Sha256: 5e1e06c5fcf5786391f4ab4c4b498d1e2ba910d0f153a6cf049fe2ffaa61f928
Contents?: true
Size: 1.19 KB
Versions: 3
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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
shoppe-0.0.19 | app/models/shoppe/delivery_service.rb |
shoppe-0.0.18 | app/models/shoppe/delivery_service.rb |
shoppe-0.0.17 | app/models/shoppe/delivery_service.rb |