Suppose a 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 add up and go for checkout. My requirement is that when the user clicks buy now, then only that product should proceed and not merge with the other two items in the cart. If the user does not complete the order placement procedure, then it should be added to the cart with the other 2 items. But if he completes the order placement procedure, the other 2 items should stay in the cart.
This is what Flipkart does. Any suggestions in how to achieve this?
Usually, such tasks require a big amount of analytics to find all cases. But a simple plan is:
de.hybris.platform.commerceservices.order.impl.DefaultCommerceCartService#addToCart
buyNow
to the CartModelcart.buyNow = true
buyNow
flag. And run a cart restoration process that will return his original cart.