Skip to content

Instantly share code, notes, and snippets.

@beautifulcode
Forked from darron/gist:101789
Created April 25, 2009 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save beautifulcode/101791 to your computer and use it in GitHub Desktop.
Save beautifulcode/101791 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