Class: Users::WishListsController

Inherits:
Storefront::ApplicationController
  • Object
show all
Defined in:
app/controllers/workarea/storefront/users/wish_lists_controller.rb

Instance Method Summary collapse

Instance Method Details

#add_itemObject



50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/controllers/workarea/storefront/users/wish_lists_controller.rb', line 50

def add_item
  current_wish_list.add_item(
    product_id,
    sku,
    params[:quantity].to_i,
    OrderItemDetails.find!(sku).to_h,
    customizations.try(:to_h) || {}
  )
  flash[:success] =
    t('workarea.storefront.flash_messages.wish_list_item_added')
  redirect_to users_wish_list_path
end

#create_from_cart_itemObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/workarea/storefront/users/wish_lists_controller.rb', line 34

def create_from_cart_item
  item = current_order.items.find(params[:item_id])
  current_wish_list.add_item(
    item.product_id,
    item.sku,
    item.quantity,
    OrderItemDetails.find!(item.sku).to_h,
    item.customizations
  )
  current_order.remove_item(params[:item_id])

  flash[:success] =
    t('workarea.storefront.flash_messages.item_moved_to_wish_list')
  redirect_to users_wish_list_path
end

#remove_itemObject



63
64
65
66
67
68
# File 'app/controllers/workarea/storefront/users/wish_lists_controller.rb', line 63

def remove_item
  current_wish_list.remove_item(params[:sku])
  flash[:success] =
    t('workarea.storefront.flash_messages.wish_list_item_removed')
  redirect_to users_wish_list_path
end

#showObject



11
12
13
14
15
16
17
# File 'app/controllers/workarea/storefront/users/wish_lists_controller.rb', line 11

def show
  WishList::Pricing.perform(current_wish_list)
  @wish_list = WishListViewModel.new(
    current_wish_list,
    view_model_options
  )
end

#updateObject



19
20
21
22
23
24
# File 'app/controllers/workarea/storefront/users/wish_lists_controller.rb', line 19

def update
  current_wish_list.update_attributes(params.permit(:privacy))
  flash[:success] =
    t('workarea.storefront.flash_messages.wish_list_updated')
  redirect_to users_wish_list_path
end

#update_item_quantityObject



26
27
28
29
30
31
32
# File 'app/controllers/workarea/storefront/users/wish_lists_controller.rb', line 26

def update_item_quantity
  if current_wish_list.update_item_quantity(params[:item_id], params[:quantity].to_i)
    flash[:success] =
      t('workarea.storefront.flash_messages.wish_list_item_updated')
  end
  redirect_to users_wish_list_path
end