calculator: Another attempt to work with the Shipment
Resolve the address from the shipment.address which might but I assume is not different to the order.address.
This commit is contained in:
parent
b14af8cffd
commit
8a6301c8a9
|
@ -153,18 +153,26 @@ ZONE3 = {
|
|||
item_total
|
||||
end
|
||||
|
||||
def compute(order)
|
||||
def extract_iso_code(o)
|
||||
if o.kind_of?(Spree::Shipment)
|
||||
return o.address.country.iso
|
||||
end
|
||||
return o.ship_address.country.iso
|
||||
end
|
||||
|
||||
def compute(object)
|
||||
# This could be more than an order but not right now
|
||||
shipping_value = total_value_no_tax(order)
|
||||
shipping_value = total_value_no_tax(object)
|
||||
iso_code = extract_iso_code(object)
|
||||
|
||||
# Go through the zones by name...
|
||||
if order.ship_address.country.iso == 'DE'
|
||||
if iso_code == 'DE'
|
||||
return price_germany(shipping_value)
|
||||
elsif ZONE1.has_key?(order.ship_address.country.iso)
|
||||
elsif ZONE1.has_key?(iso_code)
|
||||
return price_package_zone1(shipping_value)
|
||||
elsif ZONE2.has_key?(order.ship_address.country.iso)
|
||||
elsif ZONE2.has_key?(iso_code)
|
||||
return price_package_zone2(shipping_value)
|
||||
elsif ZONE3.has_key?(order.ship_address.country.iso)
|
||||
elsif ZONE3.has_key?(iso_code)
|
||||
return price_package_zone3(shipping_value)
|
||||
else
|
||||
return price_package_zone4(shipping_value)
|
||||
|
|
Loading…
Reference in New Issue