Sha256: 43dcac67db4a046e4ce3d6a07b891090e3c644223d40e485747fc096b011edea

Contents?: true

Size: 748 Bytes

Versions: 29

Compression:

Stored size: 748 Bytes

Contents

module Spree
  module Api
    module V2
      module CouponCodesHelper
        def select_coupon_codes
          params[:coupon_code].present? ? [params[:coupon_code]] : check_coupon_codes
        end

        def check_coupon_codes
          spree_current_order.promotions.coupons.map(&:code)
        end

        def select_error(coupon_codes)
          result = coupon_handler.new(spree_current_order).remove(coupon_codes.first)
          result.error
        end

        def select_errors(coupon_codes)
          results = []
          coupon_codes.each do |coupon_code|
            results << coupon_handler.new(spree_current_order).remove(coupon_code)
          end

          results.select(&:error)
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 3 rubygems

Version Path
spree_api-4.10.1 app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb
spree_api-4.10.0 app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb
spree_api-4.9.0 app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb
spree_api-4.8.3 app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb
spree_api-4.8.2 app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb
spree_api-4.7.3 app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb
spree_api-4.6.6 app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb
spree_api-4.5.5 app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb
spree_api-4.4.1 app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb
spree_api-4.5.4 app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb
spree_api-4.6.5 app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb
spree_api-4.7.2 app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb
spree_api-4.7.1 app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb
spree_api-4.6.4 app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb
spree_api-4.7.0 app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb
spree_api-4.6.3 app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb
spree_api-4.6.2 app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb
spree_api-4.6.1 app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb
spree_api-4.6.0 app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb
spree_api-4.5.3 app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb