Skip to content

Commit

Permalink
Round prices to two decimal places in price comparison check in basket
Browse files Browse the repository at this point in the history
Fix price comparison by rounding to two decimal places, preventing misleading cart notifications when prices are effectively the same.
Previously, the comparison between these two prices was done directly, which caused issues when the number of decimal places differed.
  • Loading branch information
fortelll committed Jan 7, 2024
1 parent 5370843 commit 05d1887
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/oscar/apps/basket/abstract_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ def get_warning(self):

# Compare current price to price when added to basket
current_price_incl_tax = self.purchase_info.price.incl_tax
if current_price_incl_tax != self.price_incl_tax:
if round(current_price_incl_tax, 2) != round(self.price_incl_tax, 2):
product_prices = {
"product": self.product.get_title(),
"old_price": currency(self.price_incl_tax, self.price_currency),
Expand Down

0 comments on commit 05d1887

Please sign in to comment.