Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@aldeed
Copy link
Contributor

@aldeed aldeed commented Feb 26, 2019

Resolves #2382
Impact: minor
Type: feature

Changes

A new cancelOrderItem mutation allows you to cancel a single order item or a partial quantity of a single order item.

The operator UI does not yet use this. That will be done in a separate PR, at which time the cancelOrder Meteor method will also be removed.

  • cancelOrderItem can be called internally to synchronize from an external system by setting context.isInternalCall to true
  • cancelOrderItem can be called through GraphQL by any user with "orders" permission for the shop that owns the order
  • cancelOrderItem can be called through GraphQL by the user who placed the order. In this case, the cancellation will only succeed if both the item status and the order status are "new".
  • Unlike with the existing Meteor method, neither restocking nor refunds are handled by this mutation. These are separate things with separate systems, so we'll now expect clients to separately ask for restocking or refunds as necessary.
  • When the last item in a group is canceled, the group is also canceled. When the last group in an order is canceled, the order is also canceled.

Breaking changes

None

Testing

  1. Place an order.
  2. Verify that the mutation works as described.
  3. Verify that you can cancel an order item when authenticated as a user with "orders" role or as the user who placed the order, but not when authenticated as someone else or when not authenticated.

@aldeed aldeed changed the title [WIP] Add cancelOrderItem mutation Add cancelOrderItem mutation Feb 26, 2019
@aldeed aldeed self-assigned this Feb 26, 2019
@aldeed aldeed added this to the 🏔 Torreys milestone Feb 26, 2019
@aldeed aldeed marked this pull request as ready for review February 26, 2019 20:46
@Akarshit
Copy link
Contributor

The mutation works and does what I had in my mind so 👍

@aldeed aldeed requested a review from kieckhafer February 27, 2019 16:56
Copy link
Member

@kieckhafer kieckhafer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall works as stated, one remaining question / comment but then should be good to go

@aldeed aldeed requested a review from kieckhafer March 5, 2019 23:17
};

// Update the subtotal since it is related to the quantity
updatedItem.subtotal = item.price.amount * cancelQuantity;
Copy link
Member

@kieckhafer kieckhafer Mar 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't tested this in action yet, but based on fixing a similar issue when adding items to a cart, I believe that subtotal is an object with amount and currencyCode on it, not just a number.

Will confirm / disprove when testing.

Nevermind... OrderItem !== CartItem

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this confused me at first, too. Love these little quirks!

@aldeed aldeed requested a review from kieckhafer March 6, 2019 15:39
@kieckhafer kieckhafer merged commit 3a84e60 into develop Mar 6, 2019
@kieckhafer kieckhafer deleted the feat-aldeed-cancel-order-items branch March 6, 2019 22:26
@kieckhafer
Copy link
Member

Updates resolve existing issues, and can confirm that subtotals and itemIds are updated properly when cancelling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants