I have created a custom add to cart section where a customer can customize their chosen configurable product for multi-options. It is a functionality where I will have to programmatically add to cart multiple configurable products based on the customers selection. It is working perfectly for logged in customers, but I am getting no clue how this might work for guest users.
I used
MagentoQuoteApiGuestCartManagementInterface::createEmptyCart()
to create a cart for customer, add adding item using
MagentoQuoteApiGuestCartItemRepositoryInterface::save($cartItem)
The items are added properly, which I can see in quote tables in database, but in frontend the cart stays empty.
So Magento is maintaining a different guest session for frontend users, and the Repository add to cart calls apparently does not recognize that session, or using a different one, even if the calls are made from frontend itself, not any third party application like Postman.
Magento’s default add to cart controller adds item to cart for both guest and logged in customer without any additional parameters.
I am not getting how Magento is maintaining a guest customer’s session. If it is possible to reflect the added items in cart for frontend customer.