function a000_remove_bundles_counting(){ ////////////////////////////// global $woocommerce_bundles; remove_filter( 'woocommerce_cart_contents_count', array( $woocommerce_bundles->display, 'woo_bundles_cart_contents_count' ) ); } add_action( 'init', 'a000_remove_bundles_counting' ); /////////////////////////////////////////////////// ////////////////////////////////////////////////////// function d000_cart_contents_count( $count ) { global $woocommerce; $cat_check = false; foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) { //foreach $product = $cart_item['data']; if ( has_term( 'VIP', 'product_tag', $product->id ) ) {//search product_cat $cat_check = true; // break because we only need one "true" to matter here if (!function_exists('woo_override_checkout_fields')) { function woo_override_checkout_fields( $fields ) { // woo_override_checkout_fields Function $fields['billing']['billing_country'] = array( 'type' => 'select', 'label' => __('Country', 'woocommerce'), 'options' => array('US' => 'United States(US)') ); $fields['billing']['billing_state'] = array( 'type' => 'select', 'label' => __('State', 'woocommerce'), 'options' => array('CA' => 'California(CA)') ); return $fields; } //end woo_override_checkout_fields Function } add_filter( 'woocommerce_checkout_fields' , 'woo_override_checkout_fields' ); } // end search product_cat }// end foreach return $count; } add_filter( 'woocommerce_cart_contents_count', 'd000_cart_contents_count' );
First you set the product tag to “VIP” or whatever you like, and then you add it to the code
if ( has_term( 'VIP', 'product_tag', $product->id ) ) {//search product_cat $cat_check = true; }
in this function is there any product with the product tag "VIP". and $cat_check = true;
then inside this, the function woo_override_checkout_fields( $fields ) is added to the function woo_override_checkout_fields( $fields ) function is limited to the country as the country of delivery.
Inside woo_override_checkout_fields( $fields ) { }
Indicate in which country you want to show
$fields['billing']['billing_country'] = array( 'type' => 'select', 'label' => __('Country', 'woocommerce'), 'options' => array('US' => 'United States(US)') ); $fields['billing']['billing_state'] = array( 'type' => 'select', 'label' => __('State', 'woocommerce'), 'options' => array('CA' => 'California(CA)') );