Sha256: 6bb3c58b74f01812194c955226a996a05b3aec7ff88a2a53aa27e9851637418c
Contents?: true
Size: 863 Bytes
Versions: 1
Compression:
Stored size: 863 Bytes
Contents
module Redshop module Api class CartsController < ApplicationController def add if AddToCart.new(params[:cart_id], params[:product_id]).call render nothing: true, status: 200 else render nothing: true, status: 404 end end def remove $redis.srem current_user_cart, params[:product_id] redirect_to :back end def count # Parse count name from cart name cart_count_name = CartCountService.new(current_user_cart).send(:parse_cart_count_name) cart_count = $redis.get cart_count_name # Get count if products in the cart > 0, or set 0 count = (cart_count ? cart_count : 0) render text: count, status: 200 end private def current_user_cart "cart_#{session[:guest_id]}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
redshop-0.0.1 | app/controllers/redshop/api/carts_controller.rb |