Woocommerce Deposits compatible - Remove subtotal 0
Compatibility with Woocommerce Deposits - Remove subtotal if it's 0.
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 );