Solidus: Support Default Billing Address in Address Book

Created on 5 Mar 2020  路  3Comments  路  Source: solidusio/solidus

Is your feature request related to a problem? Please describe.

Currently, persist_order_address saves order addresses to a user's address book via save_in_address_book that also supports the Spree::Config.automatic_default_address config setting. Unfortunately, this does not work for billing_address because that is still being pulled from a column on the spree_users table whereas shipping_address is pulled from the spree_user_addresses where default is true. This means that even if your config is set to automatic_default_address = false it will still set the default billing address on every order save.

Describe the solution you'd like

Support Spree::UserAddress to work for both billing and shipping addresses. Maybe add columns for default_billing and default_shipping while leaving the default column.

Describe alternatives you've considered

Changing the setting of self.bill_address_id to respect Spree::Config.automatic_default_address

# solidus/core/app/models/concerns/spree/user_address_book.rb:79-86
    if order.bill_address
      address = save_in_address_book(
        order.bill_address.attributes,
        order.ship_address.nil? && Spree::Config.automatic_default_address
      )
      # Respect automatic_default_address on legacy bill_address_id field
      self.bill_address_id = address.id if address && address.persisted? && Spree::Config.automatic_default_address
    end

Additional context

Enhancement Good First Issue

Most helpful comment

I agree that we should standardize this as the current behavior doesn't make much sense, and I think having a default_billing and default_shipping would work well here.

All 3 comments

I agree that we should standardize this as the current behavior doesn't make much sense, and I think having a default_billing and default_shipping would work well here.

anyone working on this issue? If not I would like to grab it!

@gonzar11 thanks, @oldjackson is working on that in #3563.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jarednorman picture jarednorman  路  5Comments

aitbw picture aitbw  路  4Comments

tudorpavel picture tudorpavel  路  3Comments

spaghetticode picture spaghetticode  路  3Comments

cdrage picture cdrage  路  3Comments