我正在努力实现这一目标: 显示可配置产品的当前正常价格,并在其旁边显示特殊价格和所应用的折扣百分比。
显然我无法克服它,并且我发誓我做了google,并且到处搜索了很多内容。 我正在尝试修改final_price.html,但到目前为止效果不佳。 我唯一要做的就是在不需要的价格之前隐藏“低至”线。 但我不明白如何显示常规和最终版本。
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
<?php
$idSuffix = $block->getIdSuffix() ? $block->getIdSuffix() : '';
/** @var \Magento\Bundle\Pricing\Render\FinalPriceBox $block */
/** @var \Magento\Bundle\Pricing\Price\FinalPrice $finalPriceModel */
$finalPriceModel = $block->getPrice();
$minimalPrice = $finalPriceModel->getMinimalPrice();
$maximalPrice = $finalPriceModel->getMaximalPrice();
/** ex: \Magento\Bundle\Pricing\Price\BundleRegularPrice */
/** @var \Magento\Framework\Pricing\Price\PriceInterface $regularPriceModel */
$regularPriceModel = $block->getPriceType('regular_price');
$maximalRegularPrice = $regularPriceModel->getMaximalPrice();
$minimalRegularPrice = $regularPriceModel->getMinimalPrice();
?>
<?php if ($block->getSaleableItem()->getPriceView()): ?>
<p class="minimal-price">
<?php /* @escapeNotVerified */ echo $block->renderAmount($minimalPrice, [
'display_label' => __('As low as'),
'price_id' => $block->getPriceId('from-'),
'include_container' => true
]); ?>
<?php if ($minimalPrice < $minimalRegularPrice): ?>
<span class="old-price">
<?php /* @escapeNotVerified */ echo $block->renderAmount($minimalRegularPrice, [
'display_label' => __('Regular Price'),
'price_id' => $block->getPriceId('old-price-' . $idSuffix),
'include_container' => true,
'skip_adjustments' => true
]); ?>
</span>
<?php endif ?>
</p>
<?php else: ?>
<?php if ($block->showRangePrice()): ?>
<p class="price-from">
<?php /* @escapeNotVerified */ echo $block->renderAmount($minimalPrice, [
'display_label' => __('From'),
'price_id' => $block->getPriceId('from-'),
'price_type' => 'minPrice',
'include_container' => true
]); ?>
<?php if ($minimalPrice < $minimalRegularPrice): ?>
<span class="old-price">
<?php /* @escapeNotVerified */ echo $block->renderAmount($minimalRegularPrice, [
'display_label' => __('Regular Price'),
'price_id' => $block->getPriceId('old-price-' . $idSuffix),
'include_container' => true,
'skip_adjustments' => true
]); ?>
</span>
<?php endif ?>
</p>
<p class="price-to">
<?php /* @escapeNotVerified */ echo $block->renderAmount($maximalPrice, [
'display_label' => __('To'),
'price_id' => $block->getPriceId('to-'),
'price_type' => 'maxPrice',
'include_container' => true
]); ?>
<?php if ($maximalPrice < $maximalRegularPrice): ?>
<span class="old-price">
<?php /* @escapeNotVerified */ echo $block->renderAmount($maximalRegularPrice, [
'display_label' => __('Regular Price'),
'price_id' => $block->getPriceId('old-price-' . $idSuffix),
'include_container' => true,
'skip_adjustments' => true
]); ?>
</span>
<?php endif ?>
</p>
<?php else: ?>
<?php /* @escapeNotVerified */ echo $block->renderAmount($minimalPrice, [
'price_id' => $block->getPriceId('product-price-'),
'include_container' => true
]); ?>
<?php if ($minimalPrice < $minimalRegularPrice): ?>
<span class="old-price">
<?php /* @escapeNotVerified */ echo $block->renderAmount($minimalRegularPrice, [
'display_label' => __('Regular Price'),
'price_id' => $block->getPriceId('old-price-' . $idSuffix),
'include_container' => true,
'skip_adjustments' => true
]); ?>
</span>
<?php endif ?>
<?php endif ?>
<?php endif ?>
}