Thread Starter
alfaex
(@alfaex)
thanks @icaleb
I didn’t know about these .js files, so instead of remove the entire script, i went to see when the event is created, and i found this.
$( document.body ).bind( 'update_checkout', this.update_checkout );
After reading a little, i found that I will not be able to unbind because of the namespace, so i hooked up on the on event and since i can’t prevent default i stoped the propagation of the event.
and these solved my problem.
jQuery(document.body).on('update_checkout', function(e){
//e.preventDefault();
//e.stopPropagation();
e.stopImmediatePropagation();
//console.log(e);
});
This issue needs reporting as a bug.
Been banging my head against a brick wall all day trying to figure out why removing required fields with various filters had no effect.
Finally figured out it’s this update_order_review call.
Thread Starter
alfaex
(@alfaex)
if you want to remove a field or make not required read this.
Customizing checkout fields
you can
unset($fields['order']['order_comments']);
or
$address_fields['address_1']['required'] = false;
That’s not the issue.
Unless you customize address fields using the “woocommerce_default_address_fields” filter, any changes you make to address fields will be overridden once the javascript update_order_review takes over and each form is updated after the ajax call on checkout.
You can update woocommerce_billing_fields, woocommerce_shipping_fields and woocommerce_checkout_fields all you like, but if you’ve edited any of the address fields, you’re wasting your time.
You might say “what is the problem?”
If you want different required address fields on billing and shipping forms, you can’t have them. I don’t want any address fields required on my shipping form, for various reasons, but in order to make this happen I need to remove the required fields on the billing form too. Not ideal.