Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Remove get total without gift cards from checkout model
fowczarek0c678b8f2f47
diff --git a/saleor/checkout/models.py b/saleor/checkout/models.pyindex 9d5dd81210..ada30ff0ca 100644--- a/saleor/checkout/models.py+++ b/saleor/checkout/models.py@@ -106,18 +106,12 @@ class Checkout(models.Model):subtotals = (line.get_total(discounts, taxes) for line in self)return sum(subtotals, ZERO_TAXED_MONEY)- def get_total_without_gift_cards(self, discounts=None, taxes=None):- """Return the total cost of the checkout without gift cards."""- return (- self.get_subtotal(discounts, taxes)- + self.get_shipping_price(taxes)- - self.discount_amount- )-def get_total(self, discounts=None, taxes=None):"""Return the total cost of the checkout."""total = (- self.get_total_without_gift_cards(discounts, taxes)+ self.get_subtotal(discounts, taxes)+ + self.get_shipping_price(taxes)+ - self.discount_amount- self.get_total_gift_cards_balance())return max(total, ZERO_TAXED_MONEY)diff --git a/saleor/checkout/utils.py b/saleor/checkout/utils.pyindex 2b266207a7..81ed2cd0c0 100644--- a/saleor/checkout/utils.py+++ b/saleor/checkout/utils.py@@ -1021,7 +1021,11 @@ def create_order(checkout: Checkout, tracking_code: str, discounts, taxes, user:add_variant_to_order(order, line.variant, line.quantity, discounts, taxes)# assign gift cards to the order- total_price_left = checkout.get_total_without_gift_cards().gross+ total_price_left = (+ checkout.get_subtotal(discounts, taxes)+ + checkout.get_shipping_price(taxes)+ - checkout.discount_amount+ ).grossfor gift_card in checkout.gift_cards.select_for_update():total_price_left = add_gift_card_to_order(order, gift_card, total_price_left)diff --git a/tests/test_checkout.py b/tests/test_checkout.pyindex 1df88e24d8..84db1f8ca1 100644--- a/tests/test_checkout.py+++ b/tests/test_checkout.py@@ -672,7 +672,11 @@ def test_create_order_with_gift_card(checkout.shipping_method = shipping_methodcheckout.save()- total_gross_without_gift_cards = checkout.get_total_without_gift_cards().gross+ total_gross_without_gift_cards = (+ checkout.get_subtotal()+ + checkout.get_shipping_price(None)+ - checkout.discount_amount+ ).grossgift_cards_balance = checkout.get_total_gift_cards_balance()order = create_order(