<p>When i try to delete a user address in Craft Commerce, I get an error thrown, saying the address id does not exist. </p>

<p>However the address id being passed to the action is output from a loop of the current addresses, so it does exist?</p>

<p>This only happens if it is the primary shipping or billing address. If there is a single address, where its neither the primary shipping or billing address the error does not occur. </p>

<p>For example:</p>

<pre><code>{% for address in customer.addresses %}
{% include 'shop/_includes/addresses/address' with {'address': address} %}
&lt;form method="POST"&gt;
 &lt;input type="hidden" name="action" value="commerce/customer-addresses/delete"&gt;
 {{ csrfInput() }}
 &lt;input type="hidden" name="id" value="{{ address.id }}"/&gt;
 &lt;input type="submit" class="default-button" value="Delete"/&gt;
&lt;/form&gt;
{% endfor %}
</code></pre>

<p>The error is attached in the following screenshot <a href="https://i.sstatic.net/pgklZ.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/pgklZ.jpg" alt="enter image description here"></a>:</p>

<p>This is using the default form/examples from the craft commerce example template - wondering what might be causing this error and how i can fix it? </p>

<p>If refresh the page the address is deleted as expected, but i can't get around the error being thrown.</p>

CC BY-SA 4.0
2020-04-01T13:21:41.120Z
The error is being thrown on saving an address, are you trying to save an address?
Luke Holder
CC BY-SA 4.0
2020-04-01T13:33:13.203Z
No i'm not trying to save the address - I'm justing using the example form above to delete e.g. posting the id to commerce/customer-addresses/delete
alexr
CC BY-SA 4.0
2020-04-01T13:48:39.293Z
To be honest i'm not too sure how its getting to the saveAddress function, as the contents of the form being submitted only have that single action to delete addresses - i've checked through and there's doesn't seem to be anything else on the page (other forms etc) that might be interfering somehow.
alexr
CC BY-SA 4.0
2020-04-03T21:35:21.360Z
@alexr this was a bug that has been fixed in the latest version of Commerce. Thanks!
nfourtythree
<craft3><plugin-craftcommerce>
Deleting primary commerce address throws error
# Deleting primary commerce address throws error

(Asked by: username_0 on 2020-04-01)

When i try to delete a user address in Craft Commerce, I get an error thrown, saying the address id does not exist. 
However the address id being passed to the action is output from a loop of the current addresses, so it does exist?
This only happens if it is the primary shipping or billing address. If there is a single address, where its neither the primary shipping or billing address the error does not occur. 
For example:
{% for address in customer.addresses %}
{% include 'shop/_includes/addresses/address' with {'address': address} %}

 
 {{ csrfInput() }}
 
 

{% endfor %}

The error is attached in the following screenshot :
This is using the default form/examples from the craft commerce example template - wondering what might be causing this error and how i can fix it? 
If refresh the page the address is deleted as expected, but i can't get around the error being thrown.

**Tags:** craft3, plugin-craftcommerce

> **Comments:**
> **username_1**: The error is being thrown on saving an address, are you trying to save an address?  
> **username_0**: No i'm not trying to save the address - I'm justing using the example form above to delete e.g. posting the id to commerce/customer-addresses/delete  
> **username_0**: To be honest i'm not too sure how its getting to the saveAddress function, as the contents of the form being submitted only have that single action to delete addresses - i've checked through and there's doesn't seem to be anything else on the page (other forms etc) that might be interfering somehow.  
> **username_2**: @username_0 this was a bug that has been fixed in the latest version of Commerce. Thanks!  

---

## 0 answers

