/** * Adds item ID to giftOptionsCartItem configuration and name * * @param array $jsLayout * @param AbstractItem $item * @return array */ public function process($jsLayout, AbstractItem $item) { if (isset($jsLayout['components']['giftOptionsCartItem'])) { if (!isset($jsLayout['components']['giftOptionsCartItem']['config'])) { $jsLayout['components']['giftOptionsCartItem']['config'] = []; } $jsLayout['components']['giftOptionsCartItem']['config']['itemId'] = $item->getId(); $jsLayout['components']['giftOptionsCartItem-' . $item->getId()] = $jsLayout['components']['giftOptionsCartItem']; unset($jsLayout['components']['giftOptionsCartItem']); } return $jsLayout; }
/** * Get post parameters for delete from cart * * @param \Magento\Quote\Model\Quote\Item\AbstractItem $item * @return string */ public function getDeletePostJson($item) { $url = $this->_getUrl(self::DELETE_URL); $data = ['id' => $item->getId()]; if (!$this->_request->isAjax()) { $data[\Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED] = $this->getCurrentBase64Url(); } return json_encode(['action' => $url, 'data' => $data]); }