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
| // Don't consider product which filters does not matched | |
| add_filter('advanced_woo_discount_rules_process_discount_for_product_which_do_not_matched_filters', '__return_false', 100); |
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
| // Calculate Subtotal with Tax (Inclusive Tax) | |
| add_filter('advanced_woo_discount_rules_get_cart_subtotal', function($subtotal) { | |
| if (function_exists('WC')) { | |
| $subtotal = 0; | |
| if(isset(WC()->cart) && WC()->cart != null) { | |
| if (method_exists(WC()->cart, 'get_subtotal')) { | |
| $subtotal = WC()->cart->get_subtotal(); | |
| } elseif (isset(WC()->cart->subtotal)) { | |
| $subtotal = WC()->cart->subtotal; | |
| } |
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); |
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
| // Disable before Mini Cart Recalculate Cart Totals | |
| add_action('advanced_woo_discount_rules_after_initialize', function() { | |
| if(class_exists('\Wdr\App\Router')) { | |
| remove_filter('woocommerce_before_mini_cart', array(\Wdr\App\Router::$manage_discount, 'reCalculateCartTotal'), 10); | |
| } | |
| }); |
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); |
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
| if (!function_exists('shoptimizer_child_change_displayed_sale_price_html')) { | |
| function shoptimizer_child_change_displayed_sale_price_html() { | |
| if (function_exists('shoptimizer_get_option') && function_exists('shoptimizer_safe_html')) { | |
| global $product, $price; | |
| $shoptimizer_sale_badge = ''; | |
| $shoptimizer_layout_woocommerce_display_badge = shoptimizer_get_option('shoptimizer_layout_woocommerce_display_badge'); | |
| $shoptimizer_layout_woocommerce_display_badge_type = shoptimizer_get_option('shoptimizer_layout_woocommerce_display_badge_type'); | |
| // Use WDR discount percentage if the product has discount |
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
| // Customize the sale badge only our discount applied | |
| add_filter('advanced_woo_discount_rules_on_sale_badge_html', function($html, $post, $product) { | |
| $discounted_price = apply_filters('advanced_woo_discount_rules_get_product_discount_price_from_custom_price', false, $product, 1, 0, 'discounted_price', true, false); | |
| if($discounted_price === false) { | |
| $html = '<span class="onsale">Sale!</span>'; | |
| } | |
| return $html; | |
| }, 100, 3); |
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
| // Show promotional based text in Mini-cart | |
| add_action('advanced_woo_discount_rules_after_initialize', function() { | |
| if(class_exists('\Wdr\App\Router')) { | |
| add_action('woocommerce_before_mini_cart', array(\Wdr\App\Router::$manage_discount, 'displayPromotionMessages'), 10); | |
| } | |
| }); |
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); |