Remove useless customer loading and clarify name

The method `associate_customer` only loads a customer but doesn't
actually associate one. So the deleted line doesn't have any effect.

The intention was to reset the customer after switching shops but the
before_validation logic on the order model takes care of that already.

I'm renaming this private method here for clarity.
This commit is contained in:
Maikel Linke
2022-09-14 15:17:00 +10:00
committed by Konrad
parent 93da64f466
commit 5fefd3b14b
2 changed files with 2 additions and 3 deletions

View File

@@ -717,7 +717,7 @@ module Spree
(user&.email || email)&.downcase
end
def associate_customer
def find_customer
return customer if customer.present?
Customer.of(distributor).find_by(email: email_for_customer)
@@ -738,7 +738,7 @@ module Spree
end
def ensure_customer
self.customer = associate_customer || create_customer
self.customer = find_customer || create_customer
end
def update_adjustment!(adjustment)

View File

@@ -30,7 +30,6 @@ class OrderCartReset
return unless current_user
order.associate_user!(current_user) if order.user.blank? || order.email.blank?
order.__send__(:associate_customer) if order.customer.nil? # Only associates existing customers
end
def reset_order_cycle(current_customer)