Product weight always zero after adding to packing slip, how to show actual value

Product weight always zero after adding to packing slip, how to show actual value

medlingtonQPS
Shopify Partner
28 0 8

Im trying to add the weight of each line item onto our packing slips but the weight variables always show as zero even though values have been set for the items.

 

If I use this:

{{ line_item.weight | weight_with_unit }}

 

it just shows as:

0 g

 

Ive also tried using both

{{ line_item.grams | weight_with_unit }}

and

{{ line_item.grams }}

 

and just get the same result.

 

Ive placed this within the main for loop as you can see here:

 

 

{% for line_item in line_items_in_shipment %}
      <div class="flex-line-item">
        <div class="flex-line-item-img">
          {% if line_item.image != blank %}
            <div class="aspect-ratio aspect-ratio-square" style="width: {{ desired_image_size }}px; height: {{ desired_image_size }}px;">
              {{ line_item.image | img_url: effective_image_dimensions | img_tag: '', 'aspect-ratio__content' }}
            </div>
          {% endif %}
        </div>
        <div class="flex-line-item-description">
          <p>
            <span class="line-item-description-line">
              {{ line_item.title }}
            </span>
            {% if line_item.variant_title != blank %}
              <span class="line-item-description-line">
                {{ line_item.variant_title }}
              </span>
            {% endif %}
            {% if line_item.sku != blank %}
              <span class="line-item-description-line">
                {{ line_item.sku }}
              </span>
            {% endif %}
{{ line_item.weight | weight_with_unit  }}
             {% if line_item.weight != blank %}
              <span class="line-item-description-line">
                {{ line_item.weight | weight_with_unit }}
              </span>
            {% endif %}
            
          </p>
        </div>
        <div class="flex-line-item-quantity">
          <p class="text-align-right">
            {{ line_item.shipping_quantity }} of {{ line_item.quantity }}
          </p>
        </div>
      </div>
    {% endfor %}

 

 

 

Anyone know how I can get it to show the correct values? Is there a different bit of liquid I need?

 

Thanks

Replies 6 (6)

Kani
Shopify Partner
468 125 227

Hi @medlingtonQPS 

 

It's line_item.grams https://shopify.dev/api/liquid/objects#line_item-grams

And please try to print your line item. It will help you to debug your issue.

{{ line_item | json }}

 

Hey!! ʕ ᵔᴥᵔ ʔ
Please click 'Like' and ' Accept as Solution' to encourage me to continue sharing my expertise. ♡
If you need any technical assistance, feel free to send me a DM. You no longer have to search for answers without getting a response. 🙂
medlingtonQPS
Shopify Partner
28 0 8

Thanks, 

 

I tried doing {{ line_item | json }}

 

it gives me a server error when I try to preview it so I can't see the possible variables (shot attached)

shot.jpg

 

 

Also, Ive found that if I use this code within

settings > shipping & delivery

it comes up empty or shows zero value.

 

If I use this code within

order printer > edit templates

then it works and shows me the weight however it doesn't work for the barcode for which Im using this code:

 

{{ line_item.barcode }}

Kani
Shopify Partner
468 125 227

You should check the liquid document at first

It should be 

{{ line_item.variant.barcode }}

https://shopify.dev/api/liquid/objects#variant-barcode

Hey!! ʕ ᵔᴥᵔ ʔ
Please click 'Like' and ' Accept as Solution' to encourage me to continue sharing my expertise. ♡
If you need any technical assistance, feel free to send me a DM. You no longer have to search for answers without getting a response. 🙂
medlingtonQPS
Shopify Partner
28 0 8

thanks that seems to work now although I had checked that doc and tried it before, I must have tried it in the shipping settings rather than in order printer.

 

As with most things shopify there seems to be conflicting info all over as Ive seen it suggested to do this several different ways now

GCB21
Visitor
2 0 0

Did you ever find a solution? I'm trying to get the weight to display for each item on the packing slip, but they are all 0.0

 

Thanks!

medlingtonQPS
Shopify Partner
28 0 8

Sorry, I cant remeber if I got this working or not, if the answers not in this thread then probably not. We use order printer Pro now and it was simple to setup all of this