Class: Workarea::Api::Storefront::CartItemsController
- Inherits:
-
ApplicationController
- Object
- Workarea::ApplicationController
- ApplicationController
- Workarea::Api::Storefront::CartItemsController
- Includes:
- CurrentCheckout
- Defined in:
- app/controllers/workarea/api/storefront/cart_items_controller.rb
Instance Method Summary collapse
Methods included from CurrentCheckout
#current_checkout, #current_order
Methods inherited from ApplicationController
#assert_current_metrics_id, #cache_page, #skip_session
Methods included from Authentication
#authentication?, #current_user, find_user
Instance Method Details
#create ⇒ Object
10 11 12 13 14 |
# File 'app/controllers/workarea/api/storefront/cart_items_controller.rb', line 10 def create current_order.add_item(item_params.to_h.merge(item_details.to_h)) update_cart render_item end |
#destroy ⇒ Object
25 26 27 28 29 |
# File 'app/controllers/workarea/api/storefront/cart_items_controller.rb', line 25 def destroy current_order.remove_item(params[:id]) update_cart render_item end |
#update ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'app/controllers/workarea/api/storefront/cart_items_controller.rb', line 16 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) update_cart render_item end |