Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Handle sending email
Adam Janik3a766456e0e1
diff --git a/saleor/graphql/order/mutations/fulfillments.py b/saleor/graphql/order/mutations/fulfillments.pyindex 923a630ee5..ee2f76aea4 100644--- a/saleor/graphql/order/mutations/fulfillments.py+++ b/saleor/graphql/order/mutations/fulfillments.py@@ -2,12 +2,13 @@ import graphenefrom django.utils.translation import npgettext_lazy, pgettext_lazyfrom graphql_jwt.decorators import permission_required-from saleor.graphql.core.mutations import BaseMutation, ModelMutation-from saleor.graphql.core.types import Error-from saleor.graphql.order.types import Fulfillment-from saleor.graphql.utils import get_node, get_nodes-from saleor.order import models-from saleor.order.utils import cancel_fulfillment, update_order_status+from ....graphql.core.mutations import BaseMutation, ModelMutation+from ....graphql.core.types import Error+from ....graphql.order.types import Fulfillment+from ....graphql.utils import get_node, get_nodes+from ....order import models+from ....order.emails import send_fulfillment_confirmation+from ....order.utils import cancel_fulfillment, update_order_statusfrom ....dashboard.order.utils import fulfill_order_linefrom ..types import OrderLine@@ -95,8 +96,9 @@ class FulfillmentCreate(ModelMutation):def save(cls, info, instance, cleaned_input):order_lines = cleaned_input.get('order_lines')quantities = cleaned_input.get('quantities')+ super().save(info, instance, cleaned_input)+ order = instance.orderif order_lines and quantities:- super().save(info, instance, cleaned_input)quantity_fulfilled = 0lines_to_fulfill = [(order_line, quantity) for order_line, quantity@@ -112,7 +114,6 @@ class FulfillmentCreate(ModelMutation):fulfillment=instance,quantity=line[1]) for line in lines_to_fulfill]models.FulfillmentLine.objects.bulk_create(fulfillment_lines)- order = instance.orderupdate_order_status(order)msg = npgettext_lazy('Dashboard message related to an order',@@ -123,6 +124,14 @@ class FulfillmentCreate(ModelMutation):order.history.create(content=msg, user=info.context.user)super().save(info, instance, cleaned_input)+ if cleaned_input.get('notify_customer'):+ send_fulfillment_confirmation.delay(order.pk, instance.pk)+ send_mail_msg = pgettext_lazy(+ 'Dashboard message related to an order',+ 'Shipping confirmation email was sent to user'+ '(%(email)s)') % {'email': order.get_user_current_email()}+ order.history.create(content=send_mail_msg, user=info.context.user)+class FulfillmentUpdate(FulfillmentCreate):class Arguments: