mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Make Order#address_from_distributor public
This commit is contained in:
@@ -27,7 +27,7 @@ class OrderUpdater < SimpleDelegator
|
||||
def shipping_address_from_distributor
|
||||
return if order.shipping_method.blank? || order.shipping_method.require_ship_address
|
||||
|
||||
order.ship_address = order.__send__(:address_from_distributor)
|
||||
order.ship_address = order.address_from_distributor
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -326,12 +326,6 @@ Spree::Order.class_eval do
|
||||
total.to_f > 0.0 && !skip_payment_for_subscription?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def skip_payment_for_subscription?
|
||||
subscription.present? && order_cycle.orders_close_at.andand > Time.zone.now
|
||||
end
|
||||
|
||||
def address_from_distributor
|
||||
address = distributor.address.clone
|
||||
if bill_address
|
||||
@@ -342,6 +336,12 @@ Spree::Order.class_eval do
|
||||
address
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def skip_payment_for_subscription?
|
||||
subscription.present? && order_cycle.orders_close_at.andand > Time.zone.now
|
||||
end
|
||||
|
||||
def provided_by_order_cycle?(line_item)
|
||||
order_cycle_variants = order_cycle.andand.variants || []
|
||||
order_cycle_variants.include? line_item.variant
|
||||
|
||||
@@ -107,7 +107,7 @@ class OrderSyncer
|
||||
# address on the order matches the shop's address
|
||||
def force_ship_address_required?(order)
|
||||
return false unless shipping_method.require_ship_address?
|
||||
distributor_address = order.__send__(:address_from_distributor)
|
||||
distributor_address = order.address_from_distributor
|
||||
relevant_address_attrs.all? do |attr|
|
||||
order.ship_address[attr] == distributor_address[attr]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user