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



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

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



36
37
38
39
# File 'app/controllers/comable/carts_controller.rb', line 36

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

#destroyObject



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

def destroy
  cart_item = find_cart_item
  return redirect_by_product_not_found unless cart_item

  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



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

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