mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Rename method OrderSyncer#update_ship_address_for
This method has become only a small part of the logic for updating the order's ship address. This no longer follows the method naming convention within OrderSyncer where update_*_for describes almost the complete logic for updating the association. This is renamed in preparation for extraction of the complete update logic for ship_address. The new method will be named update_ship_address_for.
This commit is contained in:
@@ -38,7 +38,7 @@ class OrderSyncer
|
||||
# are ignored or not.
|
||||
pickup_to_delivery = force_ship_address_required?(order)
|
||||
if !pickup_to_delivery || order.shipment.present?
|
||||
update_ship_address_for(order) if (ship_address.changes.keys & relevant_address_attrs).any?
|
||||
save_ship_address_in_order(order) if (ship_address.changes.keys & relevant_address_attrs).any?
|
||||
end
|
||||
if !pickup_to_delivery || order.shipment.blank?
|
||||
order.updater.__send__(:shipping_address_from_distributor)
|
||||
@@ -59,11 +59,6 @@ class OrderSyncer
|
||||
order.bill_address.update_attributes(bill_address.attributes.slice(*relevant_address_attrs))
|
||||
end
|
||||
|
||||
def update_ship_address_for(order)
|
||||
return unless ship_address_updatable?(order)
|
||||
order.ship_address.update_attributes(ship_address.attributes.slice(*relevant_address_attrs))
|
||||
end
|
||||
|
||||
def update_payment_for(order)
|
||||
payment = order.payments.with_state('checkout').where(payment_method_id: payment_method_id_was).last
|
||||
if payment
|
||||
@@ -116,6 +111,11 @@ class OrderSyncer
|
||||
end
|
||||
end
|
||||
|
||||
def save_ship_address_in_order(order)
|
||||
return unless ship_address_updatable?(order)
|
||||
order.ship_address.update_attributes(ship_address.attributes.slice(*relevant_address_attrs))
|
||||
end
|
||||
|
||||
def pending_shipment_with?(order, shipping_method_id)
|
||||
return false unless order.shipment.present? && order.shipment.state == "pending"
|
||||
order.shipping_method.id == shipping_method_id
|
||||
|
||||
Reference in New Issue
Block a user