Fixed total coupon price per product on cart woocommerce
I don’t know what happen but in this case, I just want to add total price coupon per product on cart
Before
if(!empty($coupons)){
foreach ( WC()->cart->get_coupons() as $code => $coupon ) :
$price_new_unit = $_product->get_price()*$cart_item['quantity'];
if(in_array($product_id,$coupon->product_ids) ){
$_productItem = wc_get_product( $product_id );
$dusc=0;
wc_cart_totals_coupon_html( $coupon );
echo '<span class="coupon-text ff">';
echo '<span class="pice-c">';
//call total
echo wc_price(calu_discount($coupon,$price_new_unit,$cQty));
After
$couponDiscountTotals = WC()->cart->get_coupon_discount_totals();
//print_r($couponDiscountTotals);
if(!empty($coupons)){
foreach ( WC()->cart->get_coupons() as $code => $coupon ) :
$price_new_unit = $_product->get_price() * $cart_item['quantity'];
if ( in_array( $product_id, $coupon->product_ids ) ) {
$_productItem = wc_get_product( $product_id );
$dusc = 0;
wc_cart_totals_coupon_html( $coupon );
echo '<span class="coupon-text ff">';
echo '<span class="pice-c">';
//get total discount condition 2
if ( isset( $couponDiscountTotals[ $coupon->get_code() ] ) ) {
echo wc_price( $couponDiscountTotals[ $coupon->get_code() ] );
} else {
echo wc_price( calu_discount( $coupon, $price_new_unit, $cQty ) );
}
0 Response to "Fixed total coupon price per product on cart woocommerce"
Post a Comment
Komentar yang Anda kirim akan terlebih dahulu di moderasi oleh Admin