Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rajeshsingh520/f444ac58518c651bd98f32eb3f5bab67 to your computer and use it in GitHub Desktop.
Save rajeshsingh520/f444ac58518c651bd98f32eb3f5bab67 to your computer and use it in GitHub Desktop.
disable date and time plugin for some specific range of products
class pisol_marp_disable_dtt_plugin_options{
function __construct(){
add_filter('pisol_disable_dtt_completely', array($this, 'disableDateTimePlugin'));
}
function disableDateTimePlugin($value){
if(is_admin()) return;
$disable_for_product = array(660, 665, 685); // product ids for which date and time plugin will be disabled
if(isset(WC()->cart)){
foreach( WC()->cart->get_cart() as $cart_item ) {
$product_in_cart = $cart_item['product_id'];
if(in_array($product_in_cart, $disable_for_product)){
$value = true;
}
}
}
return $value;
}
}
new pisol_marp_disable_dtt_plugin_options();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment