add_filter( 'woocommerce_cart_item_subtotal', 'hz_get_coupon_discounted_price', 10, 3 );
function hz_get_coupon_discounted_price( $subtotal, $cart_item, $cart_item_key ){
$_product = $cart_item['data'];
$product_id = $_product->get_ID();
$coupons = WC()->cart->get_applied_coupons();
$subtotal = WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] );
$product_price = $_product->get_price();
foreach ($coupons as $coupon) {
$coupon = new WC_Coupon( $coupon );
$discount_type = $coupon->get_discount_type();
$product_ids = $coupon->get_product_ids();
if( in_array( $product_id, $product_ids ) ){
$subtotal = wc_price( intval( $product_price ) - intval( $coupon->get_amount() ) );
return $product_price .'||'. $subtotal;
@$_GET[ '_dev' ] == 'coup' ? pre( $subtotal, 1 ) : '';
}
}
return WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] );
}