Skip to content

Commit

Permalink
Bug fix for variable product price in cart API
Browse files Browse the repository at this point in the history
  • Loading branch information
ChetanGN committed Jul 31, 2024
1 parent ba0b5e8 commit 06099c1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions includes/api/cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,12 @@ function getCartLineItem()
$data[$i]['product_id'] = $item['product_id'];
$data[$i]['image_url'] = $productImage? wp_get_attachment_url( $productImage ) : null;
$data[$i]['product_url'] = $product->get_permalink();
$data[$i]['price'] = (empty($product->get_price())=== false) ? $price/$item['quantity'] : 0;
$data[$i]['price'] = (empty($productDetails['price']) === false) ? (int)$productDetails['price'] * 100 / $item['quantity'] : 0;
$data[$i]['variant_id'] = $item['variation_id'];
$data[$i]['offer_price'] = (empty($productDetails['sale_price'])=== false) ? (int) $productDetails['sale_price']*100 : $price/$item['quantity'];
$data[$i]['offer_price'] = (empty($productDetails['sale_price']) === false) ? (int)$productDetails['sale_price'] * 100 : $price / $item['quantity'];
if ($data[$i]['price'] < $data[$i]['offer_price']) {
$data[$i]['price'] = $data[$i]['offer_price'];
}
$i++;
}

Expand Down

0 comments on commit 06099c1

Please sign in to comment.