本文整理汇总了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();
}
}
示例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;
}
示例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;
}
示例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();
}
}
示例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');
}
}
}
示例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);
}
示例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;
}
示例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);
}
}
示例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));
}
示例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;
}