V
V
VPVPVP2021-01-13 19:48:49
WooCommerce
VPVPVP, 2021-01-13 19:48:49

When choosing ship to different address in woocommerce, does it complain that the billing fields are not filled in?

In general, the problem is this.
When selecting the ship to different address checkbox, the worker complains that the billing fields are not filled.
Is it possible to make these fields not reqired when "ship to different address" is active?
For example, modify this function

d_filter( 'woocommerce_billing_fields', 'wc_npr_filter_phone', 10, 1 
);
function wc_npr_filter_phone( $address_fields ) {
    $address_fields['billing_phone']['required'] = false;
    $address_fields['billing_first_name']['required'] = false;
    $address_fields['billing_country']['required'] = false;
    $address_fields['billing_last_name']['required'] = false;
    $address_fields['billing_city']['required'] = false;
    $address_fields['billing_postcode']['required'] = false;
    $address_fields['billing_email']['required'] = false;
    $address_fields['billing_state']['required'] = false;
    $address_fields['billing_address_1']['required'] = false;
    $address_fields['billing_address_2']['required'] = false;
    return $address_fields;

}

So that it works only with the active checkbox ship to different address
Although it can be much simpler and there is another option.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question