Sha256: 47ff26a03d96a9c78b13470403c3539ef97b9f414a659c0b1abbf8b311acdda6
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
Spree::Stock::Estimator.class_eval do # Override to save the delivery time def calculate_shipping_rates(package, ui_filter) shipping_methods(package, ui_filter).map do |shipping_method| response = shipping_method.calculator.compute(package) if response.is_a? Hash cost = response[:cost] delivery_time = response[:delivery_time] elsif %w(Float BigDecimal Fixnum).include? response.class.to_s cost = response delivery_time = nil end tax_category = shipping_method.tax_category if tax_category tax_rate = tax_category.tax_rates.detect do |rate| # If the rate's zone matches the order's zone, a positive adjustment will be applied. # If the rate is from the default tax zone, then a negative adjustment will be applied. # See the tests in shipping_rate_spec.rb for an example of this.d rate.zone == order.tax_zone || rate.zone.default_tax? end end if cost rate = shipping_method.shipping_rates.new(cost: cost, delivery_time: delivery_time) rate.tax_rate = tax_rate if tax_rate end rate end.compact end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spree_zaez_tnt_mercurio-3.0.7 | app/models/spree/stock/estimator_decorator.rb |