businessdad icon

Aelia Currency Switcher - Reset country on change of address

businessdad | PRO | 07/18/19 04:02:52 PM UTC | 0 ⭐ | 1596 👁️ | Never ⏰ | []
PHP |

1.44 KB

|

None

|

0 👍

/

0 👎

/**
 * PROTOTYPE
 * Removes the cookie with the selected country when the user changes an address on the My Account
 * page. This should trigger the "refresh" of the country and currency in the Currency Switcher, 
 * when the "force currency by country" option is enabled.
 *
 * DISCLAIMER
 * Aelia and any member of its staff are not responsible for any data loss or damage incurred
 * when using the code, which you can use at your own risk.
 *
 * GPL DISCLAIMER
 * Because this code program is free of charge, there is no warranty for it, to the extent permitted by applicable law.
 * Except when otherwise stated in writing the copyright holders and/or other parties provide the program "as is"
 * without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of
 * merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the program
 * is with you. should the program prove defective, you assume the cost of all necessary servicing, repair or correction.
 *
 * Need a consultation, or assistance to customise this code? Find us on Codeable: https://aelia.co/hire_us
 */
add_action('woocommerce_customer_save_address', function($user_id, $load_address) {
    if(class_exists('\Aelia\WC\Aelia_SessionManager')) {
        \Aelia\WC\Aelia_SessionManager::set_cookie('aelia_customer_country', '');
        unset($_COOKIE['aelia_customer_country']);
     }
}, 15, 2);

Comments