Added $1.00 handling fee to all orders.
authorChuck Scott <cscott@gaslightmedia.com>
Thu, 18 Jun 2015 19:46:21 +0000 (15:46 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Thu, 18 Jun 2015 19:46:21 +0000 (15:46 -0400)
functions.php

index fe04c2a..28a4ce4 100755 (executable)
@@ -68,15 +68,8 @@ function glm_offcanvas_menu()
         'menu_class' => 'right-off-canvas-list'
     ));
 }
-
 add_theme_support('post-thumbnails');
 set_post_thumbnail_size(120, 100, true);
-
-/**
- * glm_site_scripts
- *
- * Add the scripts that we'll need for any home page stuff
- */
 function glm_site_scripts()
 {
     wp_enqueue_script(
@@ -91,7 +84,7 @@ function glm_site_scripts()
         '1.0',
         true
     );
-    
+
     wp_enqueue_script(
         'dollarsign',
         get_template_directory_uri() . '/js/dollarsign.js'
@@ -110,10 +103,11 @@ function glm_site_scripts()
 }
 add_action('wp_enqueue_scripts', 'glm_site_scripts');
 
+
 add_action( 'after_setup_theme', 'woocommerce_support' );
     function woocommerce_support() {
     add_theme_support( 'woocommerce' );
-} 
+}
 
 // Remove each style one by one
 add_filter( 'woocommerce_enqueue_styles', 'jk_dequeue_styles' );
@@ -128,65 +122,27 @@ add_filter( 'woocommerce_enqueue_styles', '__return_false' );
 
 add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 48;' ), 20 );
 
-
-/**
- * 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 '<div id="tm_gift_message"><h3>' . __('Gift Message') . '</h3>';
-    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.'),
-        ), $checkout->get_value( 'tm_gift_message' ));
-    echo '</div>';
-
-    echo '<div id="tm_fedex_shipping"><h3>' . __('FedEx Shipping') . '</h3>';
-    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 and phone number here.'),
-        ), $checkout->get_value( 'tm_fedex_shipping' ));
-    echo '</div>';
-
-}
-
-// 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'] ) );
-    }
-
+// 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;
 }
 
-// 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 '<p><strong>'.__('Gift Message').':</strong><br> ' . get_post_meta( $order->id, 'Gift Message', true ) . '</p>';
-    echo '<p><strong>'.__('FedEx Shipping').':</strong><br> ' . get_post_meta( $order->id, 'FedEx Shipping', true ) . '</p>';
+    $fee = 1.00;
+    $woocommerce->cart->add_fee( 'Handling Fee', $fee, true, 'standard' );
 }
-
-
 ?>
+