Class: Spree::MergeableOrdersFinder
- Inherits:
-
Object
- Object
- Spree::MergeableOrdersFinder
- Defined in:
- app/models/spree/mergeable_orders_finder.rb
Overview
Finds orders to merge when a user logs in.
Configurable via Spree::Config#mergeable_orders_finder_class. Default behavior finds all incomplete orders from the same store.
Instance Method Summary collapse
-
#call ⇒ ActiveRecord::Relation<Spree::Order>
Returns orders that should be merged into the current order.
-
#initialize(context:) ⇒ MergeableOrdersFinder
constructor
A new instance of MergeableOrdersFinder.
Constructor Details
#initialize(context:) ⇒ MergeableOrdersFinder
Returns a new instance of MergeableOrdersFinder.
28 29 30 31 32 |
# File 'app/models/spree/mergeable_orders_finder.rb', line 28 def initialize(context:) @user = context.spree_current_user @store = context.current_store @current_order = context.current_order end |
Instance Method Details
#call ⇒ ActiveRecord::Relation<Spree::Order>
Returns orders that should be merged into the current order
same store
38 39 40 41 42 |
# File 'app/models/spree/mergeable_orders_finder.rb', line 38 def call return Spree::Order.none unless @user && @current_order @user.orders.by_store(@store).incomplete.where(frontend_viewable: true).where.not(id: @current_order.id) end |