Created
February 11, 2022 10:38
-
-
Save AnanthFlycart/01ac9b74a19574e33e52543d18722427 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 products and attributes 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('products', 'product_attributes'))) { | |
| $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