Class: ShoppingCart::CheckoutController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ShoppingCart::CheckoutController
- Defined in:
- app/controllers/shopping_cart/checkout_controller.rb
Instance Method Summary collapse
- #add_address ⇒ Object
- #add_payment ⇒ Object
- #add_shipping ⇒ Object
- #create ⇒ Object
- #payment ⇒ Object
- #shipping ⇒ Object
Instance Method Details
#add_address ⇒ Object
30 31 32 33 34 |
# File 'app/controllers/shopping_cart/checkout_controller.rb', line 30 def add_address return render :index unless @address.update(address_params) @current_order.update(step: 0) unless @current_order.step redirect_to @steps ? "/shopping_cart/checkout/#{@steps[0]}" : '/shopping_cart/checkout/complete' end |
#add_payment ⇒ Object
47 48 49 50 51 |
# File 'app/controllers/shopping_cart/checkout_controller.rb', line 47 def add_payment return render :payment unless @credit_card.update(payment_params) update_step(:payment) redirect_by_step(:payment) end |
#add_shipping ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/shopping_cart/checkout_controller.rb', line 36 def add_shipping unless params[:id] flash[:alert] = t('shopping_cart.choose_shipping') return redirect_to :back end shipping = Shipping.find(params[:id]) @current_order.update(shipping: shipping) update_step(:shipping) redirect_by_step(:shipping) end |
#create ⇒ Object
23 24 25 26 27 28 |
# File 'app/controllers/shopping_cart/checkout_controller.rb', line 23 def create @current_order.place_order @current_order.update(completed_at: Time.now, total_price: @current_order.total_price) flash[:notice] = t('shopping_cart.order_placed') redirect_to '/' end |
#payment ⇒ Object
19 20 21 |
# File 'app/controllers/shopping_cart/checkout_controller.rb', line 19 def payment redirect_to :back unless check_step(:payment) end |
#shipping ⇒ Object
14 15 16 17 |
# File 'app/controllers/shopping_cart/checkout_controller.rb', line 14 def shipping redirect_to :back unless check_step(:shipping) @shippings = Shipping.all end |