Sha256: 5414838e844ce194900ec97f05d7e4bbc53d632a37577cd0a22c9e2bcdba23dd
Contents?: true
Size: 1.04 KB
Versions: 6
Compression:
Stored size: 1.04 KB
Contents
module Tienda class DeliveryService < ActiveRecord::Base # Validations validates :name, presence: true validates :courier, presence: true # Orders which are assigned to this delivery service has_many :orders, dependent: :restrict_with_exception # Prices for the different levels of service within this delivery service has_many :delivery_service_prices, dependent: :destroy # All active delivery services scope :active, -> { where(active: true)} # Returns a tracking URL for the passed order # # @param order [Tienda::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
6 entries across 6 versions & 1 rubygems