Created
November 1, 2011 20:48
-
-
Save firebelly/1331856 to your computer and use it in GitHub Desktop.
from the annals of bad old code...
This file contains 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 self.gift_card_total(cart) | |
amount = 0 | |
date = DateTime.new(2010) | |
LineItem.find(:all, :include => [:order], :conditions => ["orders.created_at BETWEEN ? AND ? | |
AND line_items.title = ?", date.beginning_of_year, date.end_of_year, 'Gift Card']).collect{ | |
|item| item.total_price }.each{ |price| amount += price | |
} | |
cart.items.each{|item| | |
if item[:item].name == 'Gift Card' | |
amount += item[:amount].to_f | |
end | |
} | |
#if amount > 2750 | |
# amount = 2750 | |
#end | |
amount | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment