Skip to content

Instantly share code, notes, and snippets.

@darron
Forked from beautifulcode/gist:101791
Created April 26, 2009 02:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darron/101845 to your computer and use it in GitHub Desktop.
Save darron/101845 to your computer and use it in GitHub Desktop.
class Order < ActiveRecord::Base
def processing_fee
packages_with_processing_fees = ['Package', 'FamilyPackage', 'LadiesPackage', 'CompletePackage']
fee = 0
# Only apply fee if cart contains an item with processing fees
fee = 3.00 if line_items.any? {|line_item| packages_with_processing_fees.include? line_item.item.class.to_s }
if customer
fee = 5.00 unless "Canada United States Mexico".include? customer.country
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment