Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swap billing/shipping address in the address step #117

Open
kennyadsl opened this issue Oct 23, 2020 · 6 comments
Open

Swap billing/shipping address in the address step #117

kennyadsl opened this issue Oct 23, 2020 · 6 comments
Assignees
Milestone

Comments

@kennyadsl
Copy link
Member

We currently use a non-common use case and we should swap the addresses which is the most common use case.

@aleph1ow aleph1ow self-assigned this Nov 6, 2020
@aleph1ow
Copy link
Collaborator

@kennyadsl @ChristianRimondi @blocknotes we should discuss if this is an issue with Solidus and if it should be addressed there. Otherwise, treating it inside this gem requires the Order model decoration.

@kennyadsl
Copy link
Member Author

What's the change needed in the Order model?

@aleph1ow
Copy link
Collaborator

  module SwapAddressForms
    def self.prepended(base)
      base.before_validation :assign_shipping_to_billing_address, if: :use_shipping?
      attr_accessor :use_shipping
    end

    def assign_shipping_to_billing_address
      self.bill_address = ship_address if ship_address
      true
    end

    def use_shipping?
      use_shipping.in?([true, 'true', '1'])
    end

    Spree::Order.prepend self
  end
end

@kennyadsl
Copy link
Member Author

👍 thanks, let's think of a way to add support for this in core.

@kennyadsl
Copy link
Member Author

I had an idea here: in Solidus core, we could change the preference name from use_shipping to same_shipping_and_billing and allow this accessor to be set on both billing and shipping address, this way we could just let user's frontends to choose where to put that checkbox and adapt the backend core to work accordingly.

@ChristianRimondi ChristianRimondi added this to the v2.0.0 milestone Nov 27, 2020
@stale
Copy link

stale bot commented Nov 11, 2022

This issue has been automatically marked as stale because it has not had recent activity. It might be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 11, 2022
@gsmendoza gsmendoza removed the stale label Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants