Class: Comable::CartsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/comable/carts_controller.rb

Instance Method Summary collapse

Instance Method Details

#addObject



8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/comable/carts_controller.rb', line 8

def add
  cart_item = Comable::Stock.where(id: params[:stock_id]).first
  cart_item ||= Comable::Product.where(id: params[:product_id]).first
  return redirect_by_product_not_found unless cart_item
  return redirect_by_product_not_found if cart_item.is_a?(Comable::Product) && cart_item.sku?

  current_customer.add_cart_item(cart_item, cart_item_options)

  flash[:notice] = I18n.t('comable.carts.add_product')
  redirect_to cart_path
end

#showObject



5
6
# File 'app/controllers/comable/carts_controller.rb', line 5

def show
end

#updateObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/comable/carts_controller.rb', line 20

def update
  stock = Comable::Stock.where(id: params[:stock_id]).first
  return redirect_by_product_not_found unless stock

  current_customer.reset_cart_item(stock, cart_item_options)

  flash[:notice] = I18n.t('comable.carts.update')
  redirect_to cart_path
end