当前位置: 首页>>代码示例>>PHP>>正文


PHP Quote::isVirtual方法代码示例

本文整理汇总了PHP中Magento\Quote\Model\Quote::isVirtual方法的典型用法代码示例。如果您正苦于以下问题:PHP Quote::isVirtual方法的具体用法?PHP Quote::isVirtual怎么用?PHP Quote::isVirtual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Quote\Model\Quote的用法示例。


在下文中一共展示了Quote::isVirtual方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCountry

 /**
  * Get payment country
  *
  * @param Quote $quote
  * @return int
  */
 public function getCountry(Quote $quote)
 {
     $address = $quote->isVirtual() ? $quote->getBillingAddress() : $quote->getShippingAddress();
     return $address ? $address->getCountry() : $this->directoryHelper->getDefaultCountry();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:11,代码来源:CountryProvider.php

示例2: validateBeforeSubmit

 /**
  * Validate quote before submit
  *
  * @param Quote $quote
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function validateBeforeSubmit(QuoteEntity $quote)
 {
     if (!$quote->isVirtual()) {
         if ($quote->getShippingAddress()->validate() !== true) {
             throw new \Magento\Framework\Exception\LocalizedException(__('Please check the shipping address information. %1', implode(' ', $quote->getShippingAddress()->validate())));
         }
         $method = $quote->getShippingAddress()->getShippingMethod();
         $rate = $quote->getShippingAddress()->getShippingRateByCode($method);
         if (!$quote->isVirtual() && (!$method || !$rate)) {
             throw new \Magento\Framework\Exception\LocalizedException(__('Please specify a shipping method.'));
         }
     }
     if ($quote->getBillingAddress()->validate() !== true) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Please check the billing address information. %1', implode(' ', $quote->getBillingAddress()->validate())));
     }
     if (!$quote->getPayment()->getMethod()) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Please select a valid payment method.'));
     }
     return $this;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:27,代码来源:QuoteValidator.php

示例3: processShippingAssignment

 /**
  * @param \Magento\Quote\Model\Quote $quote
  * @return void
  * @throws InputException
  */
 private function processShippingAssignment($quote)
 {
     // Shipping Assignments processing
     $extensionAttributes = $quote->getExtensionAttributes();
     if (!$quote->isVirtual() && $extensionAttributes && $extensionAttributes->getShippingAssignments()) {
         $shippingAssignments = $extensionAttributes->getShippingAssignments();
         if (count($shippingAssignments) > 1) {
             throw new InputException(__("Only 1 shipping assignment can be set"));
         }
         $this->shippingAssignmentPersister->save($quote, $shippingAssignments[0]);
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:17,代码来源:SaveHandler.php

示例4: validateQuote

 /**
  * Validate quote
  *
  * @param \Magento\Quote\Model\Quote $quote
  * @throws InputException
  * @throws NoSuchEntityException
  * @return void
  */
 protected function validateQuote(\Magento\Quote\Model\Quote $quote)
 {
     if ($quote->isVirtual()) {
         throw new NoSuchEntityException(__('Cart contains virtual product(s) only. Shipping address is not applicable.'));
     }
     if (0 == $quote->getItemsCount()) {
         throw new InputException(__('Shipping method is not applicable for empty cart'));
     }
 }
开发者ID:VoblaSmile,项目名称:php56-magento2-data,代码行数:17,代码来源:ShippingInformationManagement.php

示例5: _prepareCustomerQuote

 /**
  * Prepare quote for customer order submit
  *
  * @param Quote $quote
  * @return void
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function _prepareCustomerQuote($quote)
 {
     /** @var Quote $quote */
     $billing = $quote->getBillingAddress();
     $shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
     $customer = $this->customerRepository->getById($quote->getCustomerId());
     $hasDefaultBilling = (bool) $customer->getDefaultBilling();
     $hasDefaultShipping = (bool) $customer->getDefaultShipping();
     if ($shipping && !$shipping->getSameAsBilling() && (!$shipping->getCustomerId() || $shipping->getSaveInAddressBook())) {
         $shippingAddress = $shipping->exportCustomerAddress();
         if (!$hasDefaultShipping) {
             //Make provided address as default shipping address
             $shippingAddress->setIsDefaultShipping(true);
             $hasDefaultShipping = true;
         }
         $quote->addCustomerAddress($shippingAddress);
         $shipping->setCustomerAddressData($shippingAddress);
     }
     if (!$billing->getCustomerId() || $billing->getSaveInAddressBook()) {
         $billingAddress = $billing->exportCustomerAddress();
         if (!$hasDefaultBilling) {
             //Make provided address as default shipping address
             if (!$hasDefaultShipping) {
                 //Make provided address as default shipping address
                 $billingAddress->setIsDefaultShipping(true);
             }
             $billingAddress->setIsDefaultBilling(true);
         }
         $quote->addCustomerAddress($billingAddress);
         $billing->setCustomerAddressData($billingAddress);
     }
     if ($shipping && !$shipping->getCustomerId() && !$hasDefaultBilling) {
         $shipping->setIsDefaultBilling(true);
     }
 }
开发者ID:nja78,项目名称:magento2,代码行数:43,代码来源:QuoteManagement.php

示例6: prepareRegisteredCustomerQuote

 /**
  * @param \Magento\Quote\Model\Quote $quote
  * @param int|null $customerId
  * @return \Magento\Quote\Model\Quote
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function prepareRegisteredCustomerQuote(\Magento\Quote\Model\Quote $quote, $customerId)
 {
     $billing = $quote->getBillingAddress();
     $shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
     $customer = $this->customerRepository->getById($customerId);
     $isBillingAddressDefaultBilling = !$customer->getDefaultBilling();
     $isBillingAddressDefaultShipping = false;
     $isShippingAddressDefaultShipping = false;
     if ($shipping && !$customer->getDefaultShipping()) {
         $isShippingAddressDefaultShipping = true;
     } elseif (!$customer->getDefaultShipping()) {
         $isBillingAddressDefaultShipping = true;
     }
     if ($shipping && $shipping->getTelephone() && !$shipping->getSameAsBilling() && (!$shipping->getCustomerId() || $shipping->getSaveInAddressBook() || !$customer->getDefaultShipping())) {
         $address = $shipping->exportCustomerAddress();
         $address->setIsDefaultShipping($isShippingAddressDefaultShipping);
         $quote->addCustomerAddress($address);
     }
     if ($billing && $billing->getTelephone() && (!$customer->getDefaultBilling() || $billing->getSaveInAddressBook())) {
         $address = $billing->exportCustomerAddress();
         $address->setIsDefaultBilling($isBillingAddressDefaultBilling);
         $address->setIsDefaultShipping($isBillingAddressDefaultShipping);
         $quote->addCustomerAddress($address);
     }
     return $quote;
 }
开发者ID:nja78,项目名称:magento2,代码行数:33,代码来源:Quote.php

示例7: collectQuoteTotals

 /**
  * @param \Magento\Quote\Model\Quote $quote
  * @return Address\Total
  */
 public function collectQuoteTotals(\Magento\Quote\Model\Quote $quote)
 {
     if ($quote->isVirtual()) {
         return $this->collectAddressTotals($quote, $quote->getBillingAddress());
     }
     return $this->collectAddressTotals($quote, $quote->getShippingAddress());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:TotalsCollector.php

示例8: getCountry

 /**
  * Get payment country
  *
  * @param Quote $quote
  * @return int
  */
 public function getCountry(Quote $quote)
 {
     return $quote->isVirtual() ? $this->directoryHelper->getDefaultCountry() : $quote->getShippingAddress()->getCountry();
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:10,代码来源:CountryProvider.php


注:本文中的Magento\Quote\Model\Quote::isVirtual方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。