Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Fix price calculation for draft orders.

Maciej Korycinski377236b0c21f
diff --git a/saleor/core/taxes/interface.py b/saleor/core/taxes/interface.py
index 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.price
diff --git a/saleor/graphql/order/mutations/draft_orders.py b/saleor/graphql/order/mutations/draft_orders.py
index 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):
@classmethod
def save(cls, info, instance, cleaned_input):
- new_instance = bool(instance.pk)
+ new_instance = not bool(instance.pk)
# Process addresses
cls._save_addresses(info, instance, cleaned_input)
diff --git a/saleor/graphql/order/mutations/orders.py b/saleor/graphql/order/mutations/orders.py
index 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 ValidationError
from ....account.models import User
from ....core.taxes import ZERO_TAXED_MONEY, interface as tax_interface
from ....order import events, models
-from ....order.utils import cancel_order
+from ....order.utils import cancel_order, recalculate_order
from ....payment import CustomPaymentChoices, PaymentError
from ....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)