mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Move loading of saved cards out of checkout concern
This commit is contained in:
@@ -14,7 +14,7 @@ module CheckoutCallbacks
|
||||
prepend_before_action :require_order_cycle
|
||||
prepend_before_action :require_distributor_chosen
|
||||
|
||||
before_action :load_order, :associate_user, :load_saved_addresses, :load_saved_credit_cards
|
||||
before_action :load_order, :associate_user, :load_saved_addresses
|
||||
before_action :load_shipping_methods, if: -> { params[:step] == "details" }
|
||||
|
||||
before_action :ensure_order_not_completed
|
||||
@@ -43,11 +43,6 @@ module CheckoutCallbacks
|
||||
@order.ship_address ||= finder.ship_address
|
||||
end
|
||||
|
||||
def load_saved_credit_cards
|
||||
@saved_credit_cards = spree_current_user&.credit_cards&.with_payment_profile.to_a
|
||||
@selected_card = nil
|
||||
end
|
||||
|
||||
def load_shipping_methods
|
||||
@shipping_methods = available_shipping_methods.sort { |a, b| a.name.casecmp(b.name) }
|
||||
end
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
- saved_credit_cards = spree_current_user&.credit_cards&.with_payment_profile.to_a
|
||||
|
||||
%div{"data-controller": "stripe-cards", "data-paymentmethod-id": "#{payment_method.id}" }
|
||||
- if @saved_credit_cards.any?
|
||||
- if saved_credit_cards.any?
|
||||
.checkout-input
|
||||
%label
|
||||
= t('split_checkout.step2.form.stripe.use_saved_card')
|
||||
= select_tag :existing_card_id,
|
||||
options_for_select(stripe_card_options(@saved_credit_cards) + [[t('split_checkout.step2.form.stripe.create_new_card'), ""]], @selected_card),
|
||||
options_for_select(stripe_card_options(saved_credit_cards) + [[t('split_checkout.step2.form.stripe.create_new_card'), ""]], nil),
|
||||
{ "data-action": "change->stripe-cards#onSelectCard", "data-stripe-cards-target": "select" }
|
||||
|
||||
%div{"data-stripe-cards-target": "stripeelements"}
|
||||
.checkout-input
|
||||
- if @saved_credit_cards.none?
|
||||
- if saved_credit_cards.none?
|
||||
%label
|
||||
= t('split_checkout.step2.form.stripe.use_new_card')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user