Class: Admin::LineItemsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/admin/line_items_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

override r_c create action as we want to use order#add_variant instead of creating line_item



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/admin/line_items_controller.rb', line 12

def create
  load_object
  variant = Variant.find(params[:line_item][:variant_id])

  before :create

  @order.add_variant(variant, params[:line_item][:quantity].to_i)

  if @order.save
    after :create
    set_flash :create
    response_for :create
  else
    after :create_fails
    set_flash :create_fails
    response_for :create_fails
  end

end