Apply coupon and remove billing details field
-
I’m interested in removing some of the billing details fields when a specific coupon is applied to the cart.
I’ve successfully used this code (below), however the fields only change after I refresh the browser page. When the coupon code is applied the “your order” totals are dynamically updated but I can’t get the Billing Details to update.
Is this custom Javascript or can this happen with WC actions?
add_filter( 'woocommerce_checkout_fields' ,'custom_override_checkout_fields' ); function custom_override_checkout_fields( $fields ) { global $woocommerce; $coupon_id = 'cheeks'; if (in_array($coupon_id, $woocommerce->cart->get_applied_coupons())) { //unset($fields['billing']['billing_first_name']); //unset($fields['billing']['billing_last_name']); unset($fields['billing']['billing_address_1']); unset($fields['billing']['billing_address_2']); unset($fields['billing']['billing_city']); unset($fields['billing']['billing_postcode']); unset($fields['billing']['billing_country']); unset($fields['billing']['billing_state']); unset($fields['billing']['billing_phone']); unset($fields['billing']['billing_company']); //unset($fields['billing']['billing_email']); unset($fields['order']['order_comments']); } return $fields; }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Apply coupon and remove billing details field’ is closed to new replies.