Payment due date in email only shows when "upon receipt" not when Net7 or custom date

gRaViJa
Visitor
1 0 0

In my email to customers who are able to pay for their order later, I have added the following code to show when they should pay:

{% assign due_date = payment_terms.next_payment.due_at | default: nil %}

{% if payment_terms.type == 'receipt' and due_date == nil %}
   {% assign due_date = 'now' %}
{% endif %}

<h2>Payment of {{ order.total_outstanding | money }} is due {{ due_date | date: format: 'date' }}</h2>

 

However, If i choose Net7, Net15, Net30 or pick a custom date. This code shows no date at all?

 

I tried adding different variables that I though should work in emails like {{ payment_terms.next_payment.due_at}}, {{ payment_terms.current_payment.due_at }} or even {{ payment_terms.payment_terms_name }} just to see if the correct payment term is used (should return Net7 etc.), but they all return nothing?

 

How can i edit the above code so that it not only shows the correct date for upon receipt but also for net7, net15, net30 and custom dates?

 

Thank you!

 

Replies 2 (2)

seangerke
Excursionist
47 0 1

Hi I know this is old, but I have been looking for the same thing. I found this:

 

The payment_terms filter must be used on the form object within a product form or cart form.

 

{{ form | payment_terms }}

 

https://shopify.dev/api/liquid/filters/payment_terms

 

 

mhouck
Shopify Partner
1 0 0

If anyone is stumbling upon this post due to the Shopify non-functional help guide (located here: https://help.shopify.com/en/manual/orders/notifications/edit-template#payment-terms), here's a version of the code that works for me right now.

 

{% if payment_terms.type == 'receipt' and payment_terms.next_payment.due_at == nil %}
  {% assign due_date = 'now' %}
{% else %}
  {% assign due_date = payment_terms.next_payment.due_at | default: nil %}
{% endif %}

{% if payment_terms.type == 'fulfillment' and payment_terms.next_payment.due_at == nil %}
  <h2>Payment of {{ order.total_outstanding | money }} is due on fulfillment</h2>
{% else %}
  <h2>Payment of {{ order.total_outstanding | money }} is due on {{ due_date | date: '%d/%m/%Y' }}</h2>
{% endif %}

 

To edit the date format, just edit '%d/%m/%Y' to whichever format you would like. Here's Shopify's reference for dates: https://shopify.dev/docs/api/liquid/filters/date