Class: SolidusAdmin::LineItemsController

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

Instance Method Summary collapse

Methods included from ComponentsHelper

#component

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
# File 'app/controllers/solidus_admin/line_items_controller.rb', line 14

def create
  load_order
  variant_id = params.require(:line_item).require(:variant_id)
  @variant = Spree::Variant.find(variant_id)
  @line_item = @order.contents.add(@variant)

  redirect_to order_path(@order), status: :see_other, notice: t('.success')
end

#destroyObject



5
6
7
8
9
10
11
12
# File 'app/controllers/solidus_admin/line_items_controller.rb', line 5

def destroy
  load_order
  load_line_item

  @line_item.destroy!

  redirect_to order_path(@order), status: :see_other, notice: t('.success')
end

#updateObject



23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/solidus_admin/line_items_controller.rb', line 23

def update
  load_order
  load_line_item

  desired_quantity = params[:line_item][:quantity].to_i

  @line_item = @order.contents.add(@line_item.variant, desired_quantity - @line_item.quantity)

  redirect_to order_path(@order), status: :see_other, notice: t('.success')
end