From dec84157ba28019dba2b7ec779ceaa0136e0f4f1 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 24 Oct 2011 15:06:52 +0200 Subject: [PATCH] address: Do not use the paypal shipping address to override things This extension overrides the shipping address with the one supplied by paypal. It is not what we want! Store the paypal address in a dedicated field in case we will ever need it. --- .../spree/checkout_controller_decorator.rb | 6 ++++-- app/models/spree/order_decorator.rb | 3 +++ .../20111024125404_order_pay_pal_address_field.rb | 13 +++++++++++++ ...30182351_rename_sysmocom_pay_pal_ship_address.rb | 9 +++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 app/models/spree/order_decorator.rb create mode 100644 db/migrate/20111024125404_order_pay_pal_address_field.rb create mode 100644 db/migrate/20130130182351_rename_sysmocom_pay_pal_ship_address.rb diff --git a/app/controllers/spree/checkout_controller_decorator.rb b/app/controllers/spree/checkout_controller_decorator.rb index b3bf90b..46ee3bc 100644 --- a/app/controllers/spree/checkout_controller_decorator.rb +++ b/app/controllers/spree/checkout_controller_decorator.rb @@ -96,8 +96,10 @@ module Spree end order_ship_address.save! - @order.ship_address = order_ship_address - @order.bill_address ||= order_ship_address + @order.sysmocom_paypal_ship_address = order_ship_address + #No need to replace the EUVAT and others we already have from the shipping address + #@order.ship_address = order_ship_address + #@order.bill_address ||= order_ship_address #Add Instant Update Shipping if payment_method.preferred_cart_checkout diff --git a/app/models/spree/order_decorator.rb b/app/models/spree/order_decorator.rb new file mode 100644 index 0000000..bde17fc --- /dev/null +++ b/app/models/spree/order_decorator.rb @@ -0,0 +1,3 @@ +Spree::Order.class_eval do + belongs_to :sysmocom_paypal_ship_address, :foreign_key => "sysmocom_paypal_ship_address_id", :class_name => "Address" +end diff --git a/db/migrate/20111024125404_order_pay_pal_address_field.rb b/db/migrate/20111024125404_order_pay_pal_address_field.rb new file mode 100644 index 0000000..d094d97 --- /dev/null +++ b/db/migrate/20111024125404_order_pay_pal_address_field.rb @@ -0,0 +1,13 @@ +class OrderPayPalAddressField < ActiveRecord::Migration + def self.up + change_table :orders do |t| + t.integer :paypal_ship_address_id + end + end + + def self.down + change_table :orers do |t| + t.remove :paypal_ship_address_id + end + end +end diff --git a/db/migrate/20130130182351_rename_sysmocom_pay_pal_ship_address.rb b/db/migrate/20130130182351_rename_sysmocom_pay_pal_ship_address.rb new file mode 100644 index 0000000..09f3359 --- /dev/null +++ b/db/migrate/20130130182351_rename_sysmocom_pay_pal_ship_address.rb @@ -0,0 +1,9 @@ +class RenameSysmocomPayPalShipAddress < ActiveRecord::Migration + def up + rename_column :spree_orders, :paypal_ship_address_id, :sysmocom_paypal_ship_address_id + end + + def down + rename_column :spree_orders, :sysmocom_paypal_ship_address_id, :paypal_ship_address_id + end +end