I’m trying to updtae cart manually. In controller file:
public function execute() { $ id = 298; $ params['id'] = 298; $ params['product'] = 6765; $ params['selected_configurable_option'] = ''; $ params['related_product'] = ''; $ params['form_key'] = 'S3Tlt9UviUqCPaIu'; $ params ['super_attribute'] = array('135' => '608'); $ params['qty'] = 3; if (!isset($ params['options'])) { $ params['options'] = []; } try { if (isset($ params['qty'])) { $ filter = new \Zend_Filter_LocalizedToNormalized( ['locale' => $ this->_objectManager->get( \Magento\Framework\Locale\ResolverInterface::class )->getLocale()] ); $ params['qty'] = $ filter->filter($ params['qty']); } $ quoteItem = $ this->cart->getQuote()->getItemById($ id); if (!$ quoteItem) { throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t find the quote item.')); } $ item = $ this->cart->updateItem($ id, new \Magento\Framework\DataObject($ params)); $ this->cart->save();}
Its not work fine.If any modification in my code.
If anyone knows please explain me.