我有一组产品,它是由2个希尔德产品(1个真实产品+1个代表修复成本的"虚拟"产品)制成的。
因此,客户有两种可能性:
- 他可以购买真正的产品自行解决问题或
- 他可以购买捆绑包,他将购买修复套件,并自动购买真正的产品,而我的工厂将修复他的问题
例如,产品的价格为30欧元,修复套装的价格为20欧元。
在前端,它将被设置为:"起价:20欧元"
然而,我认为客户不能只使用一种产品购买此捆绑包。因此,价格是50欧元,我希望在前端的价格设置为50欧元。
我试图修改我的主题文件,该文件位于:…/Catalog/Block/Product/View/price.html
我想插入以下变量$simulationPrice:
<span class="price" id="product-minimal-price-<?php echo $_id ?>
<?php echo $this->getIdSuffix() ?>">
<?php "there I would like the price 50€" echo $simulationPrice ?>
</span>
要做到这一点,我想执行操作:
<?php $_associatedProducts = $this->getAssociatedProducts(); ?>
<?php foreach ($_associatedProducts as $childProduct) { ?>
<?php $simulationPrice += $childProduct->getPrice() ?>
<?php } ?>
我该怎么做?我希望价格=1个实物*1个数量+1个虚拟产品*1个数量。
如果你有其他方法,阅读你的命题将是一件愉快的事。我精确地说,我已经修改了捆绑包,客户不能修改设置为1个单位的数量(1个真实产品+1个虚拟产品),但他可以修改篮子里的数量。。。
如果你有关于这个代码的解决方案,但它不起作用,那将是一种乐趣。
谢谢你的帮助。
我得到了这个代码的解决方案:
$simulationPrice=0;
$associatedProducts = $_product->getTypeInstance(true)->getAssociatedProducts($_product);
foreach ($associatedProducts as $childProduct) {
$quantityBackGround=$childProduct->getQty();
$simulationPrice += $childProduct->getPrice() * $childProduct->getQty();
}
事实上,最大的问题是我把代码变成了以下情况:
<?php if (!$_product->isGrouped()): ?>
我没有看到"!"的状况。。。。因此它永远不可能工作。。。