r_r4f Posted October 6, 2016 Share Posted October 6, 2016 (edited) Hi all, I need to simplify decimal of product weight. For example 0.800000 kg simplified to 0.8 kg, as shown in image attached. Anyone can help? thankyou Edited October 6, 2016 by r_r4f (see edit history) Link to comment Share on other sites More sharing options...
rocky Posted October 7, 2016 Share Posted October 7, 2016 The default PrestaShop v1.6.1.7 theme doesn't display product weights in the shopping cart. Can you post the line of code from shopping-cart-product-line.tpl that displays the product weight? It should contain $product.weight or something like that. Link to comment Share on other sites More sharing options...
r_r4f Posted October 7, 2016 Author Share Posted October 7, 2016 My store has been configured to show the weight of products and it works well. But the problem is too many decimal in the value of weight. so i need to simplify decimal of the value. My link: http://taniorganik.com/store2 Link to comment Share on other sites More sharing options...
rocky Posted October 7, 2016 Share Posted October 7, 2016 Thanks for the link. Unfortunately, I don't know the code that is currently formatting the weight, so it's hard to suggest changing it. If it is being formatted to 8 decimal places, then I'd suggest removing the formatting code, which could be something like |number_format:8. Link to comment Share on other sites More sharing options...
Rhobur Posted October 8, 2016 Share Posted October 8, 2016 Add |string_format:"%.2f" (where 2 is the number of decimals) to the smarty weight variable in your tpl Link to comment Share on other sites More sharing options...
r_r4f Posted October 8, 2016 Author Share Posted October 8, 2016 (edited) Thankyou rocky for your support. And thankyou Rho_bur, your amazing |string_format:"%.2f" works well in my cart. Its simple, i just change the line: <td class="cart_weight">{if $product.weight}{$product.weight|escape:'htmlall':'UTF-8'} {$weightUnit}{/if}</td> to <td class="cart_weight">{if $product.weight}{$product.weight|string_format:"%.2f"|escape:'htmlall':'UTF-8'} {$weightUnit}{/if}</td> in my shopping-cart-product-line.tpl, placed above line {if $PS_STOCK_MANAGEMENT} Prestashop 1.6.1.7 Edited October 8, 2016 by r_r4f (see edit history) 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