Last active
June 15, 2020 07:07
-
-
Save Balakrishnan-flycart/a8d3ebbf74d68a3fd87c13af34c42f21 to your computer and use it in GitHub Desktop.
Discount rules v2: Woocommerce Deposits compatible - Remove subtotal 0
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_run_discount_rules', function($run_rule, $cart){ | |
return false; | |
}, 10, 2); | |
add_action( 'woocommerce_cart_loaded_from_session', function($cart){ | |
if ( sizeof( $cart->cart_contents ) > 0 ) { | |
foreach ( $cart->cart_contents as $cart_item_key => $cart_item ) { | |
$cart_key = isset($cart_item['key'])? $cart_item['key'] : ''; | |
$cart_item_data = isset($cart_item['data'])? $cart_item['data'] : ''; | |
if(!empty($cart_key) && class_exists('\Wdr\App\Controllers\ManageDiscount')){ | |
$manageDiscount = new Wdr\App\Controllers\ManageDiscount(); | |
$manageDiscount->calculateCartPageDiscounts(); | |
$discounted_price = isset($manageDiscount::$calculated_cart_item_discount[$cart_key]['discounted_price_with_tax']) ? $manageDiscount::$calculated_cart_item_discount[$cart_key]['discounted_price_with_tax'] : 0 ; | |
if(!empty($discounted_price)){ | |
if (method_exists($cart_item_data, 'set_price')) { | |
$cart_item_data->set_price($discounted_price); | |
} | |
} | |
} | |
} | |
} | |
}, 90, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment