Skip to content

Instantly share code, notes, and snippets.

@sowasred2012
Created October 29, 2015 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sowasred2012/873c1dfc7ab573f55dfe to your computer and use it in GitHub Desktop.
Save sowasred2012/873c1dfc7ab573f55dfe to your computer and use it in GitHub Desktop.
Spree::Order.prepend(Kjus::Order)
Spree::Order.class_eval do
attr_accessor :use_shipping
before_validation :clone_shipping_address, if: :use_shipping?
def use_shipping?
@use_shipping == true || @use_shipping == 'true' || @use_shipping == '1'
end
def clone_billing_address
end
def clone_shipping_address
if ship_address and self.bill_address.nil?
self.bill_address = ship_address.clone
else
self.bill_address.attributes = ship_address.attributes.except('id', 'updated_at', 'created_at')
end
true
end
end
@SebAshton
Copy link

📦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment