Class: Opensteam::ShipmentBase::ShippingRateGroup

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/opensteam/shipment_base.rb

Overview

Model for Shipping Rate Groups

Instance Method Summary collapse

Instance Method Details

#rate_for(attr = {}) ⇒ Object



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/opensteam/shipment_base.rb', line 126

def rate_for( attr = {} )
  conditions = {}
  conditions["zones.country_name"] = attr[:country] || Opensteam::Config[:default_country]
  conditions["shipping_method"] = attr[:shipping_method] || Opensteam::Config[:shipping_method_default]
    
  srate = shipping_rates.find( :first, :include => :zone, :conditions => conditions )
 
  rate = unless srate
    shipping_disabled ? 0.0 : master_rate.to_f
  else
    srate.rate
  end
    
  rate += get_payment_additions( attr[:payment_type] ) if attr[:payment_type]
 
  rate
end