Ejemplo n.º 1
0
 /**
  * @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);
     }
 }
Ejemplo n.º 2
0
 /**
  * @param CartInterface $quote
  * @return void
  * @throws \InvalidArgumentException
  */
 protected function validateQuote($quote)
 {
     if (!$quote || !$quote->getItemsCount()) {
         throw new \InvalidArgumentException(__('We can\'t initialize checkout.'));
     }
 }