Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make sure we return nil when there's no package.

Will prevent CanadaPost from firing a request with no lineitem that will crash.
  • Loading branch information...
commit 86927104e51066872b32fe50c05821c885b9132d 1 parent 6bcf653
@jbourassa jbourassa authored j15e committed
Showing with 6 additions and 2 deletions.
  1. +6 −2 app/models/spree/calculator/active_shipping/base.rb
View
8 app/models/spree/calculator/active_shipping/base.rb
@@ -36,10 +36,14 @@ def compute(object)
:zip => addr.zipcode)
rates = Rails.cache.fetch(cache_key(order)) do
- rates = retrieve_rates(origin, destination, packages(order))
+ order_packages = packages(order)
+ if order_packages.empty?
+ {}
+ else
+ retrieve_rates(origin, destination, order_packages)
+ end
end
- return nil if rates.empty?
rate = rates[self.class.description]
return nil unless rate
rate = rate.to_f + (Spree::ActiveShipping::Config[:handling_fee].to_f || 0.0)
Please sign in to comment.
Something went wrong with that request. Please try again.