Guest User

Checkout Fields for Free Products

a guest
Oct 31st, 2015
472
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /** =BMZ Checkout Fields for Free Products and User logged_in/not_logged_in */
  2. add_filter( 'woocommerce_checkout_fields', 'bmz_checkout_fields', 20 );
  3. function bmz_checkout_fields( $fields ) {
  4.     //global $woocommerce;
  5.  
  6.     // standard
  7.     if ( is_checkout() && WC()->cart->needs_payment() || is_checkout() && WC()->cart->needs_shipping() ) {
  8.         unset($fields['billing']['billing_address_2']);
  9.         //unset($fields['billing']['billing_country']);
  10.  
  11.         return $fields;
  12.     }
  13.  
  14.     // user not logged in
  15.     if ( !is_user_logged_in() ) {    
  16.             remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
  17.             remove_filter('woocommerce_after_order_notes','bmz_paid_product_order_notes'); //my notes for user + paid product  
  18.             add_filter('woocommerce_after_order_notes','bmz_free_product_order_notes'); // my notes for user + free product
  19.             add_filter( 'woocommerce_order_button_text', create_function( '', 'return "Free For You";' ) );
  20.  
  21.             /***** woo themes eu vat number plugin *******/
  22.             remove_filter('woocommerce_after_checkout_billing_form', array('WC_EU_VAT_Number', 'vat_number_field'));
  23.  
  24.             unset( $fields['billing']['billing_country'] );
  25.             unset( $fields['billing']['billing_company'] );
  26.             unset( $fields['billing']['billing_address_1'] );
  27.             unset( $fields['billing']['billing_address_2'] );
  28.             unset( $fields['billing']['billing_city'] );
  29.             unset( $fields['billing']['billing_state'] );
  30.             unset( $fields['billing']['billing_postcode'] );
  31.             unset( $fields['billing']['billing_phone'] );  
  32.         return $fields;
  33.     }
  34.  
  35.     // user logged in  
  36.     remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
  37.     remove_filter('woocommerce_after_order_notes','bmz_paid_product_order_notes'); // my notes for user + paid product  
  38.     add_filter('woocommerce_after_order_notes','bmz_free_product_order_notes_logged_in_user');  //my notes for user + free product
  39.     add_filter( 'woocommerce_order_button_text', create_function( '', 'return "Acquista gratuitamente";' ) );  
  40.  
  41.     /***** woothemes eu vat number plugin*******/
  42.     remove_filter('woocommerce_after_checkout_billing_form', array('WC_EU_VAT_Number', 'vat_number_field'));                
  43.  
  44.     unset( $fields['billing']['billing_first_name']);
  45.     unset( $fields['billing']['billing_last_name']);
  46.     unset( $fields['billing']['billing_country'] );
  47.     unset( $fields['billing']['billing_company'] );
  48.     unset( $fields['billing']['billing_address_1'] );
  49.     unset( $fields['billing']['billing_address_2'] );
  50.     unset( $fields['billing']['billing_city'] );
  51.     unset( $fields['billing']['billing_state'] );
  52.     unset( $fields['billing']['billing_postcode'] );
  53.     unset( $fields['billing']['billing_phone'] );  
  54.     //unset( $fields['billing']['vat_number_field'] );
  55.  
  56.     return $fields;
  57. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×