daily pastebin goal
19%
SHARE
TWEET

WooCommerce - Make checkout fields optional

lorro Aug 7th, 2017 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.   // WooCommerce - Make checkout fields optional
  3.   // Don't make them all optional :)
  4.   add_filter( 'woocommerce_billing_fields', 'wc_optional_billing_fields', 10, 1 );
  5.   function wc_optional_billing_fields( $address_fields ) {
  6.     $address_fields['billing_first_name']['required'] = false;
  7.     $address_fields['billing_last_name']['required'] = false;
  8.     $address_fields['billing_company']['required'] = false;
  9.     $address_fields['billing_address_1']['required'] = false;
  10.     $address_fields['billing_address_2']['required'] = false;
  11.     $address_fields['billing_city']['required'] = false;
  12.     $address_fields['billing_postcode']['required'] = false;
  13.     $address_fields['billing_country']['required'] = false;
  14.     $address_fields['billing_state']['required'] = false;
  15.     $address_fields['billing_phone']['required'] = false;
  16.     $address_fields['billing_email']['required'] = false;
  17.     return $address_fields;
  18.   }
  19.   add_filter( 'woocommerce_shipping_fields', 'wc_optional_shipping_fields', 10, 1 );
  20.   function wc_optional_shipping_fields( $address_fields ) {
  21.     $address_fields['shipping_first_name']['required'] = false;
  22.     $address_fields['shipping_last_name']['required'] = false;
  23.     $address_fields['shipping_company']['required'] = false;
  24.     $address_fields['shipping_address_1']['required'] = false;
  25.     $address_fields['shipping_address_2']['required'] = false;
  26.     $address_fields['shipping_city']['required'] = false;
  27.     $address_fields['shipping_postcode']['required'] = false;
  28.     $address_fields['shipping_country']['required'] = false;
  29.     $address_fields['shipping_state']['required'] = false;
  30.     $address_fields['shipping_phone']['required'] = false;
  31.     $address_fields['shipping_email']['required'] = false;
  32.     return $address_fields;
  33.   }
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
 
Top