简体   繁体   English

如何在购物车摘要Prestashop中用特征值乘以产品单位

[英]How to Multiply Product unit with feature value in cart summary Prestashop

Screenshot (Prestashop) I added a image of Cart summary. 屏幕快照 (Prestashop)我添加了购物车摘要的图像。 So I added product features in cart summary and one of them is "Bag" which is weight in Kg. 因此,我在购物车摘要中添加了产品功能,其中之一是“包”,以千克为单位。 "Total KG" section shows total weight means "product quantity x Bag weight". “总KG”部分显示总重量是指“产品数量x袋重”。 I used this code and it's working when we click add to cart. 我使用了此代码,当我们单击“添加到购物车”时,它可以工作。

<td>
{assign var="features"     value=Product::getFrontFeaturesStatic(Context::getContext()->language->id,   $product.id_product)} 
{foreach $features as $feature}
{if $feature.id_feature == 9}
<div>{$feature.value*$product.cart_quantity|escape:'htmlall':'UTF-8'} Kg</div>
{/if}
{/foreach}
</td>

But when we increase quantity directly through cart summary page through + and - buttons then it's not working. 但是,当我们直接通过购物车摘要页面中的+和-按钮增加数量时,则无法使用。 I know it is possible but using ajax only. 我知道有可能,但仅使用ajax。

When product quantity is modified on the Cart page then an Ajax request is sent to CartController.php (front) and which finally calls updateQty() function in Cart.php class file. 在“购物车”页面上修改产品数量后,Ajax请求将发送到CartController.php(前面),并最终在Cart.php类文件中调用updateQty()函数。

So you need to add the code that you are using to updateQty() function as well. 因此,您还需要将要使用的代码添加到updateQty()函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM