Class: Comable::CartsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#set_view_path

Instance Method Details

#addObject



7
8
9
10
11
12
13
14
# File 'app/controllers/comable/carts_controller.rb', line 7

def add
  if current_comable_user.add_cart_item(@cart_item, cart_item_options)
    redirect_to comable.cart_path, notice: Comable.t('carts.added')
  else
    flash.now[:alert] = Comable.t('carts.invalid')
    render :show
  end
end

#checkoutObject



34
35
36
37
# File 'app/controllers/comable/carts_controller.rb', line 34

def checkout
  current_order.next_state if current_order.state?(:cart)
  redirect_to comable.next_order_path(state: :confirm)
end

#destroyObject



25
26
27
28
29
30
31
32
# File 'app/controllers/comable/carts_controller.rb', line 25

def destroy
  if current_comable_user.reset_cart_item(@cart_item)
    redirect_to comable.cart_path, notice: Comable.t('carts.updated')
  else
    flash.now[:alert] = Comable.t('carts.invalid')
    render :show
  end
end

#updateObject



16
17
18
19
20
21
22
23
# File 'app/controllers/comable/carts_controller.rb', line 16

def update
  if current_comable_user.reset_cart_item(@cart_item, cart_item_options)
    redirect_to comable.cart_path, notice: Comable.t('carts.updated')
  else
    flash.now[:alert] = Comable.t('carts.invalid')
    render :show
  end
end