Last active
March 27, 2021 00:36
-
-
Save rajeshsingh520/f444ac58518c651bd98f32eb3f5bab67 to your computer and use it in GitHub Desktop.
disable date and time plugin for some specific range of products
This file contains hidden or 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
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