Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Enable support for WooCommerce Price Based on Country
<?php // don't include this line
/**
* Enable support for WooCommerce Price Based on Country and GeotargetingWP
* First enable cache mode or you will consume lot of credits.
*/
add_action( 'wc_price_based_country_before_frontend_init', 'geotwp_wcpb_set_country', 15 );
function geotwp_wcpb_set_country(){
wcpbc_set_woocommerce_country( geot_country_code() );
//trigger refresh mini cart
add_action( 'wp_print_footer_scripts', array( 'WCPBC_Frontend', 'localize_frontend_script' ), 5 );
}
// Woocommerce
add_filter('woocommerce_geolocate_ip' , 'GeotFunctions\woo_geolocate_ip', 99 );
function woo_geolocate_ip() {
return geot_country_code();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.