• Resolved mixware

    (@mixware)


    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)
  • Plugin Support CodeWooGeek Support

    (@codewoogeeksupport)

    Hello there,

    Good Day!!

    Thank you for reaching out!

    To better assist you with hiding the popup based on the geolocation, could you please provide a bit more detail about how you’re currently handling the geolocation restrictions for the cart, prices, and other elements?

    Are you using the native geolocation functionality in WooCommerce, or are you utilizing a third-party plugin for this purpose?

    Once we have a clearer understanding of your setup, we’ll be able to suggest the best solution for the popup.

    Thanks.

      Thread Starter mixware

      (@mixware)

      Thanks for getting back to me.

      I am using Country Restrictions for WooCommerce to hide add-to-cart and prices.

      In the WooCommerce settings, I have also have Default customer location set to Geolocate (with page caching support) with MaxMind integration.

      Laurent

      • This reply was modified 2 months, 1 week ago by mixware.
      Plugin Support CodeWooGeek Support

      (@codewoogeeksupport)

      Hello there,

      Thank you for the details!

      Could you please confirm which plugin you are using for the country restrictions? Is it the Country Restrictions for WooCommerce plugin, or are you using the WooCommerce Product Country Based Restrictions plugin?

      If you’re using the Country Restrictions for WooCommerce plugin, please note that it is a premium plugin. Consequently, we recommend reaching out to our dedicated helpdesk at https://codewoogeek.freshdesk.com/support/home. Our team there will be able to provide you with specific guidance regarding the integration with your geolocation and popup setup.

      Thanks.

      Plugin Support CodeWooGeek Support

      (@codewoogeeksupport)

      Hello there,

      We have followed up on your query in our support forum. Kindly review the information provided there.

      Should you have any further questions or need additional assistance, please don’t hesitate to reach out. We are here to help!

      Thanks.

    Viewing 4 replies - 1 through 4 (of 4 total)
    • You must be logged in to reply to this topic.