• Resolved cpsharp

    (@cpsharp)


    Thanks for the great plugin – this worked fantastic for a long time. With this plugin’s 3.0+ update, this hook (shown halfway through using geoip) began causing errors for me when loading products. Basically it causes the entire product page to load. If I remove it, it works again. Any idea why?

    //this example shows prices and buy buttons ONLY in US & CA, everywhere else the store turns into a catalog
    //filter out add to cart button based on country. (https://torquemag.io/2015/02/creating-location-aware-wordpress-sites-geoip/)
    add_action( ‘woocommerce_after_shop_loop_item’, ‘remove_add_to_cart_buttons’ );
    add_action( ‘woocommerce_single_product_summary’, ‘remove_add_to_cart_buttons’ );
    add_action( ‘woocommerce_single_variation’ , ‘remove_add_to_cart_buttons’ );
    add_action( ‘woocommerce_after_shop_loop_item_title’, ‘remove_add_to_cart_buttons’ );

    function remove_add_to_cart_buttons() {
    $geoip = geoip_detect2_get_info_from_current_ip();
    $country = $geoip->raw[ ‘country’ ][ ‘iso_code’ ];
    if ( ‘US’ !== $country )
    {
    remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’ , 10 );
    remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_add_to_cart’ , 30 );
    remove_action( ‘woocommerce_single_variation’ , ‘woocommerce_single_variation_add_to_cart_button’ , 20);
    remove_action( ‘woocommerce_after_shop_loop_item_title’,’woocommerce_template_loop_price’ , 10);
    }
    }

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Function no longer works’ is closed to new replies.