Merge remote-tracking branch 'dummy/patch-1' into dummy-1

Merged
This commit is contained in:
devansh bawari 2020-10-30 17:04:18 +05:30
commit 43457b225e
1 changed files with 5 additions and 1 deletions

View File

@ -30,6 +30,8 @@ class Product extends JsonResource
public function toArray($request)
{
$product = $this->product ? $this->product : $this;
$prices = $product->getTypeInstance()->getProductPrices();
return [
'id' => $product->id,
@ -56,6 +58,8 @@ class Product extends JsonResource
$product->getTypeInstance()->haveSpecialPrice(),
core()->currency($product->getTypeInstance()->getSpecialPrice())
),
'regular_price' => data_get($prices, 'regular_price.price'),
'formated_regular_price' => data_get($prices, 'regular_price.formated_price'),
'reviews' => [
'total' => $total = $this->productReviewHelper->getTotalReviews($product),
'total_rating' => $total ? $this->productReviewHelper->getTotalRating($product) : 0,
@ -67,4 +71,4 @@ class Product extends JsonResource
'updated_at' => $this->updated_at,
];
}
}
}