Apply discounts only for a specific products which has custom field data (meta)
Apply discounts only to specific products with custom field data (meta).
// Apply discounts only specific products which has custom field data (meta)
add_filter('advanced_woo_discount_rules_filter_passed', function($filter_passed, $rule, $product) {
if (is_object($product) && method_exists($product, 'get_id')) {
$product_id = $product->get_id();
if (!get_post_meta($product_id, 'your_key', true)) { // here you need to add your custom field's meta key
return false;
}
}
return $filter_passed;
}, 100,3);PreviousExclude MIL- prefixed coupons while remove other cart couponsNextExclude child products from apply discounts (compatibility for WooCommerce Product Bundles)
Last updated