Answers.Body: <p>You get the related transactions for an order with</p>
  
  <p><code>order.transactions</code></p>
  
  <p>So you can loop over the transactions like so:</p>
  
  <pre><code>{% for transaction in order.transactions %}
    {{ transaction.type|title }}
    {{ transaction.status|title }}
    {{ transaction.amount|currency(transaction.currency) }} ({{ transaction.currency }})
    {{ transaction.paymentMethod.name }}
    {{ transaction.dateUpdated|date }} // could also format to get the time
  {% endfor %}
  </code></pre>
  
  <p>The transaction 'type' column can hold the following values:</p>
  
  <p><code>authorize, capture, purchase, refund</code></p>
  
  <p>The transaction 'status' column can hold the following values:</p>
  
  <p><code>pending, direct, success, failed</code></p>
  
  <p>Some of those transaction types have a 'parent' transaction, for example, if you authorized a credit card, you would have a authorize transaction. When you capture that authorization you get a capture transactions whose parent is the authorize transaction.</p>
  
  <pre><code>{{ transaction.type }} // could return 'refund'
  {% set parent = transaction.parent %}
  {{ parent.type }} // could return 'purchase' or 'capture'
  </code></pre>
  
  <p>Let me know if you have further questions and I will improve the answer.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-23T01:51:20.103Z
Answers.LastActivityDate: 2016-07-23T01:51:20.103Z
Answers.UserDisplayName: Luke Holder
Body: <p>What’s the best way to check if an order has been refunded in a template?</p>
  
  <p>For example, you may want to: </p>
  
  <ul>
  <li>Add a message to the order/invoice template if a refund has been successful.</li>
  <li>Determine the status of the refund; perhaps displaying a different message if the status is not yet <code>success</code>.</li>
  <li>Show the time of refund.</li>
  </ul>
  
Tags: <templating><plugin-craftcommerce>
Title: Check if an order has been refunded in a template?
ThreadText: # Check if an order has been refunded in a template?
  
  (Asked by: username_0 on 2016-07-22)
  
  What’s the best way to check if an order has been refunded in a template?
  
  For example, you may want to:
  
  * Add a message to the order/invoice template if a refund has been successful.
  * Determine the status of the refund; perhaps displaying a different message if the status is not yet `success`.
  * Show the time of refund.
  
  **Tags:** templating, plugin-craftcommerce
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-07-23. Score: 7 | Accepted answer
  
  You get the related transactions for an order with
  
  `order.transactions`
  
  So you can loop over the transactions like so:
  
  ```
  {% for transaction in order.transactions %}
    {{ transaction.type|title }}
    {{ transaction.status|title }}
    {{ transaction.amount|currency(transaction.currency) }} ({{ transaction.currency }})
    {{ transaction.paymentMethod.name }}
    {{ transaction.dateUpdated|date }} // could also format to get the time
  {% endfor %}
  
  ```
  
  The transaction 'type' column can hold the following values:
  
  `authorize, capture, purchase, refund`
  
  The transaction 'status' column can hold the following values:
  
  `pending, direct, success, failed`
  
  Some of those transaction types have a 'parent' transaction, for example, if you authorized a credit card, you would have a authorize transaction. When you capture that authorization you get a capture transactions whose parent is the authorize transaction.
  
  ```
  {{ transaction.type }} // could return 'refund'
  {% set parent = transaction.parent %}
  {{ parent.type }} // could return 'purchase' or 'capture'
  
  ```
  
  Let me know if you have further questions and I will improve the answer.
  
  
  ---
  
  