Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fulfill digital orders from next dashboard
Maciej Korycinski64ad5651379f
diff --git a/saleor/graphql/order/mutations/fulfillments.py b/saleor/graphql/order/mutations/fulfillments.pyindex e47185211a..0377c9e6f7 100644--- a/saleor/graphql/order/mutations/fulfillments.py+++ b/saleor/graphql/order/mutations/fulfillments.py@@ -111,6 +111,8 @@ class FulfillmentCreate(BaseMutation):fulfillment_lines = []for order_line, quantity in zip(order_lines, quantities):fulfill_order_line(order_line, quantity)+ if order_line.is_digital:+ order_line.variant.digital_content.urls.create(line=order_line)fulfillment_lines.append(models.FulfillmentLine(order_line=order_line, fulfillment=fulfillment,diff --git a/saleor/order/utils.py b/saleor/order/utils.pyindex e723d224ce..2db0ce4497 100644--- a/saleor/order/utils.py+++ b/saleor/order/utils.py@@ -58,7 +58,7 @@ def fulfill_order_line(order_line, quantity):order_line.save(update_fields=['quantity_fulfilled'])-def fulfill_digital_lines(order: Order):+def automatically_fulfill_digital_lines(order: Order):"""Fulfill all digital lines which have enabled automatic fulfillmentsetting"""order = Order.objects.get(id=order.id)diff --git a/saleor/payment/utils.py b/saleor/payment/utils.pyindex e3b46fc8c4..e46d1db8ca 100644--- a/saleor/payment/utils.py+++ b/saleor/payment/utils.py@@ -79,7 +79,7 @@ def handle_fully_paid_order(order):'email_type': OrderEventsEmails.PAYMENT.value})if order_utils.order_needs_automatic_fullfilment(order):- order_utils.fulfill_digital_lines(order)+ order_utils.automatically_fulfill_digital_lines(order)# send_emailtry:analytics.report_order(order.tracking_client_id, order)diff --git a/tests/test_order.py b/tests/test_order.pyindex b761bc95ff..56f8117732 100644--- a/tests/test_order.py+++ b/tests/test_order.py@@ -17,7 +17,7 @@ from saleor.order.utils import (add_variant_to_order, cancel_fulfillment, cancel_order,change_order_line_quantity, delete_order_line, recalculate_order,fulfill_order_line, restock_fulfillment_lines, restock_order_lines,- update_order_prices, update_order_status, fulfill_digital_lines)+ update_order_prices, update_order_status, automatically_fulfill_digital_lines)from saleor.payment import ChargeStatusfrom saleor.payment.models import Paymentfrom saleor.product.models import DigitalContent@@ -596,7 +596,7 @@ def test_fulfill_digital_lines(mock_digital_settings, order_with_lines):line.save()order_with_lines.refresh_from_db()- fulfill_digital_lines(order_with_lines)+ automatically_fulfill_digital_lines(order_with_lines)line.refresh_from_db()fulfillment = Fulfillment.objects.get(order=order_with_lines)fulfillment_lines = fulfillment.lines.all()