I want add to cart programmatically and it is working fine. But when Magento Full page Cache is enabled, then it is not working. Here is my Code.
<?php $id = 6377; $qty = 1; $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $product = $objectManager->create('Magento\Catalog\Model\Product')->load($id); $listBlock = $objectManager->get('\Magento\Catalog\Block\Product\ListProduct'); $cart = $objectManager->create('Magento\Checkout\Model\Cart'); $http = $objectManager->create('Magento\Framework\App\Response\Http'); $session = $objectManager->get('Magento\Checkout\Model\Session'); $cart->addProduct($product,array('qty' => $qty)); $cart->save(); $session->setCartWasUpdated(true); $http->setRedirect('checkout/cart/index')->sendResponse(); exit; ?>
hi
for version 2.1.16 in mode developer is OK
best regards
I have same problem