Last active
June 17, 2024 00:31
-
-
Save rajeshsingh520/60a7bb107c55f86dd31e40264b929200 to your computer and use it in GitHub Desktop.
This allows you to disable pickup option when product from specific categories are in the cart, in below example we have used category 19, 36
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('pisol_dtt_setting_filter_pi_type', function( $val ){ | |
$disable_pickup_for_category = [19]; | |
if ( ! did_action( 'wp_loaded' ) ) return 'Both'; | |
if(function_exists('WC') && isset(WC()->cart) && is_object(WC()->cart)){ | |
foreach( WC()->cart->get_cart() as $cart_item ) { | |
$product_in_cart = $cart_item['product_id']; | |
if(has_term($disable_pickup_for_category, 'product_cat', $product_in_cart)){ | |
return 'Delivery'; | |
} | |
} | |
} | |
return $val; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment