• Resolved Avinash Patel

    (@avinashdigitl)


    Hello earlier we are using below code to remove Vat when customer is from outside of UK, now we are using free version of this plugin into our site, and we want to make below code to work with when someone change currency to another for i.e. USD, then we want to remove VAT. Can you advise on this, any hook/action/filter is available for this?

    function extempt_vat_for_non_eu_firms($post_data)
    {
    	WC()->customer->set_is_vat_exempt(false);
    
    	parse_str($post_data, $output);
    
    	$countries_without_vat = array('US', 'AU', 'JE', 'AD', 'AL', 'AT', 'AX', 'BA', 'BE', 'BG', 'BY', 'CH', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FO', 'FR', 'GG', 'GI', 'GR', 'HR', 'HU', 'IE', 'IM', 'IS', 'IT', 'JE', 'LI', 'LT', 'LU', 'LV', 'MC', 'MD', 'ME', 'MK', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'RS', 'RU', 'SE', 'SI', 'SJ', 'SK', 'SM', 'TR', 'UA', 'VA', 'CA');
    
    	if ($output['ship_to_different_address'] == 1) {
    		if (in_array($output['shipping_country'], $countries_without_vat)) {
    			WC()->customer->set_is_vat_exempt(true);
    		}
    	} else {
    		if (in_array($output['billing_country'], $countries_without_vat)) {
    			WC()->customer->set_is_vat_exempt(true);
    		}
    	}
    }
    add_action('woocommerce_checkout_update_order_review', 'extempt_vat_for_non_eu_firms');

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Avinash Patel

    (@avinashdigitl)

    Hello is there any update on this please?

    Hi,

    Thank you for contacting VillaTheme.

    The code you provided should function correctly within our plugin to achieve remove VAT when one currency is changed to another.

    Best regards.

    Thread Starter Avinash Patel

    (@avinashdigitl)

    Hello we are looking for that specific action hook, in which we can add above code so that it will look like below code.

    function vat_removal_function()
    {
    	// check for currency //
    
    	// remove vat code goes here //
    }
    add_action('hook_that_will_trigger_when_currancy_change', 'vat_removal_function');

    Hi,

    In this case, you need this currency converter function: wmc_get_price

    Depending on your specific requirements, you may also need to use additional hooks to make this function work effectively and adjust on your own.

    Best regards.

    Thread Starter Avinash Patel

    (@avinashdigitl)

    Hello, yes we just need that hook name that is fire when we change currency of this plugin. Can you ask plugin developers about that one please?

    Thread Starter Avinash Patel

    (@avinashdigitl)

    Hello, i think we have figure out how to make it works with below code. Sharing it here so anyone who is looking for same problem, they can found a solution here.

    function extempt_vat_for_non_eu_firms($post_data)
    {
    	WC()->customer->set_is_vat_exempt(false);
    
    	parse_str($post_data, $output);
    
    	if (class_exists('WOOMULTI_CURRENCY_Data')) {
    		$currency_data_obj = new WOOMULTI_CURRENCY_Data();
    		$current_currency = $currency_data_obj->get_current_currency();
    
    		if ($current_currency == 'GBP') {
    			WC()->customer->set_is_vat_exempt(false);
    		} else {
    			WC()->customer->set_is_vat_exempt(true);
    		}
    	}
    }
    add_action('woocommerce_checkout_update_order_review', 'extempt_vat_for_non_eu_firms');
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to remove VAT when currency is change to other’ is closed to new replies.