Sha256: 878d8b5cf29935f91e7a1ac882ff660e89229df145b6b5c5bb7df45ef48c9190

Contents?: true

Size: 1.19 KB

Versions: 15

Compression:

Stored size: 1.19 KB

Contents

module Shoppe
  class DeliveryService < ActiveRecord::Base
  
    self.table_name = 'shoppe_delivery_services'

    # Validations
    validates :name, :presence => true
    validates :courier, :presence => true
  
    # Orders which are assigned to this delivery service
    has_many :orders, :dependent => :restrict_with_exception, :class_name => 'Shoppe::Order'
    
    # Prices for the different levels of service within this delivery service
    has_many :delivery_service_prices, :dependent => :destroy, :class_name => 'Shoppe::DeliveryServicePrice'
  
    # All active delivery services
    scope :active, -> { where(:active => true)}
    
    # Returns a tracking URL for the passed order
    #
    # @param order [Shoppe::Order]
    # @return [String] the full URL for the order.
    def tracking_url_for(order)
      return nil if self.tracking_url.blank?
      tracking_url = self.tracking_url.dup
      tracking_url.gsub!("{{consignment_number}}", CGI.escape(order.consignment_number.to_s))
      tracking_url.gsub!("{{delivery_postcode}}", CGI.escape(order.delivery_postcode.to_s))
      tracking_url.gsub!("{{billing_postcode}}", CGI.escape(order.billing_postcode.to_s))
      tracking_url
    end

  end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
shoppe-1.1.1 app/models/shoppe/delivery_service.rb
shoppe-1.1.0 app/models/shoppe/delivery_service.rb
shoppe-1.0.9 app/models/shoppe/delivery_service.rb
shoppe-1.0.8 app/models/shoppe/delivery_service.rb
kylekthompson-shoppe-1.0.7 app/models/shoppe/delivery_service.rb
shoppe-1.0.7 app/models/shoppe/delivery_service.rb
shoppe-1.0.6 app/models/shoppe/delivery_service.rb
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/shoppe-1.0.5/app/models/shoppe/delivery_service.rb
shoppe-1.0.5 app/models/shoppe/delivery_service.rb
shoppe-1.0.3 app/models/shoppe/delivery_service.rb
shoppe-1.0.2 app/models/shoppe/delivery_service.rb
shoppe-1.0.1 app/models/shoppe/delivery_service.rb
shoppe-1.0.0 app/models/shoppe/delivery_service.rb
shoppe-0.0.21 app/models/shoppe/delivery_service.rb
shoppe-0.0.20 app/models/shoppe/delivery_service.rb