/** * @param ShippingInterface $shipping * @param CartInterface $quote * @return void */ public function save(ShippingInterface $shipping, CartInterface $quote) { $this->shippingAddressManagement->assign($quote->getId(), $shipping->getAddress()); if (!empty($shipping->getMethod()) && $quote->getItemsCount() > 0) { $nameComponents = explode('_', $shipping->getMethod()); $carrierCode = array_shift($nameComponents); // carrier method code can contains more one name component $methodCode = implode('_', $nameComponents); $this->shippingMethodManagement->apply($quote->getId(), $carrierCode, $methodCode); } }
/** * @param CartInterface $quote * @return void * @throws \InvalidArgumentException */ protected function validateQuote($quote) { if (!$quote || !$quote->getItemsCount()) { throw new \InvalidArgumentException(__('We can\'t initialize checkout.')); } }