Sha256: 6b26779d40983c0c0c79c249d1f4cccd4490d38fbc96d2b92a1a70e0df7b9122

Contents?: true

Size: 768 Bytes

Versions: 22

Compression:

Stored size: 768 Bytes

Contents

class ShippingMethod < ActiveRecord::Base
  DISPLAY =  [:both, :front_end, :back_end]
  belongs_to :zone
  has_many :shipments
  validates :name, :calculator, :zone, :presence => true

  calculated_adjustments

  def available?(order, display_on=nil)
    display_check = (self.display_on == display_on.to_s || self.display_on.blank?)
    calculator_check = calculator.available?(order)
    display_check && calculator_check
  end

  def available_to_order?(order, display_on=nil)
    availability_check = available?(order,display_on)
    zone_check = zone && zone.include?(order.ship_address)
    availability_check && zone_check
  end

  def self.all_available(order, display_on=nil)
    all.select { |method| method.available_to_order?(order,display_on)}
  end

end

Version data entries

22 entries across 22 versions & 6 rubygems

Version Path
spree_core-0.70.7 app/models/shipping_method.rb
spree_core-0.70.6 app/models/shipping_method.rb
apispree_core-0.0.0 app/models/shipping_method.rb
My-Commerce_core-1.1.0 app/models/shipping_method.rb
My-Commerce_core-1.0.0 app/models/shipping_method.rb
MyCommerceapi-1.0.0 core/app/models/shipping_method.rb
MyCommerce-0.0.3 core/app/models/shipping_method.rb
rfcommerce_core-0.0.3 app/models/shipping_method.rb
spree_core-0.60.6 app/models/shipping_method.rb
spree_core-0.70.5 app/models/shipping_method.rb
spree_core-0.70.4 app/models/shipping_method.rb
spree_core-0.60.5 app/models/shipping_method.rb
spree_core-0.70.3 app/models/shipping_method.rb
spree_core-0.70.2 app/models/shipping_method.rb
spree_core-0.60.4 app/models/shipping_method.rb
spree_core-0.60.3 app/models/shipping_method.rb
spree_core-0.70.1 app/models/shipping_method.rb
spree_core-0.70.0 app/models/shipping_method.rb
spree_core-0.60.2 app/models/shipping_method.rb
spree_core-0.70.0.rc2 app/models/shipping_method.rb