prestashop 中产品的额外价格

Aditionnal price to product in prestashop

我卖的是有定金价的瓶装饮料。顾客必须支付这笔款项,但可以通过将瓶子带到超市来取回。我想在产品页面中显示没有押金的产品价格,但是当用户结帐时,需要为每个有押金的商品将此金额添加到购物车。这里有一些额外的信息: 并非所有产品都有押金 入金价格视产品而定

我设法在产品页面的后台添加了一个 "deposit" 字段:

http://oi57.tinypic.com/6p9s80.jpg

但似乎改变购物车结账的整个工作流程会很痛苦。有什么简单的方法可以完成这个任务吗?

谢谢!

做你想做的最简单的方法是使用 "product attributes combinations" + 一点点代码更改,一步一步:

  1. 创建产品属性,例如"deposit"
  2. 为其增加价值,例如"yes"
  3. 在product create combination with "deposit: yes"中,根据需要设置价格影响值,例如"$10" 并将其设置为默认组合
  4. function updatePrice() 查找行

    themes/themename/js/product.js 中 "deposit" 不更改的情况下显示在产品页面上的价格

    // Apply combination price impact // 0 by default, +x if price is inscreased, -x if price is decreased basePriceWithoutTax = basePriceWithoutTax + +combination.price;

并将其包装成条件:

if( your_attribute_id != combination.attributes[0] ) {    
    basePriceWithoutTax = basePriceWithoutTax + +combination.price;
}

但在购物车中您会看到全价。

更新:

  1. 我认为在模板中没有好的方法,没有核心更改,所以如果你需要它(解决方案也不理想) 文件 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,而是像你已经做的那样通过索引访问数组元素),在任何情况下解决方案都是针对项目的,只是快速修复, 通常情况下最好使用其他方式。