Skip to content

Commit

Permalink
Add condition for order refund payments
Browse files Browse the repository at this point in the history
  • Loading branch information
bartek-sek committed Jan 10, 2025
1 parent 90a81fc commit 90c8a11
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
3 changes: 3 additions & 0 deletions config/twig_hooks/admin/order/show.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ sylius_twig_hooks:
priority: 0

'sylius_admin.order.show.content.sections#left':
payments:
template: '@SyliusRefundPlugin/admin/order/content/sections/payments.html.twig'
priority: 100
credit_memos:
template: '@SyliusRefundPlugin/admin/order/content/sections/credit_memos.html.twig'
priority: 50
Expand Down
6 changes: 6 additions & 0 deletions templates/admin/order/content/sections/payments.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% set order = hookable_metadata.context.resource %}
{% set refund_payments = get_all_refund_payments_by_order(order) %}

<div class="card mb-3" {{ sylius_test_html_attribute('payments') }}>
{% hook 'payments' with { refund_payments } %}
</div>
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<div class="card-header">
{% hook 'refund_header' %}
</div>
{% set refund_payments = hookable_metadata.context.refund_payments %}

{% if refund_payments|length > 0 %}
<div class="card-header border-top">
{% hook 'refund_header' %}
</div>
{% endif %}
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
{% set order = hookable_metadata.context.resource %}
{% set refund_payments = get_all_refund_payments_by_order(order) %}
{% set refund_payments = hookable_metadata.context.refund_payments %}

<div class="py-3">
{% if order.hasPayments %}
{% if refund_payments|length > 0 %}
<div class="py-3">
<div class="table-responsive">
<table class="table table-vcenter table-borderless table-sm card-table">
<tbody>
{% for refund_payment in refund_payments %}
<tr {{ sylius_test_html_attribute('refund') }}>
{% hook 'refund_item' with { resource: order, refund_payment } %}
{% hook 'refund_item' with { refund_payment } %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<span class="px-3 text-secondary italic" {{ sylius_test_html_attribute('no-payments') }}>{{ 'sylius.ui.no_payments'|trans }}</span>
{% endif %}
</div>
</div>
{% endif %}

0 comments on commit 90c8a11

Please sign in to comment.