Skip to content

Commit

Permalink
#issue bagisto#7216
Browse files Browse the repository at this point in the history
  • Loading branch information
rachana-webkul committed Feb 10, 2023
1 parent a005174 commit c2bcce9
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions packages/Webkul/Product/src/Type/Configurable.php
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ public function canBeMovedFromWishlistToCart($item)
public function getAllowedProducts()
{
$product = $this->product;

static $variants = [];

if (count($variants)) {
Expand All @@ -532,37 +533,34 @@ public function getAllowedProducts()
return $variants;
}


protected function getVariantPrices()
{
$product = $this->product;

$prices = [];

foreach ($this->getAllowedProducts($product) as $variant) {
$prices[$variant->id] = $variant->getTypeInstance()->getProductPrices();
$prices[$variant->id] = $variant->getTypeInstance()->getProductPrices();
}

return $prices;
}


/**
* Get product prices.
*
* @return array
*/

public function getProductPrices()
{
$regularMinimalPrice = $this->getVariantPrices();
{
$minPrice = $this->getMinimalPrice();

$regularmin = $this -> getRegularMinimalPrice();

return [
'regular_price' => [
'price' => $regularMinimalPrice,
'formatted_price' => $regularMinimalPrice,
'price' => core()->convertPrice($this->evaluatePrice($regularmin)),
'formatted_price' => core()->currency($this->evaluatePrice($regularmin )),
],
'final_price' => [
'price' => $regularMinimalPrice,
'formatted_price' => $regularMinimalPrice,
'price' => core()->convertPrice($this->evaluatePrice($minPrice)),
'formatted_price' => core()->currency($this->evaluatePrice($minPrice)),
],
];
}
Expand All @@ -574,29 +572,31 @@ public function getProductPrices()
*/
public function getPriceHtml()
{
$prices = $this->getProductPrices();

$prices = $this->getVariantPrices();
$priceHtml = '';

if ($this->haveDiscount()) {
$priceHtml .= '<div class="sticker sale">' . trans('shop::app.products.sale') . '</div>';
}
foreach ($prices as $price['index'] ) {

$priceHtml .= '<div class="price-from">';
if ($this->haveDiscount()) {
$priceHtml .= '<div class="sticker sale">' . trans('shop::app.products.sale') . '</div>';
}

if ($prices['regular_price']['price'] != $prices['final_price']['price']) {
$priceHtml .= '<div class="price-from">';

$priceHtml .= '<span class="regular-price">' . $prices['regular_price']['formatted_price'] . '</span>'
. '<span class="special-price">' . $prices['final_price']['formatted_price'] . '</span>';
if ($price['index']['regular_price']['price'] != $price['index']['final_price']['price']) {

} else {
$priceHtml .= '<span class="special-price">' . $prices['regular_price']['formatted_price'] . '</span>';
}
$priceHtml .= '<span class="regular-price">' . $price['index']['regular_price']['formatted_price'] . '</span>'
. '<span class="special-price">' . $price['index']['final_price']['formatted_price'] . '</span>';

$priceHtml .= '</div>';
} else {
$priceHtml .= '<span class="special-price">' . $price['index']['regular_price']['formatted_price'] . '</span>';
}

return $priceHtml;
$priceHtml .= '</div>';
}

return $priceHtml;
}

/**
Expand Down

0 comments on commit c2bcce9

Please sign in to comment.