Geolocation
-
Is it possible to add geolocation to hide the popup in certain countries? Currently I have the cart, price, and other scripts hidden in Europe, but the popup still shows. So even though people can’t order or view stock in those countries, they can still sign up for stock notifications. I tried a few methods including the one below, but none seem to work.
function restrict_back_in_stock_notifier_for_europe() {
if (class_exists('WC_Geolocation')) {
$geolocation = new WC_Geolocation();
$location = $geolocation->geolocate_ip();
$country = isset($location['country']) ? $location['country'] : '';
$european_countries = ['AL', 'AD', 'AT', 'BE', 'BG', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'GB'];
if (in_array($country, $european_countries)) {
// Remove plugin actions
remove_action('wp_enqueue_scripts', 'CWG_Instock_Bot_Protection->enqueue_script', 999);
remove_action('wp_enqueue_scripts', 'CWG_Instock_Notifier->enqueue_scripts', 999);
remove_action('woocommerce_simple_add_to_cart', 'CWG_Instock_Notifier_Product->display_in_simple_product', 31);
remove_action('cwginstock_custom_form', 'CWG_Sweetalert_Popup->display_custom_button', 10);
}
}
}
add_action('plugins_loaded', 'restrict_back_in_stock_notifier_for_europe', 20);The page I need help with: [log in to see the link]
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.