Sha256: 565e248b0c10dfed0aab2ae3c6e8d5b332459cf9b6a54c9b7e1bbc80f484de98

Contents?: true

Size: 317 Bytes

Versions: 2

Compression:

Stored size: 317 Bytes

Contents

class Shipment < ActiveRecord::Base
  belongs_to :order
  belongs_to :shipping_method
  before_save :calculate_shipping
  
  private 
  def calculate_shipping
    calculator = shipping_method.shipping_calculator.constantize.new
    order.update_attribute(:ship_amount, calculator.calculate_shipping(order))
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree-0.5.0 vendor/extensions/shipping/app/models/shipment.rb
spree-0.5.1 vendor/extensions/shipping/app/models/shipment.rb