Created
January 17, 2022 10:28
-
-
Save AnanthFlycart/39c9f2e2ad7df6b16c8cb8e387939195 to your computer and use it in GitHub Desktop.
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
| // Return filter passed true, only if all the product attributes and onsale filters are passed | |
| add_filter('advanced_woo_discount_rules_filter_passed', function ($filter_passed, $rule, $product, $sale_badge, $product_table, $conditionFailed) { | |
| if (method_exists($rule, 'getFilter')) { | |
| $filters = $rule->getFilter(); | |
| if ($filter_passed && !empty($filters) && class_exists('\Wdr\App\Helpers\Filter')) { | |
| $filter_helper = new \Wdr\App\Helpers\Filter(); | |
| foreach ($filters as $filter) { | |
| if (in_array($filter->type, array('product_attributes', 'product_on_sale'))) { | |
| $filter_piece = (object) array($filter); | |
| $custom_filter_passed = $filter_helper->matchFilters($product, $filter_piece, $sale_badge, $product_table); | |
| if ($custom_filter_passed === false) { | |
| return false; | |
| } | |
| } | |
| } | |
| } | |
| } | |
| return $filter_passed; | |
| }, 10, 6); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment