コード例 #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);
     }
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function delete(\Magento\Quote\Api\Data\CartInterface $quote)
 {
     $quoteId = $quote->getId();
     $customerId = $quote->getCustomerId();
     $quote->delete();
     unset($this->quotesById[$quoteId]);
     unset($this->quotesByCustomerId[$customerId]);
 }
コード例 #3
0
 /**
  * Delete partial payment registry data before quote deletion.
  *
  * @param $subject
  * @param \Magento\Quote\Api\Data\CartInterface $quote
  * @return array
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function beforeDelete($subject, \Magento\Quote\Api\Data\CartInterface $quote)
 {
     $quoteId = $quote->getId();
     $this->_repoPartialQuote->deleteById($quoteId);
     return [$quote];
 }
コード例 #4
0
ファイル: QuoteAdapter.php プロジェクト: shazal/magento2
 /**
  * Returns order id
  *
  * @return int
  */
 public function getId()
 {
     return $this->quote->getId();
 }
コード例 #5
0
 /**
  * Return customer code according to the admin configured format
  *
  * @param \Magento\Quote\Api\Data\CartInterface|\Magento\Sales\Api\Data\OrderInterface $data
  * @return string
  */
 protected function getCustomerCode($data)
 {
     switch ($this->config->getCustomerCodeFormat($data->getStoreId())) {
         case Config::CUSTOMER_FORMAT_OPTION_EMAIL:
             $email = $data->getCustomerEmail();
             return $email ?: Config::CUSTOMER_MISSING_EMAIL;
             break;
         case Config::CUSTOMER_FORMAT_OPTION_NAME_ID:
             $customer = $this->getCustomerById($data->getCustomerId());
             if ($customer && $customer->getId()) {
                 $name = $customer->getFirstname() . ' ' . $customer->getLastname();
                 $id = $customer->getId();
             } else {
                 if (!$data->getIsVirtual()) {
                     $address = $data->getShippingAddress();
                 } else {
                     $address = $data->getBillingAddress();
                 }
                 $name = $address->getFirstname() . ' ' . $address->getLastname();
                 if (!trim($name)) {
                     $name = Config::CUSTOMER_MISSING_NAME;
                 }
                 $id = Config::CUSTOMER_GUEST_ID;
             }
             return sprintf(Config::CUSTOMER_FORMAT_NAME_ID, $name, $id);
             break;
         case Config::CUSTOMER_FORMAT_OPTION_ID:
         default:
             return $data->getCustomerId() ?: strtolower(Config::CUSTOMER_GUEST_ID) . '-' . $data->getId();
             break;
     }
 }