Introduce "zero priced orders" in admin order payments UI and helper

This commit is contained in:
Matt-Yorkley
2023-06-02 20:31:49 +01:00
parent bd29a9acde
commit 1cd38c957d
2 changed files with 6 additions and 3 deletions

View File

@@ -4,12 +4,13 @@ module Spree
module PaymentMethodsHelper
def payment_method(payment)
# hack to allow us to retrieve the name of a "deleted" payment method
id = payment.payment_method_id
return unless (id = payment.payment_method_id)
Spree::PaymentMethod.find_with_destroyed(id)
end
def payment_method_name(payment)
payment_method(payment).name
payment_method(payment)&.name
end
end
end

View File

@@ -11,7 +11,9 @@
%tr{class: "#{cycle('odd', 'even')}"}
%td= pretty_time(payment.created_at)
%td.align-center= payment.display_amount.to_html
%td.align-center= link_to payment_method_name(payment), spree.admin_order_payment_path(@order, payment)
%td.align-center
- if payment.payment_method_id
= link_to payment_method_name(payment), spree.admin_order_payment_path(@order, payment)
%td.align-center
%span{class: "state #{payment.state}"}= t(payment.state, scope: "spree.payment_states", default: payment.state.capitalize)
%td.actions