Sha256: 2258d710c027655367793eb1e05d57943e93d979e5920acc687aa5bfa12ba400

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

Spree::CheckoutController.class_eval do

  #TODO 90% of this method is duplicated code. DRY
  def update
    if params[:order] && params[:order][:coupon_code]
      @order.coupon_code = params[:order][:coupon_code]
      unless status = apply_coupon_code
        respond_with(@order) { |format| format.html { render :edit } }
        return
      end
    end

    if @order.update_attributes(object_params)
      fire_event('spree.checkout.update')

      if @order.next
        state_callback(:after)
      else
        flash[:error] = t(:payment_processing_failed)
        respond_with(@order, :location => checkout_state_path(@order.state))
        return
      end

      if @order.state == 'complete' || @order.completed?
        flash.notice = t(:order_processed_successfully)
        flash[:commerce_tracking] = 'nothing special'
        respond_with(@order, :location => completion_route)
      else
        respond_with(@order, :location => checkout_state_path(@order.state))
      end
    else
      respond_with(@order) { |format| format.html { render :edit } }
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_promo-1.3.5 app/controllers/spree/checkout_controller_decorator.rb