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


PHP Address::getTaxCalculationAddressType方法代码示例

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


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

示例1: execute

 /**
  * Restore initial customer group ID in quote if needed on collect_totals_after event of quote address
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute($observer)
 {
     $quoteAddress = $observer->getQuoteAddress();
     $configAddressType = $this->customerAddressHelper->getTaxCalculationAddressType();
     // Restore initial customer group ID in quote only if VAT is calculated based on shipping address
     if ($quoteAddress->hasPrevQuoteCustomerGroupId() && $configAddressType == \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING) {
         $quoteAddress->getQuote()->setCustomerGroupId($quoteAddress->getPrevQuoteCustomerGroupId());
         $quoteAddress->unsPrevQuoteCustomerGroupId();
     }
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:16,代码来源:RestoreCustomerGroupId.php

示例2: isEnabled

 /**
  * Check whether VAT ID validation is enabled
  *
  * @param \Magento\Quote\Model\Quote\Address $quoteAddress
  * @param \Magento\Store\Model\Store|int $store
  * @return bool
  */
 public function isEnabled(\Magento\Quote\Model\Quote\Address $quoteAddress, $store)
 {
     $configAddressType = $this->customerAddress->getTaxCalculationAddressType($store);
     // When VAT is based on billing address then Magento have to handle only billing addresses
     $additionalBillingAddressCondition = $configAddressType == \Magento\Customer\Model\Address\AbstractAddress::TYPE_BILLING ? $configAddressType != $quoteAddress->getAddressType() : false;
     // Handle only addresses that corresponds to VAT configuration
     if (!$this->customerAddress->isVatValidationEnabled($store) || $additionalBillingAddressCondition) {
         return false;
     }
     return true;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:18,代码来源:VatValidator.php

示例3: _getVatRequiredSalesAddress

 /**
  * Retrieve sales address (order or quote) on which tax calculation must be based
  *
  * @param \Magento\Sales\Model\Order $order
  * @param \Magento\Store\Model\Store|string|int|null $store
  * @return \Magento\Sales\Model\Order\Address|null
  */
 protected function _getVatRequiredSalesAddress($order, $store = null)
 {
     $configAddressType = $this->customerAddressHelper->getTaxCalculationAddressType($store);
     $requiredAddress = null;
     switch ($configAddressType) {
         case \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING:
             $requiredAddress = $order->getShippingAddress();
             break;
         default:
             $requiredAddress = $order->getBillingAddress();
             break;
     }
     return $requiredAddress;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:21,代码来源:AddVatRequestParamsOrderComment.php

示例4: execute

 /**
  * Restore initial customer group ID in quote if needed on collect_totals_after event of quote address
  *
  * @param Observer $observer
  * @return void
  */
 public function execute(Observer $observer)
 {
     /** @var ShippingAssignmentInterface $shippingAssignment */
     $shippingAssignment = $observer->getEvent()->getShippingAssignment();
     /** @var Quote $quote */
     $quote = $observer->getEvent()->getQuote();
     $address = $shippingAssignment->getShipping()->getAddress();
     $configAddressType = $this->customerAddressHelper->getTaxCalculationAddressType();
     // Restore initial customer group ID in quote only if VAT is calculated based on shipping address
     if ($address->hasPrevQuoteCustomerGroupId() && $configAddressType == AbstractAddress::TYPE_SHIPPING) {
         $quote->setCustomerGroupId($address->getPrevQuoteCustomerGroupId());
         $address->unsPrevQuoteCustomerGroupId();
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:20,代码来源:RestoreCustomerGroupId.php

示例5: execute

 /**
  * Address before save event handler
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if ($this->_coreRegistry->registry(self::VIV_CURRENTLY_SAVED_ADDRESS)) {
         $this->_coreRegistry->unregister(self::VIV_CURRENTLY_SAVED_ADDRESS);
     }
     /** @var $customerAddress Address */
     $customerAddress = $observer->getCustomerAddress();
     if ($customerAddress->getId()) {
         $this->_coreRegistry->register(self::VIV_CURRENTLY_SAVED_ADDRESS, $customerAddress->getId());
     } else {
         $configAddressType = $this->_customerAddress->getTaxCalculationAddressType();
         $forceProcess = $configAddressType == AbstractAddress::TYPE_SHIPPING ? $customerAddress->getIsDefaultShipping() : $customerAddress->getIsDefaultBilling();
         if ($forceProcess) {
             $customerAddress->setForceProcess(true);
         } else {
             $this->_coreRegistry->register(self::VIV_CURRENTLY_SAVED_ADDRESS, 'new_address');
         }
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:25,代码来源:BeforeAddressSaveObserver.php

示例6: _canProcessAddress

 /**
  * Check whether specified address should be processed in after_save event handler
  *
  * @param Address $address
  * @return bool
  */
 protected function _canProcessAddress($address)
 {
     if ($address->getForceProcess()) {
         return true;
     }
     if ($this->_coreRegistry->registry(BeforeAddressSaveObserver::VIV_CURRENTLY_SAVED_ADDRESS) != $address->getId()) {
         return false;
     }
     $configAddressType = $this->_customerAddress->getTaxCalculationAddressType();
     if ($configAddressType == AbstractAddress::TYPE_SHIPPING) {
         return $this->_isDefaultShipping($address);
     }
     return $this->_isDefaultBilling($address);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:20,代码来源:AfterAddressSaveObserver.php

示例7: getSuccessMessage

 /**
  * Retrieve success message
  *
  * @return string
  */
 protected function getSuccessMessage()
 {
     if ($this->addressHelper->isVatValidationEnabled()) {
         if ($this->addressHelper->getTaxCalculationAddressType() == Address::TYPE_SHIPPING) {
             // @codingStandardsIgnoreStart
             $message = __('If you are a registered VAT customer, please <a href="%1">click here</a> to enter your shipping address for proper VAT calculation.', $this->urlModel->getUrl('customer/address/edit'));
             // @codingStandardsIgnoreEnd
         } else {
             // @codingStandardsIgnoreStart
             $message = __('If you are a registered VAT customer, please <a href="%1">click here</a> to enter your billing address for proper VAT calculation.', $this->urlModel->getUrl('customer/address/edit'));
             // @codingStandardsIgnoreEnd
         }
     } else {
         $message = __('Thank you for registering with %1.', $this->storeManager->getStore()->getFrontendName());
     }
     return $message;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:22,代码来源:CreatePost.php

示例8: _addWelcomeMessage

 /**
  * Adds a welcome message to the session
  *
  * @return void
  */
 protected function _addWelcomeMessage()
 {
     $this->messageManager->addSuccess(__('Thank you for registering with %1.', $this->_storeManager->getStore()->getFrontendName()));
     if ($this->_isVatValidationEnabled()) {
         // Show corresponding VAT message to customer
         $configAddressType = $this->_addressHelper->getTaxCalculationAddressType();
         $editAddersUrl = $this->_createUrl()->getUrl('customer/address/edit');
         switch ($configAddressType) {
             case \Magento\Customer\Helper\Address::TYPE_SHIPPING:
                 // @codingStandardsIgnoreStart
                 $userPrompt = __('If you are a registered VAT customer, please click <a href="%1">here</a> to enter you shipping address for proper VAT calculation', $editAddersUrl);
                 // @codingStandardsIgnoreEnd
                 break;
             default:
                 // @codingStandardsIgnoreStart
                 $userPrompt = __('If you are a registered VAT customer, please click <a href="%1">here</a> to enter you billing address for proper VAT calculation', $editAddersUrl);
                 // @codingStandardsIgnoreEnd
                 break;
         }
         $this->messageManager->addSuccess($userPrompt);
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:27,代码来源:Account.php

示例9: testGetTaxCalculationAddressType

 /**
  * @param $store
  * @param $result
  * @dataProvider getTaxCalculationAddressTypeDataProvider
  */
 public function testGetTaxCalculationAddressType($store, $result)
 {
     $this->scopeConfig->expects($this->once())->method('getValue')->with(\Magento\Customer\Helper\Address::XML_PATH_VIV_TAX_CALCULATION_ADDRESS_TYPE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store)->will($this->returnValue($result));
     $this->assertEquals($result, $this->helper->getTaxCalculationAddressType($store));
 }
开发者ID:,项目名称:,代码行数:10,代码来源:

示例10: _getVatRequiredSalesAddress

 /**
  * Retrieve sales address (order or quote) on which tax calculation must be based
  *
  * @param Order $order
  * @param \Magento\Store\Model\Store|string|int|null $store
  * @return Address|null
  */
 protected function _getVatRequiredSalesAddress($order, $store = null)
 {
     $configAddressType = $this->customerAddressHelper->getTaxCalculationAddressType($store);
     $requiredAddress = $configAddressType === AbstractAddress::TYPE_SHIPPING ? $order->getShippingAddress() : $order->getBillingAddress();
     return $requiredAddress;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:AddVatRequestParamsOrderComment.php


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