Update customer default address from Cart

Shopify Partner
7 0 1

Some of our clients have multiple addresses on their account, and I'm looking to create a simple way for them to select which address to use on checkout from the cart page, rather than going back to account > addresses for every purchase.


My idea is to use a radio button group for the customer's addresses, but I'm not sure how to translate the selected address to the customer object and actually change the default address, or how to use the selected address for checkout.


Here is the code I've injected into the cart page so far:



{% if customer and customer.addresses_count > 1 %}
                <div class="address-select">
                  <h4>Select Address</h4>
                  <form class="address-select-form">
                    {% for address in customer.addresses %}
                      <div class="radio-select">
                        <label for="{{ address.name }}-{{ forloop.index }}">
                          {{ address.name }}
                          id="{{ address.name }}-{{ forloop.index }}"
                          value="{{ address }}"
                          {% if address == customer.default_address %}
                          {% endif %}
                    {% endfor %}
              {% endif %}


Reply 1 (1)

Shopify Partner
6339 579 1350

Your html form isn't submitting to anything.

Just reference the customer address form tag in the theme , replicate it then pare it down to the minimum needed.

Also see the docs https://shopify.dev/docs/themes/architecture/templates/customers-addresses 


If you need this customization done for you then contact me by mail for services.
ALWAYS please provide context, examples: store url, theme name, post url(s) , or any further detail in ALL correspondence.
Contact info in signature.


Good Hunting.

Save time & money ,Ask Questions The Smart Way

Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com

Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org