Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Update taxes on shipping address change, remove order_line_updated plugin hook
Tomasz Szymanskid31d507ff60e
diff --git a/saleor/graphql/order/mutations/orders.py b/saleor/graphql/order/mutations/orders.pyindex cb530b5403..8b0b5cf043 100644--- a/saleor/graphql/order/mutations/orders.py+++ b/saleor/graphql/order/mutations/orders.py@@ -206,6 +206,7 @@ class OrderUpdate(DraftOrderCreate):user = User.objects.filter(email=instance.user_email).first()instance.user = userinstance.save()+ update_order_prices(instance, info.context.discounts)info.context.plugins.order_updated(instance)diff --git a/saleor/order/utils.py b/saleor/order/utils.pyindex 60f4045a87..04d353874d 100644--- a/saleor/order/utils.py+++ b/saleor/order/utils.py@@ -135,6 +135,16 @@ def update_order_prices(order, discounts):)price = manager.calculate_order_line_unit(order, line, variant, product)+ if price is not None:+ net = price.net.amount+ total_price_net_amount = net * line.quantity+ total_price_gross_amount = line.unit_price.gross.amount * line.quantity+ line.total_price_net_amount = total_price_net_amount.quantize(+ Decimal("0.001")+ )+ line.total_price_gross_amount = total_price_gross_amount.quantize(+ Decimal("0.001")+ )if price != line.unit_price:line.unit_price = priceif price.tax and price.net:@@ -299,7 +309,9 @@ def change_order_line_quantity(context, line, old_quantity, new_quantity):line.quantity = new_quantityline.save(update_fields=["quantity"])net = line.unit_price.net.amount- unit_price = context.plugins.order_line_updated(line.order, line)+ unit_price = context.plugins.calculate_order_line_unit(+ line.order, line, line.variant, line.variant.product+ )if unit_price is not None:net = unit_price.net.amounttotal_price_net_amount = net * line.quantitydiff --git a/saleor/plugins/avatax/plugin.py b/saleor/plugins/avatax/plugin.pyindex 5f9fe29550..485fd91699 100644--- a/saleor/plugins/avatax/plugin.py+++ b/saleor/plugins/avatax/plugin.py@@ -451,20 +451,6 @@ class AvataxPlugin(BasePlugin):get_order_tax_data(order, self.config, True)- def order_line_updated(- self, order: "Order", order_line: "OrderLine", previous_value: Any- ) -> Any:- if self._skip_plugin(previous_value):- return previous_value-- return self.calculate_order_line_unit(- order,- order_line,- order_line.variant, # type: ignore- order_line.variant.product, # type: ignore- previous_value,- )-def get_tax_rate_type_choices(self, previous_value: Any) -> List[TaxType]:if not self.active:return previous_valuediff --git a/saleor/plugins/base_plugin.py b/saleor/plugins/base_plugin.pyindex cfbe8c2ce9..4cb4f5d5a2 100644--- a/saleor/plugins/base_plugin.py+++ b/saleor/plugins/base_plugin.py@@ -489,16 +489,6 @@ class BasePlugin:"""return NotImplemented- def order_line_updated(- self, order: "Order", order_line: "OrderLine", previous_value: Any- ) -> Any:- """Trigger after order line is updated.-- Overwrite this method if you need to trigger specific logic after an order line is- updated.- """- return NotImplemented-def fulfillment_created(self, fulfillment: "Fulfillment", previous_value: Any) -> Any:diff --git a/saleor/plugins/manager.py b/saleor/plugins/manager.pyindex e1aa6af1af..bed03ae62c 100644--- a/saleor/plugins/manager.py+++ b/saleor/plugins/manager.py@@ -455,12 +455,6 @@ class PluginsManager(PaymentInterface):"order_line_deleted", default_value, order, order_line)- def order_line_updated(self, order: "Order", order_line: "OrderLine"):- default_value = None- return self.__run_method_on_plugins(- "order_line_updated", default_value, order, order_line- )-def fulfillment_created(self, fulfillment: "Fulfillment"):default_value = Nonereturn self.__run_method_on_plugins(