SHARE
TWEET

Untitled

a guest Apr 23rd, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. // Do NOT include the opening php tag.
  3. // Place in your theme's functions.php file
  4.  
  5. // Set address 2 to not required
  6. add_filter('woocommerce_checkout_fields', 'unrequire_address_2_checkout_fields' );
  7.  
  8. function unrequire_address_2_checkout_fields( $fields ) {
  9.     $fields['billing']['billing_address_2']['required'] = false;
  10.     $fields['shipping']['shipping_address_2']['required'] = false;
  11.  
  12.     return $fields;
  13. }
  14.  
  15. // Remove billing address 2 from Checkout for WooCommerce
  16. add_filter('cfw_get_billing_checkout_fields', 'remove_billing_address_2_checkout_fields', 100, 3);
  17.  
  18. function remove_billing_address_2_checkout_fields( $fields ) {
  19.     $fields['billing_address_1']['end'] = true;
  20.     $fields['billing_address_1']['wrap']->start = str_replace( 'cfw-column-8', 'cfw-column-12', $fields['billing_address_1']['wrap']->start );
  21.  
  22.     unset($fields['billing_address_2']);
  23.  
  24.     return $fields;
  25. }
  26.  
  27. // Remove shipping address 2 from Checkout for WooCommerce
  28. add_filter('cfw_get_shipping_checkout_fields', 'remove_shipping_address_2_checkout_fields', 100, 3);
  29.  
  30. function remove_shipping_address_2_checkout_fields( $fields ) {
  31.     $fields['shipping_address_1']['end'] = true;
  32.     $fields['shipping_address_1']['wrap']->start = str_replace( 'cfw-column-8', 'cfw-column-12', $fields['shipping_address_1']['wrap']->start );
  33.    
  34.     unset($fields['shipping_address_2']);
  35.  
  36.     return $fields;
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top