Apply cart discount from third party plugin price and fix cart item price and strikeout issues
Apply cart discounts from third-party plugin prices and fix cart item price and strike-through issues.
// Apply cart discount to third party plugin and fix cart item price and strikeout issues
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'), PHP_INT_MAX);
remove_filter('woocommerce_cart_item_price', array(\Wdr\App\Router::$manage_discount, 'getCartPriceHtml'), 1000);
add_filter('woocommerce_cart_item_price', array(\Wdr\App\Router::$manage_discount, 'getCartPriceHtml'), PHP_INT_MAX, 3);
if (has_filter('woocommerce_cart_item_subtotal', array(\Wdr\App\Router::$manage_discount, 'getCartProductSubtotalPriceHtml'))) {
remove_filter('woocommerce_cart_item_subtotal', array(\Wdr\App\Router::$manage_discount, 'getCartProductSubtotalPriceHtml'), 10);
add_filter('woocommerce_cart_item_subtotal', array(\Wdr\App\Router::$manage_discount, 'getCartProductSubtotalPriceHtml'), PHP_INT_MAX, 3);
}
}
});