Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix price calculation for draft orders.
Maciej Korycinski377236b0c21f
diff --git a/saleor/core/taxes/interface.py b/saleor/core/taxes/interface.pyindex aa19aa097e..609753c875 100644--- a/saleor/core/taxes/interface.py+++ b/saleor/core/taxes/interface.py@@ -60,7 +60,7 @@ def calculate_checkout_shipping(def calculate_order_shipping(order: "Order") -> TaxedMoney:"""Calculate shipping price that assigned to order"""if settings.VATLAYER_ACCESS_KEY:- return calculate_order_shipping(order)+ return vatlayer_interface.calculate_order_shipping(order)elif settings.AVATAX_USERNAME_OR_ACCOUNT and settings.AVATAX_PASSWORD_OR_LICENSE:return avatax_interface.calculate_order_shipping(order)price = order.shipping_method.pricediff --git a/saleor/graphql/order/mutations/draft_orders.py b/saleor/graphql/order/mutations/draft_orders.pyindex 3fbd88a43b..49967485a2 100644--- a/saleor/graphql/order/mutations/draft_orders.py+++ b/saleor/graphql/order/mutations/draft_orders.py@@ -163,7 +163,7 @@ class DraftOrderCreate(ModelMutation, I18nMixin):@classmethoddef save(cls, info, instance, cleaned_input):- new_instance = bool(instance.pk)+ new_instance = not bool(instance.pk)# Process addressescls._save_addresses(info, instance, cleaned_input)diff --git a/saleor/graphql/order/mutations/orders.py b/saleor/graphql/order/mutations/orders.pyindex 9674a7344f..4674251bdc 100644--- a/saleor/graphql/order/mutations/orders.py+++ b/saleor/graphql/order/mutations/orders.py@@ -4,7 +4,7 @@ from django.core.exceptions import ValidationErrorfrom ....account.models import Userfrom ....core.taxes import ZERO_TAXED_MONEY, interface as tax_interfacefrom ....order import events, models-from ....order.utils import cancel_order+from ....order.utils import cancel_order, recalculate_orderfrom ....payment import CustomPaymentChoices, PaymentErrorfrom ....payment.utils import (clean_mark_order_as_paid,@@ -182,6 +182,9 @@ class OrderUpdateShipping(BaseMutation):"shipping_price_gross",])+ # Post-process the results+ recalculate_order(order)+return OrderUpdateShipping(order=order)