![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-checkout/Controller/Cart/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Checkout\Controller\Cart; use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface; /** * Action Delete. * * Deletes item from cart. */ class Delete extends \Magento\Checkout\Controller\Cart implements HttpPostActionInterface { /** * Delete shopping cart item action * * @return \Magento\Framework\Controller\Result\Redirect */ public function execute() { if (!$this->_formKeyValidator->validate($this->getRequest())) { return $this->resultRedirectFactory->create()->setPath('*/*/'); } $id = (int)$this->getRequest()->getParam('id'); if ($id) { try { $this->cart->removeItem($id); // We should set Totals to be recollected once more because of Cart model as usually is loading // before action executing and in case when triggerRecollect setted as true recollecting will // executed and the flag will be true already. $this->cart->getQuote()->setTotalsCollectedFlag(false); $this->cart->save(); } catch (\Exception $e) { $this->messageManager->addErrorMessage(__('We can\'t remove the item.')); $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); } } $defaultUrl = $this->_objectManager->create(\Magento\Framework\UrlInterface::class)->getUrl('*/*'); return $this->resultRedirectFactory->create()->setUrl($this->_redirect->getRedirectUrl($defaultUrl)); } }