What are the Liquid variables to access the tips for an order?

Solved
packula
Tourist
4 1 2

The new tipping feature to let customers leave a tip in the checkout of our online shop (https://help.shopify.com/en/manual/checkout-settings/tips) is great!

Trinkgeld.png

 

However, I cannot find how to access this tipping information afterwards. I looked in the Liquid reference: https://shopify.dev/docs/themes/liquid/reference/objects/ but came up empty handed. I would like to reference it in our invoices that we create using the Order Printer app (https://apps.shopify.com/order-printer). 

 

Who can help here? 

 

 

packula
Tourist
4 1 2

This is an accepted solution.

Update: I found out that the tip is handled as a line item in the order. 

So I am currently filtering for it like this:

{% for line_item in line_items %}
     {% if line_item.title == "Tip" %}
          do something with the tip
     {% endif %}
{% endfor %}

This is quite counterintuitive, since I would expect the tip to be handled as an order attribute or perhaps transaction.

Hope it helps for others!

jaspersibayan
Tourist
3 0 0

This doesn't work for me.

No tip included in the line_items list.

Does it still work for you right now?

 

0 Likes
packula
Tourist
4 1 2

Yes, it still works for me. 

I activated tipping via the Settings menu, Checkout options. And built the invoice template in the Order Printer app.

 

  {% for line_item in line_items %}
   {% if line_item.title == "Tip" %}
    <tr>
      <td>Tip:</td>
      <td>{{ line_item.price | money }}</td>
    </tr>
   {% endif %}
  {% endfor %}

 

 

0 Likes
jaspersibayan
Tourist
3 0 0

Yes, I activated the tipping in the Checkout Settings.

I'm accessing line_items from the order status page via the custom script.

I am able to get product items but the tip is not included.

 

0 Likes

I'm able to get to the tip amount to show this way in order printer, but haven't been able to get to it work in email confirmations. Here's the basic code I'm using there:

{% for line in line_items %}
   {% if line.title == "Tip" %}
      <p>Tip =  {{ line.price | money }}</p>
   {% endif %}
{% endfor %}

This seems to follow the notification variables reference doc. I can't use contains instead of == because we do selll actual items for which the title contains the word "Tip". Is there a different way I could filter to get only the gratuity line item? Like a product type? (And if so, why does == work in order printer but not email confirmation?)

Without a tip line item, our order confirmation emails don't show completely how the grand total is arrived at. Example, in which a customer left a $4.59 tip:

Screen Shot 2021-03-03 at 3.39.46 PM.png

Thanks for any help!

0 Likes

Another forum post had the answer. Not in Shopify documentation of the order object or notification email variables, but I've tested and it works for me. The object that displays tip amount in an email confirmation is:

{{ order.total_tip | money }}

 

jaspersibayan
Tourist
3 0 0

Thanks. It worked!

0 Likes