Sha256: c7a54f96a02a737d9af92ea10cbb13733ff2dab16f0d811d3060681400b1cd91

Contents?: true

Size: 573 Bytes

Versions: 2

Compression:

Stored size: 573 Bytes

Contents

module Spree
  module Orders
    class FindCurrent
      include Spree::Orders::FinderHelper

      def execute(user:, store:, **params)
        params = params.merge(store_id: store.id)

        order = incomplete_orders.find_by(params)

        return order unless order.nil?
        return if user.nil?

        incomplete_orders.order(created_at: :desc).find_by(store: store, user: user, currency: params[:currency])
      end

      private

      def incomplete_orders
        Spree::Order.incomplete.not_canceled.includes(order_includes)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_core-4.10.1 app/finders/spree/orders/find_current.rb
spree_core-4.10.0 app/finders/spree/orders/find_current.rb