cancel
Showing results for 
Search instead for 
Did you mean: 

Express Checkout cutomization

0 Kudos

Hi Experts,

Suppose an user has 2 items in his cart. He goes to another item detail page and clicks buy now. Now, by default all the two products also adds up and goes for checkout. My requirement is that when the users clicks buy now, then only that product should proceed and not merged with the other two items in the cart. If the user does not complete the order placement procedure, then it should be added in the cart with the other 2 items. But if he completes the order placement procedure, the the other 2 items should stay in the cart.

This is what Flipkart does. Any suggestions in how to achieve this?

Accepted Solutions (1)

Accepted Solutions (1)

samuelyang
Product and Topic Expert
Product and Topic Expert

Hi Archit,

Good to know you're already using Spartacus:)

Yes, a customer can have multiple saved carts on the storefront, but only one cart will be active or current. The Saved carts button allows you to see all the carts saved by the customer, and the Save cart for later button allows you to move everything from the current/active cart to a new saved cart.

So when a customer clicks on the buy now button on the product detail page, it will send a Get call to the carts endpoint: /occ/v2/electronics-spa/users/current/carts?fields=carts() to check the customer's existing carts. If the customer already has a cart, the product item will be appended to the customer's current cart entries. Otherwise it will create a new cart by sending a Post call to the /occ/v2/electronics-spa/users/current/carts endpoint. You can send a Patch call to the /occ/v2/electronics-spa/users/current/carts/<my_current_cart_id>/save endpoint to move everything from the current active cart to a saved cart when the customer clicks on the buy now button on the product detail page.

If later on the customer decides not to buy the product item at the moment, you can make the saved cart active or current and restore the saved cart to the current active cart by sending Patch calls to the /occ/v2/electronics-spa/users/current/carts/<cart_id>/restoresavedcart & /occ/v2/electronics-spa/users/current/carts/<cart_id>/save endpoints.

Hope that helps.

Answers (1)

Answers (1)

samuelyang
Product and Topic Expert
Product and Topic Expert

Hi Archit,

Which storefront solution are you using? JSP one or JS one?

But this could be a feature request. As a workaround consumers can manually create a new cart on the cart page and then the active cart will be empty. Consumers can also restore a saved cart to the active cart.

On project implementation level though, you could leverage the cart API to automate the above process for the consumers.

0 Kudos

Hi samuel.yang,

Thank you for the response. I am using JS one i.e. Spartacus.

Can I have two carts for one user? If yes then do let me steps how to achieve this. And also I don't want to remove or update the current cart of the user. It is the buy now feature and want to implement it as the same which is in Amazon and Flipkart.