Closed saravanansp96 closed 4 years ago
It should be possible to implement in on the side of the client application, without server side mutation. Currently the idea is that operation of moving items between cart, wishlist, requisition list and gift registry will be implemented on the client via reading existing items from the source and adding them to the destination.
It should be possible to implement in on the side of the client application, without server side mutation. Currently the idea is that operation of moving items between cart, wishlist, requisition list and gift registry will be implemented on the client via reading existing items from the source and adding them to the destination.
@paliarush I agree. It can be easily done on the client-side.
@nrkapoor could you please confirm on which approach should we follow, the one mentioned by @DrewML or @paliarush? Thanks
we have an option to replace or merge the requisition list items with the existing cart items
Can you explain this a bit more? Is this an option a user is presented with in the UI? Screenshots would be super helpful.
I'm working with this screenshot atm:
@DrewML @paliarush @nrkapoor
Steps to get the modal with the merge or replace option.
Please check the screenshot
Thanks
It should be possible to implement in on the side of the client application, without server side mutation. Currently the idea is that operation of moving items between cart, wishlist, requisition list and gift registry will be implemented on the client via reading existing items from the source and adding them to the destination.
@paliarush @nrkapoor Although this is possible, I'm not sure it's the best option to put this work on the client, at least without some improvements.
Example Imagine I'm a buyer, and I have 3 items I want to quickly order from a requisition list. I already have a few items in my cart, but I'd like to just get rid of those and do my requisition list order.
The UI has to do the following:
Query.cart
or Query.customerCart
to get a list of all items in the cart. This list will likely be paged per #389 because the cart listing could be large for B2B usersMutation.removeItemFromCart
to remove a single item from the cart. To remove every item in the cart, the developer needs to dynamically generate the mutation (can't just write it out). For 20 items, that will be 20 mutations.
Mutation.addRequisitionListItemToCart
to add the new items to the cartThis is 2 or 3 requests to perform what is really a single logical action for the storefront, and requires the UI now handle new error states.
Proposed Options (We can pick 1 or multiple)
clearCustomerCart
and addRequisitionListItemToCart
in a single requestremoveItemsFromCart
that allows removing multiple items with a single mutationMutation.replaceCartWithRequisitionListItems
@nrkapoor Alex is out this week, but let me know your thoughts.
It should be possible to implement in on the side of the client application, without server side mutation. Currently the idea is that operation of moving items between cart, wishlist, requisition list and gift registry will be implemented on the client via reading existing items from the source and adding them to the destination.
@paliarush @nrkapoor Although this is possible, I'm not sure it's the best option to put this work on the client, at least without some improvements.
Example Imagine I'm a buyer, and I have 3 items I want to quickly order from a requisition list. I already have a few items in my cart, but I'd like to just get rid of those and do my requisition list order.
The UI has to do the following:
- Use
Query.cart
orQuery.customerCart
to get a list of all items in the cart. This list will likely be paged per #389 because the cart listing could be large for B2B usersUse
Mutation.removeItemFromCart
to remove a single item from the cart. To remove every item in the cart, the developer needs to dynamically generate the mutation (can't just write it out). For 20 items, that will be 20 mutations.
- If any of those 20 mutations fail, the UI is now in a state where it needs to handle letting the user know that they've lost some items in their cart, but still have others, and the UI still has to decide whether to add the requisition list items to the cart or not
- Use
Mutation.addRequisitionListItemToCart
to add the new items to the cartThis is 2 or 3 requests to perform what is really a single logical action for the storefront, and requires the UI now handle new error states.
Proposed Options (We can pick 1 or multiple)
- Add a new mutation to clear/empty the cart. Then a client can send something like
clearCustomerCart
andaddRequisitionListItemToCart
in a single request- Add a new mutation like
removeItemsFromCart
that allows removing multiple items with a single mutation- Add a new mutation that can clear the cart and populate with requisition list items in a single operation. Something like
Mutation.replaceCartWithRequisitionListItems
@nrkapoor Alex is out this week, but let me know your thoughts.
@DrewML I like option 1.
@nrkapoor sounds good to me.
@saravanansp96 let's go with this one:
Add a new mutation to clear/empty the cart. Then a client can send something like clearCustomerCart and addRequisitionListItemToCart in a single request
Does that sound good to you? Then a client can do:
mutation EmptyCartAndAddRequisitionItems {
clearCustomerCart
addRequisitionListItemsToCart(...args) {
# fields
}
}
@nrkapoor sounds good to me.
@saravanansp96 let's go with this one:
Add a new mutation to clear/empty the cart. Then a client can send something like clearCustomerCart and addRequisitionListItemToCart in a single request
Does that sound good to you? Then a client can do:
mutation EmptyCartAndAddRequisitionItems { clearCustomerCart addRequisitionListItemsToCart(...args) { # fields } }
@DrewML yes. this looks good.
@DrewML @nrkapoor @paliarush Yes, it looks good, will update the Pull Request.
Thanks
@DrewML @nrkapoor I have updated the PR. Could you please review the changes.
Thanks
@nrkapoor @DrewML @paliarush I have updated the PR. Could you please review the changes.
Thanks
@nrkapoor @paliarush @DrewML I have changed the arguments to the camel case. Thanks
Problem
Whenever we add requisition list items to cart if the cart has items we have an option to replace or merge the requisition list items with the existing cart items. We don't have the option in the addRequisitionListItemToCart mutation.
Solution
Added a seperate parameter ( is_replace ) to the addRequisitionListItemToCart mutation.
Requested Reviewers
@nrkapoor @paliarush