We have to add product into cart using on the bases of Ajax response from another domain on requesting Magento 2 Add to cart url or function.
Request url or domain:
Response domain: "localhost/"
So here is the problem:
Product has been added to cart but while getting response customer cart session has been changed to new and new quote id is created I.e fresh cart session will be created and existing products from the cart are wipeout and new added products will be shown only. Also on every response for the request having new session for cart. On using request url on the browser its working fine and product has been added to cart as expected.
Issue is when we are using that add to cart functionality with Ajax or adding product after response from localhost domain has issue. I guess response is coming from cross domain that’s why its creating problem?
If any one faced this kind of situation and have solution for Magento 2.1.6 will be appreciated.
NOTE: This the way Iam using is working fine in Magento 1 versions but not working in Magento 2