2015-10-04 140 views
0

我正在销售具有存款价格的瓶装饮料。客户必须支付这笔费用,但可以将瓶子带到超市购买。我想在没有存款的产品页面中显示产品价格,但是当用户检查他的购物车时,需要将这个数量添加到购物车中以获得每个存款的物品。这里有一些额外的信息: 并非所有产品都有存款 的存款价格取决于产品prestashop中产品的临时价格

我设法一个“定金”字段添加到产品页面的后台:

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

但是,似乎更改购物车检出的整个工作流程将是一件非常痛苦的事情。有没有简单的方法来完成这项任务?

谢谢!

回答

1

做你想要它是用“产品属性的组合” +小代码更改,一步一个脚印什么最简单的方法:

  1. 创建产品属性如“存款”
  2. 增加它的价值,任何,例如。 “是”
  3. 在产品中创建与“存款:是”的组合,根据需要设置价格影响值,例如, “$ 10”,并将其设置为默认组合
  4. 对产品页面价格显示没有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.phpuse 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但像你已经做过的那样通过索引来访问数组元素),在任何情况下,解决方案都非常针对项目,只是快速修复,通常情况下更好地使用其他方式。

    +0

    嗨,谢谢你的回答!这个想法很好,我正在用组合技巧。问题是这仅适用于产品页面,而不适用于产品列表页面(以及所有其他产品列表,例如精选,最佳销售等)。任何想法? – skirato

    +0

    此外,我不得不调整你的代码到'if(combination.attributes [0] == 1){ \t \t basePriceWithoutTax = basePriceWithoutTax ++ combination.price; \t}'因为它是我必须比较的id属性,所以每个产品的id_product_attribute是不同的。 – skirato

    +0

    '组合。属性[0]!= 1'当然! (抱歉的垃圾邮件,无法编辑我的评论) – skirato