Created
January 7, 2012 22:15
-
-
Save rthbound/1576241 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # If the cart already has this product in it, | |
| if existing_cart_product = cart.cart_products.find_by_part_number_id(@cart_product.part_number_id) | |
| # And if the current quantity in cart exceeds or equals the available quantity | |
| if existing_cart_product.quantity >= available_quantity | |
| # Set the quantity in cart to the available quantity, and add 0 of the requested quantity to the cart. | |
| existing_cart_product.update_attributes(:quantity => available_quantity) | |
| @addl_msg << "Quantity has been depleted for this item. There are #{existing_cart_product.quantity} units in your cart. " | |
| @cart_product.quantity = 0 | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment