本文整理匯總了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);
}