From: Steve Sutton Date: Thu, 18 Jun 2015 20:39:39 +0000 (-0400) Subject: Merge branch 'master' into develop X-Git-Tag: v1.0.3~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=0adbcd9a6271f9387f8cd9d35e8fe8d352f63136;p=WP-Themes%2FTomsMomsCookies.git Merge branch 'master' into develop --- 0adbcd9a6271f9387f8cd9d35e8fe8d352f63136 diff --cc functions.php index 28a4ce4,a53b19c..e61d6af --- a/functions.php +++ b/functions.php @@@ -122,27 -128,66 +122,78 @@@ add_filter( 'woocommerce_enqueue_styles add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 48;' ), 20 ); +// This is more for Gilmore, but testing it on Tom's Mom's +add_filter('upload_mimes', 'custom_upload_mimes'); +function custom_upload_mimes ( $existing_mimes=array() ) +{ + // Add *.EPS files to Media upload + $existing_mimes['eps'] = 'application/postscript'; + // Add *.AI files to Media upload + $existing_mimes['ai'] = 'application/postscript'; + return $existing_mimes; +} + /** + * WooCommerce Checout Field Additions + */ + + // Add custom fields to checkout + + add_filter( 'woocommerce_after_order_notes' , 'tm_added_checkout_fields' ); + + function tm_added_checkout_fields( $checkout ) { + + echo '

' . __('Gift Message') . '

'; - ++ + woocommerce_form_field( 'tm_gift_message', array( + 'type' => 'textarea', + 'class' => array('my-field-class form-row-wide'), + 'label' => __(''), + 'placeholder' => __('Enter any desired gift message here.'), - 'maxlength' => 150, ++ 'maxlength' => 150, + ), $checkout->get_value( 'tm_gift_message' )); - ++ + echo '
'; + + echo '

' . __('FedEx Shipping') . '

'; - ++ + woocommerce_form_field( 'tm_fedex_shipping', array( + 'type' => 'textarea', + 'class' => array('my-field-class form-row-wide'), + 'label' => __(''), + 'placeholder' => __('If you wish to charge shipping to your FedEx Account, please provide account number OR contact phone number here.'), + ), $checkout->get_value( 'tm_fedex_shipping' )); - ++ + echo '
'; + + } + + // Get custom field data and store it in post meta data + + add_action( 'woocommerce_checkout_update_order_meta', 'tm_added_checkout_fields_order_meta' ); - ++ + function tm_added_checkout_fields_order_meta( $order_id ) { + + if ( ! empty( $_POST['tm_gift_message'] ) ) { + update_post_meta( $order_id, 'Gift Message', sanitize_text_field( $_POST['tm_gift_message'] ) ); + } + + if ( ! empty( $_POST['tm_fedex_shipping'] ) ) { + update_post_meta( $order_id, 'FedEx Shipping', sanitize_text_field( $_POST['tm_fedex_shipping'] ) ); + } + + } + -// Display custom fields in admin order data +// Add a $1.00 handling fee to all orders. +add_action( 'woocommerce_cart_calculate_fees','endo_handling_fee' ); +function endo_handling_fee() { + global $woocommerce; -add_action( 'woocommerce_admin_order_data_after_billing_address', 'tm_added_checkout_fields_admin_order_meta', 10, 1 ); + if ( is_admin() && ! defined( 'DOING_AJAX' ) ) + return; -function tm_added_checkout_fields_admin_order_meta($order){ - echo '

'.__('Gift Message').':
' . get_post_meta( $order->id, 'Gift Message', true ) . '

'; - echo '

'.__('FedEx Shipping').':
' . get_post_meta( $order->id, 'FedEx Shipping', true ) . '

'; + $fee = 1.00; + $woocommerce->cart->add_fee( 'Handling Fee', $fee, true, 'standard' ); } - - ?> +