Updated the regular price key

This commit is contained in:
Afaz Khatri 2020-10-09 20:21:38 +05:30 committed by GitHub
parent 2fbbabb604
commit 95cd8c6902
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -31,6 +31,8 @@ class Product extends JsonResource
{
$product = $this->product ? $this->product : $this;
$prices = $product->getTypeInstance()->getProductPrices();
return [
'id' => $product->id,
'type' => $product->type,
@ -56,7 +58,8 @@ class Product extends JsonResource
$product->getTypeInstance()->haveSpecialPrice(),
core()->currency($product->getTypeInstance()->getSpecialPrice())
),
'prices' => $product->getTypeInstance()->getProductPrices(),
'regular_price' => data_get($prices, 'regular_price.price'),
'formatted_regular_price' => data_get($prices, 'regular_price.formated_price'),
'reviews' => [
'total' => $total = $this->productReviewHelper->getTotalReviews($product),
'total_rating' => $total ? $this->productReviewHelper->getTotalRating($product) : 0,