Magento 2 显示不含税的最低价格
Magento 2 Display minimal price without tax
Magento 2
我们在前端显示含税和不含税的产品价格。
默认情况下,最低价格和旧价格是含税的,但我必须显示不含税的最低价格。
知道在哪里或如何改变这个吗?
没有完美的方法,我找到的最佳解决方案是覆盖发生价格呈现的模板,并使用基本金额而不是 "As low as" 的全部金额。
My/Theme/Magento_Catalog/templates/product/price/amount/default.phtml
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
<?php /** @var \Magento\Framework\Pricing\Render\Amount $block */ ?>
<?php
if ($block->getDisplayLabel() != 'As low as') {
$price = $block->getDisplayValue();
}
else {
$price = $block->getAmount()->getBaseAmount();
}
?>
<span class="price-container <?php /* @escapeNotVerified */ echo $block->getAdjustmentCssClasses() ?>"
<?php echo $block->getSchema() ? ' itemprop="offers" itemscope itemtype="http://schema.org/Offer"' : '' ?>>
<?php if ($block->getDisplayLabel()): ?>
<span class="price-label"><?php /* @escapeNotVerified */ echo $block->getDisplayLabel(); ?></span>
<?php endif; ?>
<span <?php if ($block->getPriceId()): ?> id="<?php /* @escapeNotVerified */ echo $block->getPriceId() ?>"<?php endif;?>
<?php echo($block->getPriceDisplayLabel()) ? 'data-label="' . $block->getPriceDisplayLabel() . $block->getPriceDisplayInclExclTaxes() . '"' : '' ?>
data-price-amount="<?php /* @escapeNotVerified */ echo $price; ?>"
data-price-type="<?php /* @escapeNotVerified */ echo $block->getPriceType(); ?>"
class="price-wrapper <?php /* @escapeNotVerified */ echo $block->getPriceWrapperCss(); ?>"
<?php echo $block->getSchema() ? ' itemprop="price"' : '' ?>>
<?php /* @escapeNotVerified */ echo $block->formatCurrency($price, (bool)$block->getIncludeContainer()) ?>
</span>
<?php if ($block->hasAdjustmentsHtml()): ?>
<?php echo $block->getAdjustmentsHtml() ?>
<?php endif; ?>
<?php if ($block->getSchema()): ?>
<meta itemprop="priceCurrency" content="<?php /* @escapeNotVerified */ echo $block->getDisplayCurrencyCode()?>" />
<?php endif; ?>
</span>
Magento 2 我们在前端显示含税和不含税的产品价格。 默认情况下,最低价格和旧价格是含税的,但我必须显示不含税的最低价格。
知道在哪里或如何改变这个吗?
没有完美的方法,我找到的最佳解决方案是覆盖发生价格呈现的模板,并使用基本金额而不是 "As low as" 的全部金额。
My/Theme/Magento_Catalog/templates/product/price/amount/default.phtml
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
<?php /** @var \Magento\Framework\Pricing\Render\Amount $block */ ?>
<?php
if ($block->getDisplayLabel() != 'As low as') {
$price = $block->getDisplayValue();
}
else {
$price = $block->getAmount()->getBaseAmount();
}
?>
<span class="price-container <?php /* @escapeNotVerified */ echo $block->getAdjustmentCssClasses() ?>"
<?php echo $block->getSchema() ? ' itemprop="offers" itemscope itemtype="http://schema.org/Offer"' : '' ?>>
<?php if ($block->getDisplayLabel()): ?>
<span class="price-label"><?php /* @escapeNotVerified */ echo $block->getDisplayLabel(); ?></span>
<?php endif; ?>
<span <?php if ($block->getPriceId()): ?> id="<?php /* @escapeNotVerified */ echo $block->getPriceId() ?>"<?php endif;?>
<?php echo($block->getPriceDisplayLabel()) ? 'data-label="' . $block->getPriceDisplayLabel() . $block->getPriceDisplayInclExclTaxes() . '"' : '' ?>
data-price-amount="<?php /* @escapeNotVerified */ echo $price; ?>"
data-price-type="<?php /* @escapeNotVerified */ echo $block->getPriceType(); ?>"
class="price-wrapper <?php /* @escapeNotVerified */ echo $block->getPriceWrapperCss(); ?>"
<?php echo $block->getSchema() ? ' itemprop="price"' : '' ?>>
<?php /* @escapeNotVerified */ echo $block->formatCurrency($price, (bool)$block->getIncludeContainer()) ?>
</span>
<?php if ($block->hasAdjustmentsHtml()): ?>
<?php echo $block->getAdjustmentsHtml() ?>
<?php endif; ?>
<?php if ($block->getSchema()): ?>
<meta itemprop="priceCurrency" content="<?php /* @escapeNotVerified */ echo $block->getDisplayCurrencyCode()?>" />
<?php endif; ?>
</span>