Skip to content

Commit

Permalink
Merge pull request #3472 from mirumee/3444/Draft_order_reset_shipping…
Browse files Browse the repository at this point in the history
…_method

Draft order should be able to clear its shipping method
  • Loading branch information
maarcingebala committed Dec 17, 2018
2 parents e3fdb13 + 3cf8e01 commit 4f384f3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ All notable, unreleased changes to this project will be documented in this file.
- Use first and last name of a customer or staff member in UI - #3247 by @Bonifacy1, @dominik-zeglen
- Bump `urllib3` and `elasticsearch` to latest versions - #3460 by @maarcingebala
- Resort imports in tests - #3471 by @jxltom
- Support sorting products by update date - #3470 by @jxltom
- Support sorting products by update date - #3470 by @jxltom
- Draft order should be able to clear its shipping method - #3472 by @fowczarek
2 changes: 1 addition & 1 deletion saleor/graphql/order/mutations/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def mutate(cls, root, info, id, input):
order = cls.get_node_or_error(info, id, errors, 'id', Order)

if not input['shipping_method']:
if order.is_shipping_required():
if not order.is_draft() and order.is_shipping_required():
cls.add_error(
errors, 'shippingMethod',
'Shipping method is required for this order.')
Expand Down
17 changes: 17 additions & 0 deletions tests/api/test_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,23 @@ def test_order_update_shipping_incorrect_shipping_method(
'Shipping method cannot be used with this order.')


def test_draft_order_clear_shipping_method(
staff_api_client, draft_order, permission_manage_orders):
assert draft_order.shipping_method
query = ORDER_UPDATE_SHIPPING_QUERY
order_id = graphene.Node.to_global_id('Order', draft_order.id)
variables = {'order': order_id, 'shippingMethod': None}
response = staff_api_client.post_graphql(
query, variables, permissions=[permission_manage_orders])
content = get_graphql_content(response)
data = content['data']['orderUpdateShipping']
assert data['order']['id'] == order_id
draft_order.refresh_from_db()
assert draft_order.shipping_method is None
assert draft_order.shipping_price == ZERO_TAXED_MONEY
assert draft_order.shipping_method_name is None


def test_orders_total(
staff_api_client, permission_manage_orders, order_with_lines):
query = """
Expand Down

0 comments on commit 4f384f3

Please sign in to comment.