Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AnanthFlycart/4d283a18b474c5fb3191c8198b27351f to your computer and use it in GitHub Desktop.
Save AnanthFlycart/4d283a18b474c5fb3191c8198b27351f to your computer and use it in GitHub Desktop.
// 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'))) {
remove_all_filters('woocommerce_cart_item_subtotal');
add_filter('woocommerce_cart_item_subtotal', array(\Wdr\App\Router::$manage_discount, 'getCartProductSubtotalPriceHtml'), 10, 3);
} else {
remove_all_filters('woocommerce_cart_item_subtotal');
}
}
}, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment