Add new 'Checkout options' step to the edit order cycle form so people can attach shipping methods

This commit is contained in:
Cillian O'Ruanaidh
2022-06-08 21:15:38 +01:00
committed by Filipe
parent 1e817af5aa
commit 855ec1a708
16 changed files with 499 additions and 8 deletions

View File

@@ -156,6 +156,23 @@ class OrderCycle < ApplicationRecord
]
end
def attachable_payment_methods
Spree::PaymentMethod.available(:both).
joins("INNER JOIN distributors_payment_methods
ON payment_method_id = spree_payment_methods.id").
where("distributor_id IN (?)", distributor_ids).
distinct
end
def attachable_shipping_methods
return Spree::ShippingMethod.none if simple? || !shipping_methods_customisable?
Spree::ShippingMethod.frontend.
joins(:distributor_shipping_methods).
where("distributor_id IN (?)", distributor_ids).
distinct
end
def clone!
oc = dup
oc.name = I18n.t("models.order_cycle.cloned_order_cycle_name", order_cycle: oc.name)

View File

@@ -243,7 +243,9 @@ module Spree
end
def add_order_cycle_management_abilities(user)
can [:admin, :index, :read, :edit, :update, :incoming, :outgoing], OrderCycle do |order_cycle|
can [
:admin, :index, :read, :edit, :update, :incoming, :outgoing, :checkout_options
], OrderCycle do |order_cycle|
OrderCycle.visible_by(user).include? order_cycle
end
can [:admin, :index, :create], Schedule