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


PHP Quote::getBillingAddress方法代码示例

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


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

示例1: getProductTaxRate

 private function getProductTaxRate()
 {
     /** @var $taxCalculator \Magento\Tax\Model\Calculation */
     $taxCalculator = $this->calculation;
     $request = $taxCalculator->getRateRequest($this->quote->getShippingAddress(), $this->quote->getBillingAddress(), $this->quote->getCustomerTaxClassId(), $this->quote->getStore());
     $request->setProductClassId($this->getProduct()->getTaxClassId());
     return $taxCalculator->getRate($request);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:8,代码来源:Item.php

示例2: 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

示例3: testSameAsBillingForBillingAddress

 /**
  * same_as_billing must be equal 0 if billing address is being saved
  *
  * @param bool $unsetId
  * @dataProvider unsetAddressIdDataProvider
  */
 public function testSameAsBillingForBillingAddress($unsetId)
 {
     $this->_quote->setCustomer($this->_customer);
     $address = $this->_quote->getBillingAddress();
     if ($unsetId) {
         $address->setId(null);
     }
     /** @var \Magento\Customer\Api\AddressRepositoryInterface $addressRepository */
     $addressRepository = Bootstrap::getObjectManager()->create('Magento\\Customer\\Api\\AddressRepositoryInterface');
     $customerAddressData = $addressRepository->getById($this->_customer->getDefaultBilling());
     $address->setSameAsBilling(0)->setCustomerAddressData($customerAddressData)->save();
     $this->assertEquals(0, $this->_quote->getBillingAddress()->getSameAsBilling());
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:19,代码来源:AddressTest.php

示例4: populateQuoteAddress

 /**
  * @param \Magento\Quote\Model\Quote $quote
  * @param array $details
  * @return $this
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function populateQuoteAddress($quote, $details)
 {
     // import shipping address
     $exportedShippingAddress = isset($details['shippingAddress']) ? $details['shippingAddress'] : null;
     if (!$quote->getIsVirtual()) {
         $shippingAddress = $quote->getShippingAddress();
         if ($exportedShippingAddress) {
             $this->importAddressData($shippingAddress, $exportedShippingAddress);
         }
         // PayPal doesn't provide detailed shipping info: prefix, suffix
         $shippingAddress->setLastname($details['lastName']);
         $shippingAddress->setFirstname($details['firstName']);
         $shippingAddress->setEmail($details['email']);
         $shippingAddress->setCollectShippingRates(true);
     }
     $exportedBillingAddress = isset($details['billingAddress']) ? $details['billingAddress'] : null;
     $billingAddress = $quote->getBillingAddress();
     if ($exportedBillingAddress) {
         $this->importBillingAddressData($billingAddress, $exportedBillingAddress);
         $billingAddress->setFirstname($details['firstName']);
         $billingAddress->setLastname($details['lastName']);
         $billingAddress->setEmail($details['email']);
     } elseif ($billingAddress->getEmail() == null) {
         $this->importAddressData($billingAddress, $exportedShippingAddress);
         $billingAddress->setFirstname($details['firstName']);
         $billingAddress->setLastname($details['lastName']);
         $billingAddress->setEmail($details['email']);
     }
     return $this;
 }
开发者ID:nja78,项目名称:magento2,代码行数:36,代码来源:Checkout.php

示例5: populateCustomerInfo

 /**
  * Populate customer model
  *
  * @param Quote $quote
  * @return void
  */
 public function populateCustomerInfo(QuoteEntity $quote)
 {
     $customer = $quote->getCustomer();
     if (!$customer->getId()) {
         $customer = $this->accountManagement->createAccountWithPasswordHash($customer, $quote->getPasswordHash());
         $quote->setCustomer($customer);
     } else {
         $this->customerRepository->save($customer);
     }
     if (!$quote->getBillingAddress()->getId() && $customer->getDefaultBilling()) {
         $quote->getBillingAddress()->importCustomerAddressData($this->customerAddressRepository->getById($customer->getDefaultBilling()));
         $quote->getBillingAddress()->setCustomerAddressId($customer->getDefaultBilling());
     }
     if (!$quote->getShippingAddress()->getSameAsBilling() && !$quote->getBillingAddress()->getId() && $customer->getDefaultShipping()) {
         $quote->getShippingAddress()->importCustomerAddressData($this->customerAddressRepository->getById($customer->getDefaultShipping()));
         $quote->getShippingAddress()->setCustomerAddressId($customer->getDefaultShipping());
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:24,代码来源:CustomerManagement.php

示例6: ignoreAddressValidation

 /**
  * Make sure addresses will be saved without validation errors
  *
  * @return void
  */
 private function ignoreAddressValidation()
 {
     $this->_quote->getBillingAddress()->setShouldIgnoreValidation(true);
     if (!$this->_quote->getIsVirtual()) {
         $this->_quote->getShippingAddress()->setShouldIgnoreValidation(true);
         if (!$this->_config->getValue('requireBillingAddress') && !$this->_quote->getBillingAddress()->getEmail()) {
             $this->_quote->getBillingAddress()->setSameAsBilling(1);
         }
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:Checkout.php

示例7: 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

示例8: disabledQuoteAddressValidation

 /**
  * Make sure addresses will be saved without validation errors
  *
  * @param Quote $quote
  * @return void
  */
 protected function disabledQuoteAddressValidation(Quote $quote)
 {
     $billingAddress = $quote->getBillingAddress();
     $billingAddress->setShouldIgnoreValidation(true);
     if (!$quote->getIsVirtual()) {
         $shippingAddress = $quote->getShippingAddress();
         $shippingAddress->setShouldIgnoreValidation(true);
         if (!$billingAddress->getEmail()) {
             $billingAddress->setSameAsBilling(1);
         }
     }
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:18,代码来源:AbstractHelper.php

示例9: initializeAddresses

 private function initializeAddresses()
 {
     $billingAddress = $this->quote->getBillingAddress();
     $billingAddress->addData($this->proxyOrder->getBillingAddressData());
     $billingAddress->setStreet($billingAddress->getStreet());
     $billingAddress->setLimitCarrier('m2eproshipping');
     $billingAddress->setShippingMethod('m2eproshipping_m2eproshipping');
     $billingAddress->setCollectShippingRates(true);
     $billingAddress->setShouldIgnoreValidation($this->proxyOrder->shouldIgnoreBillingAddressValidation());
     // ---------------------------------------
     $shippingAddress = $this->quote->getShippingAddress();
     $shippingAddress->setSameAsBilling(0);
     // maybe just set same as billing?
     $shippingAddress->addData($this->proxyOrder->getAddressData());
     $shippingAddress->setStreet($shippingAddress->getStreet());
     $shippingAddress->setLimitCarrier('m2eproshipping');
     $shippingAddress->setShippingMethod('m2eproshipping_m2eproshipping');
     $shippingAddress->setCollectShippingRates(true);
     // ---------------------------------------
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:20,代码来源:Quote.php

示例10: getTaxContainer

 /**
  * {@inheritdoc}
  */
 public function getTaxContainer()
 {
     return $this->_salesModel->getIsVirtual() ? $this->_salesModel->getBillingAddress() : $this->_salesModel->getShippingAddress();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:7,代码来源:Quote.php

示例11: getBillingAddress

 /**
  * Return quote billing address
  *
  * @return \Magento\Quote\Model\Quote\Address
  */
 public function getBillingAddress()
 {
     return $this->_quote->getBillingAddress();
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:9,代码来源:Review.php

示例12: updateBillingAddress

 /**
  * Update billing address
  *
  * @param Quote $quote
  * @param array $details
  * @return void
  */
 private function updateBillingAddress(Quote $quote, array $details)
 {
     $billingAddress = $quote->getBillingAddress();
     if ($this->config->isRequiredBillingAddress()) {
         $this->updateAddressData($billingAddress, $details['billingAddress']);
     } else {
         $this->updateAddressData($billingAddress, $details['shippingAddress']);
     }
     $billingAddress->setFirstname($details['firstName']);
     $billingAddress->setLastname($details['lastName']);
     $billingAddress->setEmail($details['email']);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:19,代码来源:QuoteUpdater.php

示例13: _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

示例14: setMessage

 /**
  * Sets the gift message to item or quote.
  *
  * @param \Magento\Quote\Model\Quote $quote The quote.
  * @param string $type The type.
  * @param \Magento\GiftMessage\Api\Data\MessageInterface $giftMessage The gift message.
  * @param null|int $entityId The entity ID.
  * @return void
  * @throws \Magento\Framework\Exception\CouldNotSaveException The specified gift message is not available.
  * @throws \Magento\Framework\Exception\State\InvalidTransitionException The billing or shipping address is not set.
  */
 public function setMessage(\Magento\Quote\Model\Quote $quote, $type, $giftMessage, $entityId = null)
 {
     if ($quote->getBillingAddress()->getCountryId() === null) {
         throw new InvalidTransitionException(__('Billing address is not set'));
     }
     // check if shipping address is set
     if ($quote->getShippingAddress()->getCountryId() === null) {
         throw new InvalidTransitionException(__('Shipping address is not set'));
     }
     $message[$type][$entityId] = ['from' => $giftMessage->getSender(), 'to' => $giftMessage->getRecipient(), 'message' => $giftMessage->getMessage()];
     try {
         $this->add($message, $quote);
     } catch (\Exception $e) {
         throw new CouldNotSaveException(__('Could not add gift message to shopping cart'));
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:27,代码来源:GiftMessageManager.php

示例15: prepareGuestQuote

 /**
  * Prepare quote for guest checkout order submit
  *
  * @param Quote $quote
  * @return void
  */
 private function prepareGuestQuote(Quote $quote)
 {
     $quote->setCustomerId(null)->setCustomerEmail($quote->getBillingAddress()->getEmail())->setCustomerIsGuest(true)->setCustomerGroupId(Group::NOT_LOGGED_IN_ID);
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:10,代码来源:OrderPlace.php


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