Last active
June 9, 2021 12:37
-
-
Save Balakrishnan-flycart/108b56ee55d569a6f5393a9025c8640e to your computer and use it in GitHub Desktop.
Woo Discount Rules v2 - parent sku - woo discount rules filter check
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
add_filter('advanced_woo_discount_rules_check_sku_filter', function($product_sku, $product, $operation_values, $operation_method, $sale_badge){ | |
if(class_exists('\Wdr\App\Helpers\Woocommerce')){ | |
$parent_id = \Wdr\App\Helpers\Woocommerce::getProductParentId($product); | |
$result = false; | |
if(!empty($parent_id)){ | |
$parent_product = \Wdr\App\Helpers\Woocommerce::getProduct($parent_id); | |
$parant_product_sku = \Wdr\App\Helpers\Woocommerce::getProductSku($parent_product); | |
if ('in_list' === $operation_method) { | |
$result = (in_array($parant_product_sku, $operation_values)); | |
} elseif ('not_in_list' === $operation_method) { | |
$result = !(in_array($parant_product_sku, $operation_values)); | |
} | |
if($result){ | |
return $parant_product_sku; | |
} | |
} | |
} | |
return $product_sku; | |
}, 10, 5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment