problems and more problems!
-
hello good, I’m trying to do something (in theory) simple but there’s no way!
The idea is to detect if the client is from 3 specific provinces and, if there is one, that both the prices and the buttons to add to the cart are hidden.
the code is the following and I can not get it to work:
$ip = $_SERVER[‘REMOTE_ADDR’];
$record = geoip_detect2_get_info_from_current_ip($ip);
$prov = $record->mostSpecificSubdivision->isoCode;function ven(){
if ($prov == ‘A’ || $prov == ‘MU’ || $prov == ‘V’) {
remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’, 20 );
remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10 );
remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_add_to_cart’, 30 );
remove_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_loop_price’, 10 );
add_action( ‘woocommerce_single_product_summary’, ‘nuevo’, 31 );
add_action( ‘woocommerce_after_shop_loop_item’, ‘nuevo’, 11 );
}
else { return false; }
}function nuevo() {
global $product;
$product_type = $product->product_type;
switch ( $product_type ) {
case ‘simple’:
echo ‘Consultar<style>.woocommerce .button { display: none;}</style>’;
break;
case ‘variable’:
echo ‘Consultar‘;
break;
default:
echo ‘Consultar‘;
}
}add_action(‘init’, ‘ven’);
and thank you very much for the plugin!
- The topic ‘problems and more problems!’ is closed to new replies.