At the moment it is not possible to programmatically load addresses for a specific user without knowing the address ID unless you call the private function _uc_addresses_db_get_address().
Is there a reason why this function is private? And if not, could it please be made public?
It is also not entirely easy to programmatically save an existing address (saving new addresses for new customers is no problem) without resorting to either calling the private function _uc_addresses_db_update_address or working around doing that by calling the uc_addresses_get_address_form_submit function, which is a bit cumbersome to say the least.
So would it be possible to either make _uc_addresses_db_update_address public or provide some other way to save an address?
Comments
Comment #1
megachrizfreixas and I are working on a new version of Ubercart Addresses that will get a better API for saving and loading addresses. At the moment we are still discussing about how the API should look like. This redesigned API will finally result in Ubercart Addresses v6.x-2.x. After that we will be working on porting the module to Drupal 7.
In the mean time, you can just use the "private" functions in the module. The reason why these functions start with a underscore was because freixas had not found an other way to specify which functions are part of the official API and which aren't. I won't recommend to use uc_addresses_get_address_form_submit() for programmatically update addresses. If you want to save an existing address, use _uc_addresses_db_update_address().
Comment #2
rhmtts commentedOK, we'll use the private functions for now.
Thanks for your input.
Comment #3
freixas commentedJust confirming that Chris is correct—it's fine to use _uc_addresses_db_update_address(). In theory, yes, it was intended as part of the private interface, which could change without notice. But the changes to the next version will be pretty major, so you'll probably need to rewrite anyway. This time, we'll provide an official API.
Also, uc_addresses_get_address_form_submit() is not really a "public" function (as in part of an official API). It needs that name so that it works with the forms system.
Comment #4
megachrizThe 6.x-2.x-version has an official API. You can read all the details about this API in the developer's guide of Ubercart Addresses.
Comment #5
rhmtts commentedLooks great, thanks!