Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Sailias/885489 to your computer and use it in GitHub Desktop.
Save Sailias/885489 to your computer and use it in GitHub Desktop.
# AJAX request: This adds line items to cart.
def add_line_item_to_cart
#Get current_cart object
current_cart
quantity = params[:quantity].to_i
id = params[:id].to_i
line_item = LineItem.find_or_create_by_cartridge_id_and_cart_id(id, current_cart.id)
line_item.quantity = line_item.quantity.to_i + quantity
line_item.save
render :text => current_cart.line_items.count.to_s
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment