在prestashop的产品的aditionnal价格

时间:2015-10-04 13:06:15

标签: prestashop shopping-cart prestashop-1.6

我卖的是有存款价格的瓶装饮料。客户必须支付这笔金额,但可以通过将瓶子带到超市来取回。我想在产品页面中显示没有存款的产品价格,但是当用户检出他的购物车时,需要将这笔金额添加到购物车中以存入每个存款。这是一些额外的信息: 并非所有产品都有存款 存款价格取决于产品

我设法添加"存款"字段到产品页面的后台:

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

但似乎改变购物车检查的整个工作流程会非常痛苦。有没有简单的方法来完成这项任务?

谢谢!

1 个答案:

答案 0 :(得分:1)

最简单的方法来做你想要的是使用"产品属性组合" +小代码一步一步地改变:

  1. 创建产品属性,例如"存"
  2. 为它增加价值,例如。 "是"
  3. 在产品中创建与"存款组合:是",根据需要设置价格影响值,例如: " $ 10#34;并将其设置为默认组合
  4. 在没有"存款"的产品页面价格上显示更改themes/themename/js/product.js中的function updatePrice()查找行

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

  5. 并将其包装成条件:

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

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

    UPD:

    1. 我认为没有好的方法可以在模板中进行,没有核心更改,所以如果你需要它(解决方案也不理想) 文件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;
          }
      }
      
    2. 你需要为你使用的所有列表控制器重复它(并且你不能使用foreach但是像你已经那样通过索引访问数组元素),在任何情况下解决方案都是特定于项目的,只需快速修复,常见的情况是更好地使用其他方式。

相关问题