ReinH Posted March 2, 2019 Share Posted March 2, 2019 (edited) Hi, Let's consider the following. The attached picture is the following foreach loop: {foreach from=$order_products item=product} <tr> <td class="custom-td">{$product.product_name}</td> <td class="custom-td-price"> {if $use_taxes} {displayPrice price=$product.total_price_tax_incl} {else} {displayPrice price=$product.total_price_tax_excl} {/if} </td> <td class="custom-td-qty">{$product.product_quantity}</td> </tr> {/foreach} Which is taken from the following tutorial: http://nemops.com/prestashop-order-confirmation-resume/ I've been trying to make a sum of the total quantity of the cart in question to populate the variables of a javascript tracker, but I've got no idea on how to make that. I've tried to call $cart_qties to get the whole total of the order, but it will show just 0. I don't have much experience with smarty, but How can I achieve the thing that I need? It's a simple sum of the output of the foreach loop. 2+3+3+2 Edited March 2, 2019 by ReinH (see edit history) Link to comment Share on other sites More sharing options...
ReinH Posted March 2, 2019 Author Share Posted March 2, 2019 Well, nevermind. I'm not sure if this is the right way, but if anyone needs it this is how I made it: {foreach from=$order_products item=product} {$product.product_quantity} {assign var="sum_elements" value=$sum_elements+$product.product_quantity} {/foreach} = {$sum_elements} Pretty simple, I can't believe I spent 3 hours doing this. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now