mmifarook Posted February 15, 2018 Share Posted February 15, 2018 Hi all, i need to display weight in product inner page in prestashop 1.7 . please help to solve this. Link to comment Share on other sites More sharing options...
nadie Posted February 15, 2018 Share Posted February 15, 2018 (edited) hace 59 minutos, mmifarook dijo: Hi all, i need to display weight in product inner page in prestashop 1.7 . please help to solve this. Use variable: {$product.weight} For example in the file: /themes/classic/templates/catalog/product.tpl Below the short description of the product Attached image: http://victor-rodenas.com/wp-content/uploads/2018/02/PesoProducto-1024x301.png Sorry for my English Tip tested in Prestashop 1.7.2.4 with the default template ---- {$product.weight} -> weight product {$product.weight_unit} -> Unit of the weight (Kg) --- {if isset($product.weight) && ($product.weight != 0)} <div> {l s='Weight' d='Shop.Theme.Catalog'} {$product.weight|string_format:"%.2f"} {$product.weight_unit} </div> {/if} Edited February 15, 2018 by nadie (see edit history) 3 Link to comment Share on other sites More sharing options...
mmifarook Posted February 18, 2018 Author Share Posted February 18, 2018 On 2/15/2018 at 3:37 PM, nadie said: Use variable: {$product.weight} For example in the file: /themes/classic/templates/catalog/product.tpl Below the short description of the product Attached image: http://victor-rodenas.com/wp-content/uploads/2018/02/PesoProducto-1024x301.png Sorry for my English Tip tested in Prestashop 1.7.2.4 with the default template ---- {$product.weight} -> weight product {$product.weight_unit} -> Unit of the weight (Kg) --- {if isset($product.weight) && ($product.weight != 0)} <div> {l s='Weight' d='Shop.Theme.Catalog'} {$product.weight|string_format:"%.2f"} {$product.weight_unit} </div> {/if} Thanks for the reply nadie, I tried the variable the u specified above it worked , but if the product has two weights, the weight should change according to the option selected, if the product has large and small option with different weight and prices . the price is changing according to the option selected but weight remains same . please help me to solve this .thank you Link to comment Share on other sites More sharing options...
eleazar Posted February 18, 2018 Share Posted February 18, 2018 This is already done with a hook in /blob/develop/themes/classic/templates/catalog/_partials/product-prices.tpl. I mean, in theory! Because in order to show this weight label, you would have to install the module for complying with European legal requirements called ps_legalcompliance. And after this you would find another bug here: They forgot to integrate this weight hook file into /modules/ps_legalcompliance/views/templates/hook My advice: Forget this ill-conceived new development called PrestaShop 1.7x and use the technically mature shop software PrestaShop 1.6.1x instead. Link to comment Share on other sites More sharing options...
Merlin-Naturkosmetik Posted August 5, 2020 Share Posted August 5, 2020 This may works with an product which has a weight. But if i using combinations my default weight is zero. I added the information for the combination to add 40 grams. So my display is still zero. How can I get the chosen combinations weight? Link to comment Share on other sites More sharing options...
Galomen Posted August 21, 2021 Share Posted August 21, 2021 HI. How to display weight product on product page?? PrestaShop 1.7.7.6 version /themes/*Your Theme*/templates/catalog/_partials/product-prices.tpl Add line after: <div class="product-prices"> {block name='product.weight'} {if isset($product.weight) && ($product.weight != 0)} <div class=product-weight"> <label class="label">{l s='CatWeight: ' d='Shop.Theme.Catalog'}</label> <span itemprop="product-weight">{$product.weight|string_format:"%.2f"} {$product.weight_unit}</span> </div> {/if} {/block} Working Prestashop 1.7.7.6 version Link to comment Share on other sites More sharing options...
WebCR8 Posted August 30, 2021 Share Posted August 30, 2021 On 8/21/2021 at 11:55 PM, Galomen said: /themes/*Your Theme*/templates/catalog/_partials/product-prices.tpl Add line after: <div class="product-prices"> {block name='product.weight'} {if isset($product.weight) && ($product.weight != 0)} <div class=product-weight"> <label class="label">{l s='CatWeight: ' d='Shop.Theme.Catalog'}</label> <span itemprop="product-weight">{$product.weight|string_format:"%.2f"} {$product.weight_unit}</span> </div> {/if} {/block} Hi I'm new to PrestaShop and have only been at it a month but have a great shop developing (1.7.7.6) for a friend and have implemented some updates and custom styling. With regard to the above piece of code for the product-prices.tpl file (thanks Galomen): I implemented it and it works great in the Product Details tab or all Single Products. However, when I use it on a simple combination product (one item with a number of sizes selectable from a dropdown), the $product.weight variable does not update with the different "Impact on weight" value changes for each size. The price changes perfectly in accordance with the "Impact on price" value. I understand that one needs to add the base weight to the combination impact weight but obviously the maths cannot be done within the TPL file. I found "{$product->weight+$combinations[$product.id_product_attribute]["weight"]}" and this does contain the correct product combo weight. How can I correctly integrate this into above TPL code as quoted above? Is there another variable available within PrestaShop (for example something like "$product.total_weight" that would contain the new total weight value of the combination choice for display or how can I create this (which PHP file provides the values to the TPL file)? Any assistance would be greatly appreciated. Thank you. Link to comment Share on other sites More sharing options...
formel Posted November 24, 2022 Share Posted November 24, 2022 Hi, since I charge my shipping costs by weight to the customer, I need to display weight information of the item on the item page. I have inserted the code, this works very well! Thanks a lot for this! Unfortunately our store is multilingual, is there maybe a solution to display the name "weight" in the respective language? Somehow I can't find a module free or paid for this either. Have Prestashop 1.7.8.7 Thanks! 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