本文整理汇总了PHP中Magento\Tax\Model\Config::crossBorderTradeEnabled方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::crossBorderTradeEnabled方法的具体用法?PHP Config::crossBorderTradeEnabled怎么用?PHP Config::crossBorderTradeEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Tax\Model\Config
的用法示例。
在下文中一共展示了Config::crossBorderTradeEnabled方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isSameRateAsStore
/**
* Check if tax rate is same as store tax rate
*
* @param float $rate
* @param float $storeRate
* @return bool
*/
protected function isSameRateAsStore($rate, $storeRate)
{
if ((bool) $this->config->crossBorderTradeEnabled($this->storeId)) {
return true;
} else {
return abs($rate - $storeRate) < 1.0E-5;
}
}
示例2: calculateTax
/**
* {@inheritdoc}
*/
public function calculateTax(QuoteDetails $quoteDetails, $storeId = null)
{
if (is_null($storeId)) {
$storeId = $this->storeManager->getStore()->getStoreId();
}
// initial TaxDetails data
$taxDetailsData = [TaxDetails::KEY_SUBTOTAL => 0.0, TaxDetails::KEY_TAX_AMOUNT => 0.0, TaxDetails::KEY_DISCOUNT_TAX_COMPENSATION_AMOUNT => 0.0, TaxDetails::KEY_APPLIED_TAXES => [], TaxDetails::KEY_ITEMS => []];
$items = $quoteDetails->getItems();
if (empty($items)) {
return $this->taxDetailsBuilder->populateWithArray($taxDetailsData)->create();
}
$this->computeRelationships($items);
$addressRequest = $this->getAddressTaxRequest($quoteDetails, $storeId, $quoteDetails->getCustomerId());
if ($this->config->priceIncludesTax($storeId)) {
$storeRequest = $this->getStoreTaxRequest($storeId);
$classIds = [];
foreach ($items as $item) {
if ($item->getTaxClassId()) {
$classIds[] = $item->getTaxClassId();
}
}
$classIds = array_unique($classIds);
$addressRequest->setProductClassId($classIds);
$storeRequest->setProductClassId($classIds);
if ((bool) $this->config->crossBorderTradeEnabled($storeId)) {
$addressRequest->setSameRateAsStore(true);
} else {
$addressRequest->setSameRateAsStore($this->calculator->compareRequests($storeRequest, $addressRequest));
}
}
// init rounding deltas for this quote
$this->roundingDeltas = [];
// init discount tax compensations array
$this->discountTaxCompensations = [];
$processedItems = [];
/** @var QuoteDetailsItem $item */
foreach ($this->keyedItems as $item) {
if (isset($this->parentToChildren[$item->getCode()])) {
$processedChildren = [];
foreach ($this->parentToChildren[$item->getCode()] as $child) {
$processedItem = $this->processItem($child, $addressRequest, $storeId);
$taxDetailsData = $this->aggregateItemData($taxDetailsData, $processedItem);
$processedItems[$processedItem->getCode()] = $processedItem;
$processedChildren[] = $processedItem;
}
$processedItemBuilder = $this->calculateParent($processedChildren, $item->getQuantity());
$processedItemBuilder->setCode($item->getCode());
$processedItemBuilder->setType($item->getType());
$processedItem = $processedItemBuilder->create();
} else {
$processedItem = $this->processItem($item, $addressRequest, $storeId);
$taxDetailsData = $this->aggregateItemData($taxDetailsData, $processedItem);
}
$processedItems[$processedItem->getCode()] = $processedItem;
}
return $this->taxDetailsBuilder->populateWithArray($taxDetailsData)->setItems($processedItems)->create();
}
示例3: isCrossBorderTradeEnabled
/**
* Return whether cross border trade is enabled or not
*
* @param null|int|string|Store $store
* @return bool
*/
public function isCrossBorderTradeEnabled($store = null)
{
return (bool) $this->_config->crossBorderTradeEnabled($store);
}
示例4: _isCrossBorderTradeEnabled
/**
* Return whether cross border trade is enabled or not
*
* @param null|int|string|Store $store
* @return bool
*/
protected function _isCrossBorderTradeEnabled($store = null)
{
return (bool) $this->_config->crossBorderTradeEnabled($store);
}