Jump to content

display weight in prestashop 1.7


mmifarook

Recommended Posts

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 by nadie (see edit history)
  • Like 3
Link to comment
Share on other sites

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

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

  • 2 years later...
  • 1 year later...

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

  • 2 weeks later...
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

  • 1 year later...

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...