Skip to content

Commit

Permalink
When Spree::ActiveShipping::Config[:shipper_number] is "", an empty S…
Browse files Browse the repository at this point in the history
…hipperNumber node is added to the request, resulting in a "Missing/Invalid Shipper/ShipperNumber" error response from UPS.

By adding .presence, we can have it treat a "" value as nil so that it will skip adding the
ShipperNumber node when shipper_number is "" instead of treating "" as a truthy value.

Fixes #57
  • Loading branch information
TylerRick authored and radar committed Feb 1, 2013
1 parent 6421913 commit 8068050
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/spree/active_shipping/ups_override.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def build_rate_request(origin, destination, packages, options={})
# * Shipment/RateInformation element

#SPREE OVERRIDE Negotiated Rates
if (origin_account = @options[:origin_account] || options[:origin_account])
if (origin_account = @options[:origin_account].presence || options[:origin_account].presence)
shipment << XmlNode.new("RateInformation") do |rate_information|
rate_information << XmlNode.new("NegotiatedRatesIndicator", '')
end
Expand Down Expand Up @@ -157,7 +157,7 @@ def build_location_node(name,location,options={})
location_node << XmlNode.new('PhoneNumber', location.phone.gsub(/[^\d]/,'')) unless location.phone.blank?
location_node << XmlNode.new('FaxNumber', location.fax.gsub(/[^\d]/,'')) unless location.fax.blank?

if name == 'Shipper' and (origin_account = @options[:origin_account] || options[:origin_account])
if name == 'Shipper' and (origin_account = @options[:origin_account].presence || options[:origin_account].presence)
location_node << XmlNode.new('ShipperNumber', origin_account)
elsif name == 'ShipTo' and (destination_account = @options[:destination_account] || options[:destination_account])
location_node << XmlNode.new('ShipperAssignedIdentificationNumber', destination_account)
Expand Down

0 comments on commit 8068050

Please sign in to comment.