0
0 Comments

add_action( 'woocommerce_before_cart', 'c2_find_product_in_cart' );
 function c2_find_product_in_cart() {
 $product_id = 111;
 $product_cart_id = WC()->cart->generate_cart_id( $product_id );
$in_cart = WC()->cart->find_product_in_cart( $product_cart_id );
 if ( $in_cart ) {
//JS
// $notice = 'Product ID ' . $product_id . ' is in the Cart!';
//wc_print_notice( $notice, 'notice' );
 add_filter( 'woocommerce_countries', 'woo_remove_specific_country', 10, 1 );
}
 }
 function woo_remove_specific_country( $country )
{
unset($country["AF"]);
unset($country["AX"]);
unset($country["AL"]);
unset($country["CA"]);
return $country;
}
 add_action( 'woocommerce_checkout_before_customer_details', 'c2_find_product_in_cart', 20 );

admin Edited question February 23, 2022
Add a Comment