Skip to content

Commit

Permalink
fix: coderabbitai feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
kzamanbd committed Dec 26, 2024
1 parent a126a95 commit 95f27e6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions includes/Vendor/Coupon.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function ( $coupon_temp ) use ( $coupon_codes ) {
$coupon_info[ $coupon->get_code() ] = [
'discount' => $discount_amount,
'coupon_code' => $coupon->get_code(),
'per_qty_amount' => $discount_amount / $item_object['quantity'],
'per_qty_amount' => $item_object['quantity'] > 0 ? ( $discount_amount / $item_object['quantity'] ) : 0,
'quantity' => $item_object['quantity'],
];
}
Expand Down Expand Up @@ -255,7 +255,8 @@ public function add_coupon_info_to_order_item( $item, $cart_item_key, $values ):

if ( $total_discount > $total_product_price && $limit_reached === false ) {
$remain_discount = $total_discount - $total_product_price;
$coupon_info[ $key ]['discount'] = $coupon['discount'] - $remain_discount;
$adjusted_discount = max( $coupon['discount'] - $remain_discount, 0 );
$coupon_info[ $key ]['discount'] = $adjusted_discount;
$limit_reached = true;
}
}
Expand Down

0 comments on commit 95f27e6

Please sign in to comment.