Class: Gemgento::CartController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Gemgento::CartController
- Defined in:
- app/controllers/gemgento/cart_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/gemgento/cart_controller.rb', line 13 def create product = Product.find(params[:line_item][:product_id]) if !@quote.products.include? product # make sure the product isn't in the cart @line_item = LineItem.new(line_item_params) @line_item.itemizable = @quote respond @line_item.save else # update the appropriate line_item if it is @line_item = @quote.line_items.find_by(product: product) params[:line_item][:qty_ordered] = params[:line_item][:qty_ordered].to_f + @line_item.qty_ordered # increase existing qty by requested qty respond @line_item.update(line_item_params) end end |
#destroy ⇒ Object
35 36 37 |
# File 'app/controllers/gemgento/cart_controller.rb', line 35 def destroy respond @line_item.destroy end |
#mini_bag ⇒ Object
39 40 41 |
# File 'app/controllers/gemgento/cart_controller.rb', line 39 def mini_bag render partial: 'gemgento/shared/mini_bag' end |
#show ⇒ Object
9 10 11 |
# File 'app/controllers/gemgento/cart_controller.rb', line 9 def show respond_with @quote end |
#update ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/controllers/gemgento/cart_controller.rb', line 27 def update if params[:line_item][:qty_ordered].to_f > 0 respond @line_item.update(line_item_params) else respond @line_item.destroy end end |