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('woocommerce_before_cart', function(){ | |
if(class_exists('\Wdr\App\Router') && class_exists('\Wdr\App\Controllers\DiscountCalculator') && class_exists('\Wdr\App\Helpers\Woocommerce')){ | |
$manage_discount = \Wdr\App\Router::$manage_discount; | |
$calculator = $manage_discount::$calculator; | |
$used_coupons = $calculator::getUsedCoupons(); | |
$applied_coupons = \Wdr\App\Helpers\Woocommerce::getAppliedCoupons(); | |
foreach ($applied_coupons as $applied_coupon) { | |
if (in_array($applied_coupon,$used_coupons)) { | |
$coupon = new WC_Coupon($applied_coupon); | |
// Check if the coupon has zero 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
add_filter('advanced_woo_discount_rules_advance_table_based_on_rule', function ($advanced_layout, $rule, $discount_calculator, $product, $product_price, $html_content){ | |
// Check if the product is a variable product | |
if ( $product->is_type( 'variable' ) ) { | |
// Loop through each variation | |
foreach ( $product->get_children() as $variation_id ) { | |
$variation = wc_get_product( $variation_id ); | |
if ( ! $variation->is_in_stock() ) { | |
$advanced_layout = []; | |
break; |
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('woocommerce_before_cart', function(){ | |
if(class_exists('\Wdr\App\Router') && class_exists('\Wdr\App\Controllers\DiscountCalculator') && class_exists('\Wdr\App\Helpers\Woocommerce')){ | |
$manage_discount = \Wdr\App\Router::$manage_discount; | |
$applied_rules = \Wdr\App\Controllers\DiscountCalculator::$applied_rules; | |
foreach ($applied_rules as $rule) { | |
if($rule->rule->exclusive == 1){ | |
$applied_coupons = \Wdr\App\Helpers\Woocommerce::getAppliedCoupons(); | |
$exclude_coupons = ['shipfree']; //You can add the coupons here (with comma separate) | |
foreach ($applied_coupons as $applied_coupon) { | |
if (in_array($applied_coupon,$exclude_coupons)) { |
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_advance_table_based_on_rule', function ($advanced_layout, $rule, $discount_calculator, $product, $product_price, $html_content){ | |
if(!$product->is_in_stock()){ | |
$advanced_layout = []; | |
} | |
return $advanced_layout; | |
},10,6); |
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_strikeout_price_html', function ($html, $original_price, $discounted_price, $is_variable_product, $initial_price_html, $separator) { | |
if ($original_price != $discounted_price){ | |
$html = '<ins>' . $discounted_price . '</ins>'; | |
} | |
return $html; | |
},10,6); |
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_check_purchase_first_order_status', function ($order_statuses) { | |
unset($order_statuses['wc-checkout-draft']); | |
return $order_statuses; | |
},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_filter_passed', function($filter_passed, $rule, $product, $sale_badge){ | |
$coupon_applied = in_array('your_coupon_code', WC()->cart->get_applied_coupons()); | |
//'array(1,2)' - give rule id as you needed | |
if(in_array($rule->getId(), array(1, 2)) && $coupon_applied){ | |
// Add your additional condition here if required | |
// Your custom logics enter here and return true or false | |
// true -> Run rule | |
// false -> Do not run rule | |
return true; |
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('advanced_woo_discount_rules_after_initialize', 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'), 10000); | |
} | |
}); | |
add_action('plugins_loaded', function() { | |
if(class_exists('\Wdr\App\Router')){ | |
remove_all_filters('advanced_woo_discount_rules_cart_strikeout_price_html'); |
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('admin_footer', function() { | |
?> | |
<style> | |
.wc-orders-list-table span .awdr-you-saved-text { | |
display: none !important; | |
} | |
</style> | |
<?php | |
}); |
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
// Cart page add the woocommerce you saved amount | |
add_filter('wdr_add_woocommerce_amount_saved_text', '__return_true'); | |
// Thankyou and Order page add the woocommerce you saved text | |
add_filter('wdr_add_woocommerce_amount_saved_text_order_page', '__return_true'); | |