Class: Spree::Api::V2::Storefront::OrderPromotionsController

Inherits:
UserPromotionController show all
Defined in:
app/controllers/spree/api/v2/storefront/order_promotions_controller.rb

Instance Method Summary collapse

Methods inherited from UserPromotionController

#collection

Instance Method Details

#indexObject



10
11
12
13
14
15
16
17
18
# File 'app/controllers/spree/api/v2/storefront/order_promotions_controller.rb', line 10

def index
  spree_authorize! :update, @spree_current_order, @order_token

  eligible_promotions = spree_current_user.promotions.active.order(:expires_at).filter do |promotion|
    promotion.eligible?(@spree_current_order)
  end

  render_serialized_payload { serialize_collection(eligible_promotions) }
end