Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions Components/LengowProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,18 +514,23 @@ private function getPrices()
{
$detailPrice = $this->getDetailPrice();
$tax = $this->article->getTax() ? $this->article->getTax()->getTax() : 0;
// get original price before discount
// get price
$priceExclTax = $detailPrice ? $detailPrice->getPrice() : 0;
$priceInclTax = $priceExclTax * (100 + $tax) / 100;
// get price with discount
$discount = $detailPrice ? $detailPrice->getPercent() : 0;
$discountPriceExclTax = $priceExclTax * (1 - ($discount / 100));
$discountPriceInclTax = $discountPriceExclTax * (100 + $tax) / 100;
// get price before discount
$beforeDiscountPriceExclTax = $priceExclTax;
$beforeDiscountPriceInclTax = $priceInclTax;
$discount = $detailPrice && $detailPrice->getPseudoPrice() > 0 && $priceExclTax > 0 && $detailPrice->getPseudoPrice() > $priceExclTax ? ((($detailPrice->getPseudoPrice()-$priceExclTax)/$detailPrice->getPseudoPrice())*100) : 0;
if ($discount > 0) {
$beforeDiscountPriceExclTax = $detailPrice ? $detailPrice->getPseudoPrice() : 0;
$beforeDiscountPriceInclTax = $beforeDiscountPriceExclTax * (100 + $tax) / 100;
}

return array(
'price_excl_tax' => round($discountPriceExclTax, 2),
'price_incl_tax' => round($discountPriceInclTax, 2),
'price_before_discount_excl_tax' => round($priceExclTax, 2),
'price_before_discount_incl_tax' => round($priceInclTax, 2),
'price_excl_tax' => round($priceExclTax, 2),
'price_incl_tax' => round($priceInclTax, 2),
'price_before_discount_excl_tax' => round($beforeDiscountPriceExclTax, 2),
'price_before_discount_incl_tax' => round($beforeDiscountPriceInclTax, 2),
'discount_percent' => $discount,
);
}
Expand Down