Insert Product Weight into Product Description

somersetfoodie
Tourist
7 0 1

Is it possible to insert the value of a products weight into the products description using code? This way the weight of the product is visible information to the customer before they purchase and it would make things a lot quicker as there would be no need to manually include the weight in each and every products description, as this would be done automatically.

The theme being used is Debut.

0 Likes
dmwwebartisan
Shopify Partner
5878 1345 1729

Hey @somersetfoodie,

You need to change the product page template liquid file.

You can use the following code to display product weight.

Weight: {% for variant in product.variants %}{{variant.weight | weight_with_unit }}{% endfor %}

 

Hope this will work.

Thanks!

If helpful then please Like and Accept Solution.
Email: dmw.webartisan@gmail.com | Instagram: @dmw.webartisan
Advanced Shopify Page Builder to customize your pages - check here PageFly App
0 Likes
somersetfoodie
Tourist
7 0 1

Thanks for the quick response! Where in the code structure should I use the code you provided? This is how the product.liquid code looks right now:

{% comment %}
  The contents of the product.liquid template can be found in /sections/product-template.liquid
{% endcomment %}

{% section 'product-template' %}
{% section 'product-recommendations' %}

{% if collection %}
  <div class="text-center return-link-wrapper page-width">
    <a href="{{ collection.url }}" class="btn btn--secondary btn--has-icon-before return-link">
      {% include 'icon-arrow-left' %}
      {{ 'products.product.back_to_collection' | t: title: collection.title }}
    </a>
  </div>
{% endif %}

<script>
  // Override default values of shop.strings for each template.
  // Alternate product templates can change values of
  // add to cart button, sold out, and unavailable states here.
  theme.productStrings = {
    addToCart: {{ 'products.product.add_to_cart' | t | json }},
    soldOut: {{ 'products.product.sold_out' | t | json }},
    unavailable: {{ 'products.product.unavailable' | t | json }}
  }
</script>

{% assign current_variant = product.selected_or_first_available_variant %}

<script type="application/ld+json">
{
  "@context": "http://schema.org/",
  "@type": "Product",
  "name": {{ product.title | json }},
  "url": {{ shop.url | append: product.url | json }},
  {%- if product.featured_media -%}
    {%- assign media_size = product.featured_media.preview_image.width | append: 'x' -%}
    "image": [
      {{ product.featured_media | img_url: media_size | prepend: "https:" | json }}
    ],
  {%- endif -%}
  "description": {{ product.description | strip_html | json }},
  {%- if current_variant.sku != blank -%}
    "sku": {{ current_variant.sku | json }},
  {%- endif -%}
  "brand": {
    "@type": "Thing",
    "name": {{ product.vendor | json }}
  },
  "offers": [
    {%- for variant in product.variants -%}
      {
        "@type" : "Offer",
        {%- if variant.sku != blank -%}
          "sku": {{ variant.sku | json }},
        {%- endif -%}
        "availability" : "http://schema.org/{% if product.available %}InStock{% else %}OutOfStock{% endif %}",
        "price" : {{ variant.price | divided_by: 100.00 | json }},
        "priceCurrency" : {{ cart.currency.iso_code | json }},
        "url" : {{ shop.url | append: variant.url | json }}
      }{% unless forloop.last %},{% endunless %}
    {%- endfor -%}
  ]
}
</script>
0 Likes
dmwwebartisan
Shopify Partner
5878 1345 1729

Hey @somersetfoodie,

Go to Sections/product-template.liquid file. You will get a description code there just paste given code there and see where it appears.

Move that code in your desired place.

Thanks!

If helpful then please Like and Accept Solution.
Email: dmw.webartisan@gmail.com | Instagram: @dmw.webartisan
Advanced Shopify Page Builder to customize your pages - check here PageFly App
0 Likes
somersetfoodie
Tourist
7 0 1

Thanks, this has worked! It is currently displaying the weight in lbs when I would like it display kg. Is it possible to change which unit of weight the code displays?

0 Likes
dmwwebartisan
Shopify Partner
5878 1345 1729

Hey @somersetfoodie,

Please edit the product and check the setting of the product weight in the admin. It must be in KG.

Because if you see the code, it is dynamic. It will automatically take weight measurements for the product.

So please check in the admin.

Thanks!

If helpful then please Like and Accept Solution.
Email: dmw.webartisan@gmail.com | Instagram: @dmw.webartisan
Advanced Shopify Page Builder to customize your pages - check here PageFly App
0 Likes
grubio
Tourist
21 0 1

Hi

I follow the instruction and although I have gr. as weight metric for the products in the Admin, the weight is displayed as kg. in the product page.

Do you know how I can show gr. instead of kg in the product page?

Thanks

0 Likes