This file contains 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
/** | |
* To handle the low price product in set discount. | |
* Works from Discount rules v2.6.1 | |
*/ | |
add_filter('advanced_woo_discount_rules_matched_set_discount_range', function ($selected_bundle_range, $product, $rule, $cart_items, $is_cart){ | |
if(class_exists('\Wdr\App\Helpers\Woocommerce')){ | |
if($is_cart){ | |
if(!empty($selected_bundle_range->type) && $selected_bundle_range->type == 'fixed_set_price'){ | |
if(!empty($cart_items)){ | |
$discounted_price = $selected_bundle_range->value; |
This file contains 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('isPossibleToHaveDiscountThroughWDR')) { | |
function isPossibleToHaveDiscountThroughWDR() { | |
$status = false; | |
if (class_exists('\Wdr\App\Controllers\DiscountCalculator')) { | |
$rules = \Wdr\App\Controllers\DiscountCalculator::$rules; | |
$cart = \Wdr\App\Helpers\Woocommerce::getCart(); | |
foreach ($rules as $rule) { | |
if ($rule->isEnabled()) { | |
if ($rule->hasConditions()) { | |
$conditions_passed = $rule->isCartConditionsPassed($cart); |
This file contains 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_discount_prices_of_product', function ($discount_prices, $product, $quantity, $cart_item){ | |
$regular_price = $product->get_regular_price(); | |
$sale_price = $product->get_price(); | |
$default_discount = $regular_price - $sale_price; | |
$non_applied_qty = $discount_prices['discount_lines']['non_applied']['quantity']; | |
if(($default_discount) > 0 && $non_applied_qty > 0){ | |
$discount_prices['initial_price'] = $sale_price; | |
$discount_prices['discounted_price'] = $discount_prices['discounted_price'] - (($default_discount*$non_applied_qty)/$quantity); | |
} |
This file contains 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_scheduled_rebuild_on_sale_index_event_recurrence', function ($recurrence){ | |
$recurrence = 'hourly'; | |
return $recurrence; | |
}, 10, 1); |
This file contains 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_is_conditions_passed', function($result, $rule_object, $rule){ | |
$conditions = $rule_object->getConditions(); | |
$cart = null; | |
if(function_exists('WC')){ | |
$cart = WC()->cart->get_cart(); | |
} | |
if(empty($cart) && !empty($conditions) && count((array)$conditions) == 1) | |
foreach ($conditions as $condition) { | |
$type = isset($condition->type) ? $condition->type : NULL; | |
if($type == 'cart_subtotal' && ($condition->options->operator == 'less_than_or_equal' || $condition->options->operator == 'less_than')){ |
This file contains 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_action('wp_loaded', function() { | |
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 ); | |
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 ); | |
}, 100); |
This file contains 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
// To override Cart Page Overrides (increase priority to higher) | |
add_action('wp_loaded', function() { | |
if(class_exists('\Wdr\App\Router')){ | |
remove_action('woocommerce_before_calculate_totals', array(\Wdr\App\Router::$manage_discount, 'applyCartProductDiscount'), 1000); | |
add_action('woocommerce_before_calculate_totals', array(\Wdr\App\Router::$manage_discount, 'applyCartProductDiscount'), PHP_INT_MAX); | |
remove_all_filters('woocommerce_cart_item_price'); | |
add_filter('woocommerce_cart_item_price', array(\Wdr\App\Router::$manage_discount, 'getCartPriceHtml'), 1000, 3); | |
if (has_filter('woocommerce_cart_item_subtotal', array(\Wdr\App\Router::$manage_discount, 'getCartProductSubtotalPriceHtml'))) { | |
add_filter('woocommerce_cart_item_subtotal', array(\Wdr\App\Router::$manage_discount, 'getCartProductSubtotalPriceHtml'), 10, 3); | |
} |
This file contains 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_action('wp_footer','woo_disocunt_rules_slide_cart_fix'); | |
function woo_disocunt_rules_slide_cart_fix(){ | |
?> | |
<script type="text/javascript"> | |
// Ready state | |
(function($){ | |
$( document.body ).on( 'added_to_cart removed_from_cart', function(){ | |
jQuery( document.body ).trigger( 'wc_fragment_refresh' ); | |
jQuery( document.body ).trigger( 'wc_fragment_refresh' ); | |
}); |
NewerOlder