Created
December 28, 2021 12:20
-
-
Save AnanthFlycart/78869eac65971ccfd4a6e806224a5874 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 category 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('product_category', '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