protected function setCustomData() { // If there is a customer, insert its basket into the response data. $currentCustomer = Customers::getCurrent(); if ($currentCustomer instanceof Customer) { $this->setData('basket', $this->getBasketContents($currentCustomer)); } }
/** * Empties the basket. */ private function getBasketClearedResponse() { $response = NULL; try { // Remove all products from the current customer's basket. Customers::getCurrent()->getBasket()->clear(); $response = new RedirectionResponse($this->getRequest()); $response->setNextUrl('/cistella'); } catch (\Exception $exception) { $response = $this->getViewPageResponse(); $customerId = Customers::getCurrent()->getId(); Logger::get()->error("Failed to clear customer {$customerId}'s basket."); $response->addErrorMessage(_('The basket could not be cleared.')); } return $response; }