I have installed alpha1+25-dev version of UC Addresses module (though previous version has the same problem). The module is grabbing and storing the data no problem, but I'm missing addresses in few places on site. First - the address is not present in address book (screen 1), second the select list doesn't display address name (altough it is populated with blank space, screen 2). And third - the address is missing in last step of checkout (screen 3). Enabling or disabling address nicknames doesn't change a thing. Everything works fine when the module is disabled. Guess it has something to do with entities/tokens, but I'm not an expert.

Comments

megachriz’s picture

It looks like there is something wrong with the Ubercart Addresses address formats. An address format is used to create an address "label" and in your screenshots these labels look empty (thanks for posting the screenshots to clarify the problem!). Go to /admin/store/settings/countries/uc_addresses_formats and check if the address formats for Ubercart Addresses are set right. An address format should look something like this:

[uc_addresses:company]
[uc_addresses:first_name] [uc_addresses:last_name]
[uc_addresses:street1]
[uc_addresses:street2]
[uc_addresses:city], [uc_addresses:zone:zone_code] [uc_addresses:postal_code]
[uc_addresses:country:country_name_if]

It can look different, depending on the country.

Did this issue happen on a fresh install of Drupal + Ubercart + Ubercart Addresses? Or did this happen on an upgrade from Ubercart Addresses 6.x-1.x or 6.x-2.x?

countach’s picture

I have everything OK in /uc_addresses_formats. I tried to save all settings once more. The status is changed to overridden but that didn't help.
I think there is more to the problem, cause when I save the settings in admin/store/settings/countries/formats I got an error:
"Warning: Illegal string offset 'address_format' in uc_country_formats_form_submit() (line 190 of D:\server\mysite\sites\all\modules\ubercart\uc_store\uc_store.countries.inc)." But it also says that the country settings are saved.

It is a fresh install of Drupal 7.21 and Ubercart 3.4.

megachriz’s picture

It sounds like something goes wrong when saving address formats on admin/store/settings/countries/formats. Although Ubercart reports it saved the country settings, it probably didn't. Can you post a screenshot of this page? (I'm not sure if I can locate the problem with it, but I could look if it looks right.)
Did you try to edit the address format of one of the countries on admin/store/settings/countries/uc_addresses_formats? You can click on the country name to edit the address format.

countach’s picture

StatusFileSize
new127.74 KB
new126.45 KB
new134.04 KB
new54.04 KB

Yup, tried that - it's says overridden, but still no luck.

Here are screenshots from all 4 pages.

megachriz’s picture

It took me some time to figure out, but I think I got a clue what's the cause of the issue. Since you disabled the country field, the setting for the Ubercart default country is not saved (I didn't knew about this behavior in Ubercart). Also, if the country field is disabled, Ubercart Addresses tries to pick the Ubercart default country to format the address with. Since there is no default country, Ubercart Addresses can't find the address format to use and choose to display nothing. Yes, that is a bug.

In the first place, Ubercart Addresses shouldn't give up if it can't find an address format: it should at least use a default address format.
Second, I think it should look at the available countries when there is no Ubercart default country. Now it just picks U.S., even when that country is not available. I should examine what Ubercart does in this case.

A quick fix for you would be the following:

  1. Temporary enable the country field on admin/store/settings/countries/fields.
  2. Go to admin/store/settings/store and set the store's country.
  3. Disable the country field on admin/store/settings/countries/fields.

Meanwhile, I'll look for the real fix, though you won't need to wait for it as the steps above would solve the problem for you too.

countach’s picture

Yeah, it worked. Thanks a lot :)

megachriz’s picture

Version: 7.x-1.0-alpha1 » 7.x-1.x-dev
Component: Checkout » Code
Status: Active » Needs review
StatusFileSize
new5.82 KB

This patch fixes two things:

  • It ensures that never an "empty" address format is used. In case an address format is not found, it uses a "hard-coded" default address format.
  • When the country field is disabled and there is no default country set, Ubercart Addresses will first try to use the address format for the United States. If that country is not available, it will use the address format from the first country available in alphabetical order.

The patch also includes a test to ensure the bug is fixed.

Status: Needs review » Needs work

The last submitted patch, uc_addresses7-default-address-format-1961590-7.patch, failed testing.

megachriz’s picture

Status: Needs work » Needs review
StatusFileSize
new10.5 KB

The test is failing because of a caching issue in the tests. uc_store_default_country() caches the default country in code using the static keyword instead of the more encouraged drupal_static() function. Because of this, this function can not be evolved in API tests like this. The test should be done via an other approach.

The test in the attached patch disabled the country field and tests the output of formatted addresses using curl instead of the API. Additionally, some changes were needed in the base test class "UcAddressesTestCase", because the function for generating address edit values did not check for enabled fields.

Hopefully, this patch will pass all tests.

Status: Needs review » Needs work

The last submitted patch, uc_addresses7-default-address-format-1961590-9.patch, failed testing.

megachriz’s picture

Status: Needs work » Needs review
StatusFileSize
new10.5 KB

The test that fails on drupal.org is passing locally. It looks I need to look for a nail in haystack.

Okay, next try. This patch uses randomName() instead of randomString() to set the Canada address format (in the test).

megachriz’s picture

Version: 7.x-1.x-dev » 6.x-2.x-dev
Status: Needs review » Patch (to be ported)

Committed #11.

Moving to 6.x-2.x.

megachriz’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new9.74 KB

Patch for the 6.x-2.x version.

megachriz’s picture

Version: 6.x-2.x-dev » 7.x-1.x-dev
Status: Needs review » Fixed

Committed #13.

Setting issue status back to the version it was originally reported for and mark it as fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.