做你想要它是用“产品属性的组合” +小代码更改,一步一个脚印什么最简单的方法:
- 创建产品属性如“存款”
- 增加它的价值,任何,例如。 “是”
- 在产品中创建与“存款:是”的组合,根据需要设置价格影响值,例如, “$ 10”,并将其设置为默认组合
对产品页面价格显示没有function updatePrice()
查找线路
// Apply combination price impact // 0 by default, +x if price is inscreased, -x if price is decreased basePriceWithoutTax = basePriceWithoutTax + +combination.price;
,并包装成条件themes/themename/js/product.js
“定金”的变化:
if(your_attribute_id != combination.attributes[0]) {
basePriceWithoutTax = basePriceWithoutTax + +combination.price;
}
但在购物车中您会看到全价。
UPD:
我看不出有什么好办法做到这一点的模板,没有核心的变化,因此,如果您需要它(解决方案还不够理想) 文件controllers/front/CategoryController.php
( use override)方法assignProductList()
改变代码块到下一个视图:
foreach ($this->cat_products as &$product) {
if ($product['id_product_attribute'] && isset($product['product_attribute_minimal_quantity']))
$product['minimal_quantity'] = $product['product_attribute_minimal_quantity'];
$combination = new Combination($product['id_product_attribute']);
$attributes = $combination->getAttributesName($this->context->language->id);
foreach ($attributes as $attribute) {
if(your_attribute_id == $attribute['id_attribute'])
$product['price_tax_exc'] -= $combination->price;
}
}
您将需要重复它,你使用所有列出的控制器(你可以不使用的foreach但像你已经做过的那样通过索引来访问数组元素),在任何情况下,解决方案都非常针对项目,只是快速修复,通常情况下更好地使用其他方式。
嗨,谢谢你的回答!这个想法很好,我正在用组合技巧。问题是这仅适用于产品页面,而不适用于产品列表页面(以及所有其他产品列表,例如精选,最佳销售等)。任何想法? – skirato
此外,我不得不调整你的代码到'if(combination.attributes [0] == 1){ \t \t basePriceWithoutTax = basePriceWithoutTax ++ combination.price; \t}'因为它是我必须比较的id属性,所以每个产品的id_product_attribute是不同的。 – skirato
'组合。属性[0]!= 1'当然! (抱歉的垃圾邮件,无法编辑我的评论) – skirato