Skip to content

Commit

Permalink
🐛 added discount amount according product interval count
Browse files Browse the repository at this point in the history
  • Loading branch information
M3ndes committed Jan 25, 2022
1 parent 85e35df commit 9ee3f6d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Plugin/Princing/Render/FinalPricePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ public static function getRecurrencePrice($productId)
->load($productId);

$currency = self::getLowestRecurrencePrice($subscriptionProduct, $product);
$discountAmount = ProductHelper::getDiscountAmount($product);
$currency['price'] = $currency['price'] - $discountAmount > 0 ? $currency['price'] - $discountAmount : $currency['price'];
$currency['price'] = ProductHelper::applyMoneyFormat($currency['price']);

return $currency;
Expand All @@ -109,11 +107,15 @@ private static function getLowestRecurrencePrice(
}

$price = $recurrencePrice / $repetition->getIntervalCount() / 100;
$discountAmount = ProductHelper::getDiscountAmount($product) / $repetition->getIntervalCount();

if ($repetition->getInterval() == Repetition::INTERVAL_YEAR) {
$price = $recurrencePrice / (12 * $repetition->getIntervalCount());
$discountAmount = ProductHelper::getDiscountAmount($product) / (12 * $repetition->getIntervalCount());
}

$price = $price - $discountAmount > 0 ? $price - $discountAmount : $price;

$prices[$price] = [
'price' => $price,
'interval' => $repetition->getInterval(),
Expand Down

0 comments on commit 9ee3f6d

Please sign in to comment.