Class: Workarea::Storefront::CartItemsController
Instance Method Summary
collapse
#check_pricing_override
#check_inventory
#current_layout, #current_user_info, #health_check, #layout_content
#lookup_order, #lookup_order=
#clear_current_order, #completed_order, #completed_order=, #current_checkout, #current_order, #current_order=, #current_shipping, #current_shippings, #logout
Instance Method Details
#create ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/controllers/workarea/storefront/cart_items_controller.rb', line 13
def create
if current_order.add_item(item_params.to_h.merge(item_details.to_h))
check_inventory
Pricing.perform(current_order, current_shippings)
@cart = CartViewModel.new(current_order, view_model_options)
@item = OrderItemViewModel.wrap(
current_order.items.find_existing(
item_params[:sku],
item_params[:customizations].to_h
),
view_model_options
)
end
end
|
#destroy ⇒ Object
40
41
42
43
44
|
# File 'app/controllers/workarea/storefront/cart_items_controller.rb', line 40
def destroy
current_order.remove_item(params[:id])
flash[:success] = t('workarea.storefront.flash_messages.cart_item_removed')
redirect_to cart_path
end
|
#update ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'app/controllers/workarea/storefront/cart_items_controller.rb', line 31
def update
update_params = params.permit(:sku, :quantity).to_h
update_params.merge!(item_details.to_h) if params[:sku].present?
current_order.update_item(params[:id], update_params)
flash[:success] = t('workarea.storefront.flash_messages.cart_item_updated')
redirect_to cart_path
end
|