Module: Spree::Order::AddressBook
- Included in:
- Spree::Order
- Defined in:
- app/models/spree/order/address_book.rb
Instance Method Summary collapse
- #bill_address_attributes=(attributes) ⇒ Object
- #bill_address_id=(id) ⇒ Object
- #clone_billing_address ⇒ Object
- #clone_shipping_address ⇒ Object
- #ship_address_attributes=(attributes) ⇒ Object
- #ship_address_id=(id) ⇒ Object
Instance Method Details
#bill_address_attributes=(attributes) ⇒ Object
30 31 32 33 |
# File 'app/models/spree/order/address_book.rb', line 30 def bill_address_attributes=(attributes) self.bill_address = update_or_create_address(attributes) user.bill_address = bill_address if should_assign_user_default_address?(bill_address) end |
#bill_address_id=(id) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/models/spree/order/address_book.rb', line 16 def bill_address_id=(id) return if bill_address_id == id address = Spree::Address.find_by(id: id) # rubocop:disable Style/ConditionalAssignment if address && user_id.present? && address.user_id == user_id self['bill_address_id'] = address.id else self['bill_address_id'] = nil end # rubocop:enable Style/ConditionalAssignment reset_bill_address end |
#clone_billing_address ⇒ Object
10 11 12 13 14 |
# File 'app/models/spree/order/address_book.rb', line 10 def clone_billing_address self.ship_address = bill_address if bill_address user.ship_address = bill_address if should_assign_user_default_address?(bill_address) true end |
#clone_shipping_address ⇒ Object
4 5 6 7 8 |
# File 'app/models/spree/order/address_book.rb', line 4 def clone_shipping_address self.bill_address = ship_address if ship_address user.bill_address = ship_address if should_assign_user_default_address?(ship_address) true end |
#ship_address_attributes=(attributes) ⇒ Object
49 50 51 52 53 |
# File 'app/models/spree/order/address_book.rb', line 49 def ship_address_attributes=(attributes) self.ship_address = update_or_create_address(attributes) user.ship_address = ship_address if should_assign_user_default_address?(ship_address) self.ship_address = nil if quick_checkout_address?(attributes[:quick_checkout]) && !ship_address.persisted? end |
#ship_address_id=(id) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/models/spree/order/address_book.rb', line 35 def ship_address_id=(id) return if ship_address_id == id address = Spree::Address.find_by(id: id) # rubocop:disable Style/ConditionalAssignment if address && user_id.present? && address.user_id == user_id self['ship_address_id'] = address.id else self['ship_address_id'] = nil end # rubocop:enable Style/ConditionalAssignment reset_ship_address end |