Override Cart page overrides (by increase priority to higher and suppress some hooks)
Fix mini-cart refresh issues in the Floating Sticky Cart for WooCommerce.
// 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);
}
}
}, 100);
/* Show sale & regular price on the checkout page */
add_filter("woocommerce_cart_item_subtotal", "al_display_discount_price_override_by_discount_rule", 11, 3);
function al_display_discount_price_override_by_discount_rule($product_price, $cart_item, $cart_item_key)
{
$regular_price = wc_price( $cart_item['data']->get_regular_price() );
if( $product_price != $regular_price )
{
if(isset( $cart_item['cartflows_bump'] ) && 1 == $cart_item['cartflows_bump'])
{
$product_price = wc_format_sale_price( $cart_item['data']->get_regular_price(), $cart_item['custom_price'] );
}else{
$product_price = wc_format_sale_price( $cart_item['data']->get_regular_price(), $cart_item['data']->get_price() );
}
}
return $product_price;
}
/* Show sale & regular price on the checkout page */