Created
January 24, 2013 03:37
-
-
Save pzaich/4617430 to your computer and use it in GitHub Desktop.
opportunity for a anonymous block?
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
| def under_minimum_order_size?(min = minimum_order_size, total = total_quantity_in_instance) | |
| errors.add(:under_min, "Total quantity must be over #{min}") if total < min | |
| end | |
| def total_quantity_in_instance(total = 0) | |
| self.custom_sizes.each do |custom_size| | |
| total += custom_size.quantity.to_i | |
| end | |
| total | |
| end | |
| def minimum_order_size(min = 12) | |
| min = 25 if self.custom_product.parent_product_type_name == "swim cap" | |
| min | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment