本文整理汇总了PHP中Magento\Tax\Helper\Data::getTaxBasedOn方法的典型用法代码示例。如果您正苦于以下问题:PHP Data::getTaxBasedOn方法的具体用法?PHP Data::getTaxBasedOn怎么用?PHP Data::getTaxBasedOn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Tax\Helper\Data
的用法示例。
在下文中一共展示了Data::getTaxBasedOn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: aroundExecute
/**
* @param \Magento\Framework\App\ActionInterface $subject
* @param callable $proceed
* @param \Magento\Framework\App\RequestInterface $request
* @return mixed
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function aroundExecute(
\Magento\Framework\App\ActionInterface $subject,
\Closure $proceed,
\Magento\Framework\App\RequestInterface $request
) {
if (!$this->weeeHelper->isEnabled() ||
!$this->customerSession->isLoggedIn() ||
!$this->moduleManager->isEnabled('Magento_PageCache') ||
!$this->cacheConfig->isEnabled()) {
return $proceed($request);
}
$basedOn = $this->taxHelper->getTaxBasedOn();
if ($basedOn != 'shipping' && $basedOn != 'billing') {
return $proceed($request);
}
$weeeTaxRegion = $this->getWeeeTaxRegion($basedOn);
$websiteId = $this->storeManager->getStore()->getWebsiteId();
$countryId = $weeeTaxRegion['countryId'];
$regionId = $weeeTaxRegion['regionId'];
if (!$countryId && !$regionId) {
// country and region does not exist
return $proceed($request);
} else if ($countryId && !$regionId) {
// country exist and region does not exist
$regionId = 0;
$exist = $this->weeeTax->isWeeeInLocation(
$countryId,
$regionId,
$websiteId
);
} else {
// country and region exist
$exist = $this->weeeTax->isWeeeInLocation(
$countryId,
$regionId,
$websiteId
);
if (!$exist) {
// just check the country for weee
$regionId = 0;
$exist = $this->weeeTax->isWeeeInLocation(
$countryId,
$regionId,
$websiteId
);
}
}
if ($exist) {
$this->httpContext->setValue(
'weee_tax_region',
['countryId' => $countryId, 'regionId' => $regionId],
0
);
}
return $proceed($request);
}