Class: Locomotive::Ecommerce::PurchaseController

Inherits:
ApplicationController show all
Defined in:
app/controllers/locomotive/ecommerce/purchase_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_user!, #locomotive_user?

Methods included from EcommerceHelper

#as_currency, #current_user

Methods included from InventoryInterface

included

Methods included from EcommerceUrlHelper

#add_to_cart_path, #cart_path, #cart_update_path, #checkout_index_path, #checkout_path, #checkout_update_path, #confirm_order_path, #post_checkout_path, #purchases_path, #remove_from_cart_path

Methods included from EcommerceCartHelper

#current_user_cart

Instance Method Details

#createObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/locomotive/ecommerce/purchase_controller.rb', line 8

def create
  @purchase = current_user_cart(self).purchase
  @purchase.shipping_info = params[:shipping_info]
  @purchase.shipping_method = params[:shipping_method]
  if @purchase.save
    redirect_to confirm_order_path
    return
  elsif @purchase.errors.any?
    flash_ar = []
    @purchase.errors.full_messages.each { |msg| flash_ar << msg }
    flash[:error] = flash_ar.join(', ')
  end

  redirect_to checkout_path
end