When we apply coupon for discount its applied for sale price by default but sometimes we need to apply discount coupon on regular price .
On Bellow There is a code implement it on Your Theme on File Name : function.php
By default cart and product show sale price after applying this code Regular price will be update on cart.
Code :
add_action( 'woocommerce_before_calculate_totals', 'add_custom_price', 10, 1); function add_custom_price( $cart_object) { global $woocommerce; if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return; $coupon = False; if ($coupons = WC()->cart->get_applied_coupons() == False ) $coupon = False; else { foreach ( WC()->cart->get_applied_coupons() as $code ) { $coupons1 = new WC_Coupon( $code ); if ($coupons1->type == 'percent_product' || $coupons1->type == 'percent') $coupon = True; } } if ($coupon == True) foreach ( $cart_object->get_cart() as $cart_item ) { $price = $cart_item['data']->regular_price; $cart_item['data']->set_price( $price ); } }