Payment methods get updated via an ajax event which is called once fields are filled in. This would be the ideal place to do any custom validation and/or tweak payment methods. Look at the JS to see what ajax events get called. The functions + hooks are in our https://github.com/woothemes/woocommerce/blob/master/includes/class-wc-ajax.php file
Thanks for the reply.
Unfortunately, every background check we do costs money. Therefore, we cannot make a check when all fields are filled in, since the user might update the fields (typos, corrections).
The only way I see right now is to completey replace the AJAX call that is made in checkout.js, function submit(). I just wonder how this will work with future updates.
You can quite easily check if all fields are complete before doing checks no? And cache the values to prevent re-checking same values.
Or just do checks when place order is clicked instead.
I apologize for injecting what might be a slightly new topic into this thread, but I believe my issue is related to this topic and may help others whose search ends here as mine did. I need to toggle checkout field visibility based on the selected payment method. I am using the ‘update_checkout’ trigger, but this does not cause an update of the checkout fields ‘billing_last_name’ ‘billing_first_name’ ‘billing_company’ ‘billing_email’ and ‘billing_phone’
Is there a trigger that I can invoke (similar to ‘update_checkout’), so that the visibility of these checkout fields updates automatically when the payment method is toggled? Note that I have implemented the fields filter and confirmed that it works by manually refreshing the page after toggling the payment method. Now I just need the checkout fields to “refresh” automatically when the payment method is toggled.
Thank you.
-
This reply was modified 9 years, 2 months ago by
deeveedee.