Last active
May 17, 2020 10:22
-
-
Save rajeshsingh520/180715fae88ada3e539a4f419dc28ec4 to your computer and use it in GitHub Desktop.
Enable date time plugin for specific category of product only
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
<?php | |
add_action( 'wp_loaded', 'pisol_enable_plugin_for_category' ); | |
function pisol_enable_plugin_for_category(){ | |
$enable_for_cat = 107; // this will be your category id for which you want to enable the plugin | |
$plugin_disabled = true; | |
if(isset(WC()->cart)){ | |
foreach( WC()->cart->get_cart() as $cart_item ) { | |
$product_in_cart = $cart_item['product_id']; | |
if(has_term($enable_for_cat, 'product_cat', $product_in_cart)){ | |
$plugin_disabled = false; | |
} | |
} | |
} | |
if($plugin_disabled){ | |
add_filter('pisol_disable_dtt_completely',function($var){ | |
return true; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment