Class: Workarea::Storefront::CartItemsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Workarea::Storefront::CartItemsController
- Includes:
- CheckInventory, CheckPricingOverride
- Defined in:
- app/controllers/workarea/storefront/cart_items_controller.rb
Instance Method Summary collapse
Methods included from CheckPricingOverride
Methods included from CheckInventory
Methods inherited from ApplicationController
#current_layout, #current_user_info, #health_check, #layout_content
Methods included from OrderLookup
Methods included from UserActivity
#current_user_activity_id, #user_activity
Methods included from CurrentCheckout
#clear_current_order, #completed_order, #completed_order=, #current_checkout, #current_order, #current_order=, #current_shipping, #current_shippings
Methods included from HttpCaching
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 # TODO: for v4, use AddItemToCart for this. 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, ) @item = OrderItemViewModel.wrap( current_order.items.find_existing( item_params[:sku], item_params[:customizations].to_h ), ) 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 |