CLARIFICATION FOR ALL :
You use virtual products on your shop.
On checkout page, you have created and set an additional checkbox for european VAT purpose.
There is 3 cases related to this checkbox.
- Checkbox is hidden (default)
- Checkbox is visible when selected country is an european
country:- Checkbox disabled (default) => set the VAT value to ‘0’
(vat is not applied). - Checkbox enabled:
- VAT is applied normally
- Hide (unset) all fields in billing details except email field and country selector.
- Checkbox disabled (default) => set the VAT value to ‘0’
WHAT IS NOT WORKING
Your php functions related to checkbox detection state, because you use $_POST['my_checkbox']
but you don’t post (submit) anything, you have just an enable/disable state on a form item.
WHAT DO YOU NEED TO DO (not done yet) :
- Define the european countries => Visible checkbox state
- You need to use javascript/jQuery
.select()
form event for detection and Ajax in javascript and wordpress.
Read this article: 5 TIPS FOR USING AJAX IN WORDPRESS.
You can search and find a lot of related stuff to wordpress ajax and form element detection state over this forum threads.