Show separate custom cart attribute fields in order printer pro

Highlighted
Shopify Partner
5 0 0

Hi, 

I have customer input fields on my cart and this provides me with several fields of answers when a customer orders.

This works well and comes through to my admin order email and printer pro. However, I would like to shows the fields separately in the order printer pro template.

 

Currently, I have:

 

        {% for attribute in attributes %}
                <strong>{{ attribute | first }}:</strong> {{ attribute | last }}<br />
        {% endfor %}

The above shows:

 

First Name: Person
Last Name: Person Last name
Date of Birth: 24/09/45
Gender: Female
Results: Yes I would Like Reported Results

 

The above works but brings over all the fields, 5 rows in total. I would like to show only 4 of those fields as below.

 

First Name: Person
Last Name: Person Last name
Date of Birth: 24/09/45
Gender: Female

 

I have tried this:

 

{% assign SETTING_show_cart_attributes = true %}

SURNAME:{{ attributes.last-name }}

SURNAME:{{ cart.attributes.last-name }}

SURNAME:{{ last-name }}

 

Any help would be much appreciated.

Keith

0 Likes
Highlighted
Shopify Partner
262 26 40

Hi @ukbh

You can try this:

{% for attribute in attributes %}
  {% assign attr_name = attribute | first %}
  {% assign attr_value = attribute | last %}
  {% unless attr_name  == 'Result' %}
    <strong>{{ attr_name}}:</strong> {{ attr_value  }}<br />
  {% endunless %}
{% endfor %}
Let's make the best store!
Contact us at: thepremierstores@gmail.com
1 Like
Highlighted
Shopify Partner
5 0 0

Hi @PremierStores 

 

Apologies for the delay, only just got back into work!

Many thanks for your reply on this, I added this in and this brings back all custom attributes from the cart:

 

Patient First name: yjhryjh
Patient Last Name: drtjdrtj
Patient Date of Birth: 12/12/1987
Patient Gender: Female
Reported Results: Yes I would Like Reported Results

 

I am hoping to split them up, so I only show the below in summary:

 

Patient First name: yjhryjh
Patient Last Name: drtjdrtj
Patient Date of Birth: 12/12/1987
Patient Gender: Female

 

And these by themselves in different parts of the order PDF:

 yjhryjh  will be attending, and their last name is drtjdrtj and their DOB is 12/12/1987

 

many thanks for your help.

Keith

0 Likes
Highlighted
Shopify Partner
262 26 40

Hi, @ukbh

 

So the code needs a little adjust:

{% for attribute in attributes %}
  {% assign attr_name = attribute | first %}
  {% assign attr_value = attribute | last %}
  {% unless attr_name  == 'Reported Results' %}
    <strong>{{ attr_name}}:</strong> {{ attr_value  }}<br />
  {% endunless %}
{% endfor %}

 
About the PDF, it's not possible to edit that report without using an App.

Let's make the best store!
Contact us at: thepremierstores@gmail.com
0 Likes
Highlighted
Shopify Partner
5 0 0

@PremierStores  thankyou, that's great, gets rid of the 5th option :)

 

Many thanks

0 Likes
Highlighted
Shopify Partner
262 26 40

Hi @ukbh:
We are glad to know that, please give us a like and mark the solution to help other people to find it. Thank you.

Let's make the best store!
Contact us at: thepremierstores@gmail.com
0 Likes