Steps to reproduce
- update to commerce_addressbook 7.x-2.0-rc4
- as a user with some addresses, none of which are default, visit user/UID/addressbook
- click "set as default" on one of the addresses
The AJAX request completes, then the address disappears. Refreshing the page causes the default address to be displayed correctly.
I guess this is a regression after #1781548: Active Adress boxes, when the DIV #commerce-addressbook-billing-default was removed for users with no default addresses.
Comments
Comment #1
jsacksick commentedYou're right, this is a regression coming from #1781548: Active Adress boxes, the attached patch should fix the issue.
Comment #2
jsacksick commentedSame patch with an updated comment.
Comment #3
pjcdawkins commentedThe comment should have "has default addresses", and it's a bit confusing anyway (not sure how to fix).
Perhaps use
drupal_html_id()for this sort of thing. It's not clear whether $customer_profile->type is sanitized.Other than that the patch works for me - thanks!
Comment #4
jsacksick commentedI updated the comment, I'm not sure we need to change anything for the $defaults_html, this doesn't need to be passed by drupal_html_id.
Comment #5
pjcdawkins commentedFine with me.
Comment #6
jsacksick commentedThis patch doesn't fix all the potential usecases.
Let me explain why :
You could break it by creating two addresses, then you'll end up with one default address and an other non default one.
Now if you remove the default address and set the other as "default" then you'll have an empty
#commerce-addressbook-($customer_profile->type)-listdiv, we could potentially avoid that situation by forcing users to have a default address, so when you'd remove your default address we would set an other as default. I'm not 100% sure about that though.Comment #7
jsacksick commentedCommitted, thanks for your help ! http://drupalcode.org/project/commerce_addressbook.git/commit/d11dc4c