How to make a specific cart attribute appear on the packing slip

Hi all

Hope all of you stay well and safe.

I entered an additional cart attribute in the cart template liquid as below:


I'd like a reusable skincare spatula to keep my pots of creams clean and fresh.

And with this code in, the Shopify order page looks like below:

ADDITIONAL DETAILS

created_at

1xxxxxxxx

mc_cid
acxxxxx

Requested a spatula?
Yes

Also, I entered the following code in the packing slip template, wanting the 3rd attribute “Requested a spatula” section to appear:

{% for attribute in attributes %}
*{{ attribute | first }} {{ attribute | last }}

{% endfor %}

However, all information including mailchimp tracking info from the ‘Additional Details’ section appear on the packing slip.

Is there any way that I can make a specific attribute/s only appear on the packing slip? In this case, the ‘Requested a spatula?’ part only.

Any help will be greatly appreciated!

Thanks!

Hi, that’s normal, your a looping through all elements in the array and printing them.

Try to change it like this

{% for attribute in attributes %}
 {% assign key = attribute | first %}
 {% if key == 'your-key-name' %}
 *{{ attribute | first }} {{ attribute | last }}

 {% endif %}
{% endfor %}
2 Likes

Thank you so much @drakedev

It worked brilliantly!

Sorry to ask another dumb question…Is there any way to assign multiple keys so that I can put multiple conditions in the {% if…%}?

E.g. {% assign key1 = xxxx %} , {% assign key2 = yyy %}

Thank you for your help!

It is possible to add multiple conditions to an if, use if/elesif/else or use case/when to control the flow

If you explain the logic you want to implement I can give you some code examples

Hi @drakedev ,

I have followed the above however it doesn’t seem to work. Do you know if this still works currently?

Thanks, let me know

Brendan

1 Like

Hi!

i have an additional cart attribute in my cart template:

<input
          required
          class="required"
          type="checkbox"
          name="attributes[Envoltura gratis]"
          value="Si"
          {% if cart.attributes['Envoltura gratis'] == 'Si' %}
            checked
          {% endif %}
>

how can i get this attribute in my packing slip template? i followed the solution above but it doesn’t work for me

I will appreciate your help

Thanks!

Same problem I am facing with attribute did you get any solution of this how to add attribute in packing slip?

I have the same problem trying to add the order attributes to the print packaging form template but I can’t get it to appear.

{% for attribute in attributes %}
{% assign key = attribute | first %}
{% if key == ‘your-key-name’ %}
*{{ attribute | first }} {{ attribute | last }}

{% endif %}
{% endfor %}