1) Visitor (either anonymous or logged in) comes to site
4) Landing page front-end listens for event and calls the REST api for add to cart
5) Visitor goes to cart page and sees product added.
Step 1 and 5 is standard Magento
Steps 2 and 3 - I know how to do and have it working
Step 4 is causing the trouble.
How do I know the customer id or cart if of the current visitor via the front-end?
Can the REST api be called so that /carts/mine will reference the current visitor's cart (either anonymous or logged in)? I would assume the phpsessionid would do that or some other cookie that is set on the browser.
I am trying to do something very similar and am having problems as well. It seems like this should be fairly straight forward but I just can't get it.
I'm looking at the API call...
quoteGuestCartManagementV1 : Cart Management interface for guest carts
Surely I'm missing something completely obvious. Did you have any luck @jschneller?
Here is what I did although not sure if it is the "right" way of doing it.
This works except that the REST call does not fire the added to cart event so the cart item count on the page (upper right corner in the default template) is not refreshed. Since the REST call doesn't fire the event then my observer to set the price of the item added is never called.
Things I don't like:
events are not fired. I need this to happen for my use case
I thing we have the same problem to solve
I want a connect a shirtconfigurator other platform than Magento 2 (it is .Net) iframed
from there I want to add to cart to MAGENTO 2
I do not know how add to cart in MAGENTO 2
Do you have found solution ? I am intresterd thanks
I join the party. I also want to add products to the cart of the current visitor. The item to add is customized in a configurator, this conifugrator will be displayed in the Magento store via iframe.
I also listen for a "Add to cart" event and then try to add the product to the cart.
The only thing I've achieved so far: getting the quote id, create a new anonymous cart, add the product to the anonymous cart.
I finally found a solution which works for me.