Sha256: 2a70242afa00469f84ce52bf4589b1918d5f0a122af56701e3c9fc89eaf711a9

Contents?: true

Size: 856 Bytes

Versions: 72

Compression:

Stored size: 856 Bytes

Contents

# frozen_string_literal: true

module Spree
  class CouponCodesController < Spree::StoreController
    before_action :load_order, only: :create
    around_action :lock_order, only: :create

    def create
      authorize! :update, @order, cookies.signed[:guest_token]

      if params[:coupon_code].present?
        @order.coupon_code = params[:coupon_code]
        handler = PromotionHandler::Coupon.new(@order).apply

        respond_with(@order) do |format|
          format.html do
            if handler.successful?
              flash[:success] = handler.success
              redirect_to cart_path
            else
              flash.now[:error] = handler.error
              render 'spree/coupon_codes/new'
            end
          end
        end
      end
    end

    private

    def load_order
      @order = current_order
    end
  end
end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
solidus_frontend-4.0.0 app/controllers/spree/coupon_codes_controller.rb
solidus_frontend-4.0.0.dev app/controllers/spree/coupon_codes_controller.rb
solidus_frontend-3.4.0 app/controllers/spree/coupon_codes_controller.rb
solidus_frontend-3.1.9 app/controllers/spree/coupon_codes_controller.rb
solidus_frontend-3.4.0.dev app/controllers/spree/coupon_codes_controller.rb
solidus_frontend-3.3.0 app/controllers/spree/coupon_codes_controller.rb
solidus_frontend-3.2.5 app/controllers/spree/coupon_codes_controller.rb
solidus_frontend-3.2.4 app/controllers/spree/coupon_codes_controller.rb
solidus_frontend-3.2.3 app/controllers/spree/coupon_codes_controller.rb
solidus_frontend-3.1.8 app/controllers/spree/coupon_codes_controller.rb
solidus_frontend-3.0.8 app/controllers/spree/coupon_codes_controller.rb
solidus_frontend-3.2.2 app/controllers/spree/coupon_codes_controller.rb
solidus_frontend-3.2.1 app/controllers/spree/coupon_codes_controller.rb
solidus_frontend-3.3.0.alpha app/controllers/spree/coupon_codes_controller.rb
solidus_frontend-3.2.0 app/controllers/spree/coupon_codes_controller.rb
solidus_frontend-3.2.0.alpha app/controllers/spree/coupon_codes_controller.rb
solidus_frontend-3.0.7 app/controllers/spree/coupon_codes_controller.rb
solidus_frontend-2.11.17 app/controllers/spree/coupon_codes_controller.rb
solidus_frontend-3.1.7 app/controllers/spree/coupon_codes_controller.rb
solidus_frontend-2.11.16 app/controllers/spree/coupon_codes_controller.rb