Skip to content

Instantly share code, notes, and snippets.

@rajeshsingh520
Created October 17, 2025 02:14
Show Gist options
  • Select an option

  • Save rajeshsingh520/e97df3c5cd4db25c7aaa8caa1a26405f to your computer and use it in GitHub Desktop.

Select an option

Save rajeshsingh520/e97df3c5cd4db25c7aaa8caa1a26405f to your computer and use it in GitHub Desktop.
disable date and time plugin for multiple categories
class pisol_custom_disable_20221118 {
private $disable_for_cats = [];
function __construct($cats) {
$this->disable_for_cats = is_array($cats) ? $cats : [$cats];
add_filter('pisol_disable_dtt_completely', [$this, 'disable']);
}
function disable($return) {
$only_special_cat_present = true;
if (isset(WC()->cart) && WC()->cart->get_cart_contents_count() > 0) {
foreach (WC()->cart->get_cart() as $cart_item) {
$product_id = $cart_item['product_id'];
$in_target_cat = false;
foreach ($this->disable_for_cats as $cat_id) {
if (has_term($cat_id, 'product_cat', $product_id)) {
$in_target_cat = true;
break;
}
}
if (!$in_target_cat) {
$only_special_cat_present = false;
break;
}
}
}
return $only_special_cat_present;
}
}
add_action('wp_loaded', function() {
new pisol_custom_disable_20221118([15, 105]);
}, 20);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment