From 05d188735915e733eafb84250b045d9d13ca81f1 Mon Sep 17 00:00:00 2001 From: fortelll <61501955+fortelll@users.noreply.github.com> Date: Sun, 7 Jan 2024 18:44:15 +0100 Subject: [PATCH] Round prices to two decimal places in price comparison check in basket 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. --- src/oscar/apps/basket/abstract_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/oscar/apps/basket/abstract_models.py b/src/oscar/apps/basket/abstract_models.py index 5d3f6877d0..c11d95bc8b 100644 --- a/src/oscar/apps/basket/abstract_models.py +++ b/src/oscar/apps/basket/abstract_models.py @@ -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),