From 6d7b250e7a045aa27260353c05011897f9344b54 Mon Sep 17 00:00:00 2001 From: Victor Vasiloi Date: Tue, 7 May 2024 14:25:04 +0200 Subject: [PATCH 1/2] Add fallback to last payment when there is no completed payment --- src/Resources/views/_paymentMethod.html.twig | 24 ++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Resources/views/_paymentMethod.html.twig b/src/Resources/views/_paymentMethod.html.twig index c76631bc..ce814f30 100644 --- a/src/Resources/views/_paymentMethod.html.twig +++ b/src/Resources/views/_paymentMethod.html.twig @@ -1,11 +1,17 @@ -{% if order.payments.first() %} - {% set completed = constant('Sylius\\Component\\Core\\Model\\PaymentInterface::STATE_COMPLETED') %} - {% set original_payment_method = order.lastPayment(completed).method %} - +{% set completed = constant('Sylius\\Component\\Core\\Model\\PaymentInterface::STATE_COMPLETED') %} +{% set last_completed_payment = order.lastPayment(completed) %} +{% set lat_payment = order.lastPayment %} +{% if last_completed_payment is not null %} + {% set original_payment_method = last_completed_payment.method %} +{% elseif last_payment is not null %} + {% set original_payment_method = last_payment.method %} +{% else %} + {% set original_payment_method = null %} +{% endif %} -
-
- {{ sylius_template_event('sylius_refund.admin.order.refund.form.payment_method', _context) }} -
+ +
+
+ {{ sylius_template_event('sylius_refund.admin.order.refund.form.payment_method', _context) }}
-{% endif %} +
From ca8c3e905e71d175d6e9844934ed88191c4eb45f Mon Sep 17 00:00:00 2001 From: Victor Vasiloi Date: Tue, 7 May 2024 14:28:21 +0200 Subject: [PATCH 2/2] Avoid error when original payment method is not available --- .../views/Order/Admin/Refund/_paymentMethod.html.twig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Resources/views/Order/Admin/Refund/_paymentMethod.html.twig b/src/Resources/views/Order/Admin/Refund/_paymentMethod.html.twig index 213bdd6b..a33ba814 100644 --- a/src/Resources/views/Order/Admin/Refund/_paymentMethod.html.twig +++ b/src/Resources/views/Order/Admin/Refund/_paymentMethod.html.twig @@ -3,11 +3,14 @@ - {{ 'sylius.ui.original_payment_method'|trans }}: {{ original_payment_method }} + {% if original_payment_method is not null %} + {{ 'sylius.ui.original_payment_method'|trans }}: {{ original_payment_method }} + {% endif %}