Sha256: 4a602f9887170097420c9826029eebafb952ffae135f9cf929e47319c421cea1

Contents?: true

Size: 697 Bytes

Versions: 2

Compression:

Stored size: 697 Bytes

Contents

class OrderShipping < ActiveRecord::Base
  belongs_to :order

  def self.from_cart(cart)
    options = {}

    unless cart.options[:colissimo].nil?
      params= cart.options[:colissimo]
      options[:name] = 'So Colissimo'
      options[:price] = params['DYFORWARDINGCHARGES']
      options[:colissimo_type] = params['DELIVERYMODE']
    else
      if cart.options[:free_shipping] == true
        options[:name] = I18n.t(:free_shipping)
        options[:price] = 0
      elsif transporter = TransporterRule.find_by_id(cart.options[:transporter_rule_id])
        options[:name] = transporter.name
        options[:price] = transporter.variables
      end
    end

    self.new(options)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
forgeos_commerce-1.9.1.rc1 app/models/order_shipping.rb
forgeos_commerce-1.9.0 app/models/order_shipping.rb