/** * {@inheritdoc} */ public function load(CustomerInterface $customer) { $basket = $this->getFromSession($customer); if (!$basket) { $basket = $this->basketManager->create(); $basket->setLocale($customer->getLocale()); $basket->setCurrency($this->currencyDetector->getCurrency()); } $basket->setCustomer($customer); $this->basketBuilder->build($basket); return $basket; }
/** * {@inheritdoc} */ public function load(CustomerInterface $customer) { $basket = $this->session->get($this->getSessionVarName($customer)); if (!$basket) { $basket = $this->session->get($this->getSessionVarName()); if (!$basket) { $basket = $this->basketManager->create(); $basket->setLocale($customer->getLocale()); $basket->setCurrency($this->currencyDetector->getCurrency()); } } $basket->setCustomer($customer); $this->basketBuilder->build($basket); // always clone the basket so it can be only saved by calling // the save method return clone $basket; }