Sha256: 0a98c5faf821d3e1f5b63e0e0efe6951adfc3c327a49edd63ce5c584c7b5333c

Contents?: true

Size: 1.24 KB

Versions: 16

Compression:

Stored size: 1.24 KB

Contents

Spree::CheckoutController.class_eval do

  #TODO 90% of this method is duplicated code. DRY
  def update
    if @order.update_attributes(object_params)

      fire_event('spree.checkout.update')

      if @order.coupon_code.present?

        if Spree::Promotion.exists?(:code => @order.coupon_code)
          fire_event('spree.checkout.coupon_code_added', :coupon_code => @order.coupon_code)
          # If it doesn't exist, raise an error!
          # Giving them another chance to enter a valid coupon code
        else
          flash[:error] = t(:promotion_not_found)
          render :edit and return
        end
      end

      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

16 entries across 16 versions & 1 rubygems

Version Path
spree_promo-1.0.7 app/controllers/spree/checkout_controller_decorator.rb
spree_promo-1.1.3 app/controllers/spree/checkout_controller_decorator.rb
spree_promo-1.0.6 app/controllers/spree/checkout_controller_decorator.rb
spree_promo-1.1.2 app/controllers/spree/checkout_controller_decorator.rb
spree_promo-1.1.2.rc1 app/controllers/spree/checkout_controller_decorator.rb
spree_promo-1.1.1 app/controllers/spree/checkout_controller_decorator.rb
spree_promo-1.1.0 app/controllers/spree/checkout_controller_decorator.rb
spree_promo-1.0.4 app/controllers/spree/checkout_controller_decorator.rb
spree_promo-1.1.0.rc2 app/controllers/spree/checkout_controller_decorator.rb
spree_promo-1.1.0.rc1 app/controllers/spree/checkout_controller_decorator.rb
spree_promo-1.0.3 app/controllers/spree/checkout_controller_decorator.rb
spree_promo-1.0.2 app/controllers/spree/checkout_controller_decorator.rb
spree_promo-1.0.1 app/controllers/spree/checkout_controller_decorator.rb
spree_promo-1.0.0 app/controllers/spree/checkout_controller_decorator.rb
spree_promo-1.0.0.rc4 app/controllers/spree/checkout_controller_decorator.rb
spree_promo-1.0.0.rc3 app/controllers/spree/checkout_controller_decorator.rb