Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Clear shipment when transitioning to delivery step of

checkout if the current shipping address is not eligible for the
existing shipping method

[Fixes #925]
  • Loading branch information...
commit aae64f1f84d4d376903ca25d397844f473c0d30d 1 parent 71a3c4f
@LBRapid LBRapid authored radar committed
Showing with 7 additions and 3 deletions.
  1. +7 −3 core/app/models/spree/order.rb
View
10 core/app/models/spree/order.rb
@@ -94,9 +94,7 @@ class Order < ActiveRecord::Base
end
end
- before_transition :to => ['delivery'] do |order|
- order.shipments.each { |s| s.destroy unless s.shipping_method.available_to_order?(order) }
- end
+ before_transition :to => 'delivery', :do => :remove_invalid_shipments!
after_transition :to => 'complete', :do => :finalize!
after_transition :to => 'delivery', :do => :create_tax_charge!
@@ -338,6 +336,12 @@ def tax_total
adjustments.tax.map(&:amount).sum
end
+ # Clear shipment when transitioning to delivery step of checkout if the
+ # current shipping address is not eligible for the existing shipping method
+ def remove_invalid_shipments!
+ shipments.each { |s| s.destroy unless s.shipping_method.available_to_order?(self) }
+ end
+
# Creates new tax charges if there are any applicable rates. If prices already
# include taxes then price adjustments are created instead.
def create_tax_charge!
Please sign in to comment.
Something went wrong with that request. Please try again.