Sha256: e65db3a7c98826676b7cb2a052dc8702c589abaf71e6159bf21733f63dc2a2d1

Contents?: true

Size: 711 Bytes

Versions: 2

Compression:

Stored size: 711 Bytes

Contents

class ShippingMethod < ActiveRecord::Base
  DISPLAY =  [:both, :front_end, :back_end]
  belongs_to :zone
  has_many :shipments

  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

2 entries across 2 versions & 1 rubygems

Version Path
spree_core-0.60.0 app/models/shipping_method.rb
spree_core-0.60.0.RC1 app/models/shipping_method.rb