When you choose a address, it work great, but if after that, the user select the #empty_value ( the "- choose an address -" option), it thow an ajax error.

I was trying to debug this in order to don't make the ajax callback when the #empty_value is selected, but I couldn't

Here I attach a screenshot

regards.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

akalam’s picture

I don't know if it is usefull but the error message is thrown in misc/ajax.js line 451:

/**
 * Handler for the form redirection error.
 */
Drupal.ajax.prototype.error = function (response, uri) {
  alert(Drupal.ajaxError(response, uri));

since commenting this line stop throwing the alert

jsacksick’s picture

Status: Active » Closed (cannot reproduce)

I just tried to do that and I couldn't reproduce the issue.

sin’s picture

Version: 7.x-2.0-rc3 » 7.x-2.0-rc7
Status: Closed (cannot reproduce) » Active

The same for me in rc7, trying to debug now.

EDIT
AJAX Error is:
EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. function EntityDrupalWrapper->set() (string 744 in /sites/all/modules/entity/includes/entity.wrapper.inc).

EDIT
commerce_addressbook.module:452
$order_wrapper->{$field_name} = NULL;
this causes exception for me in entity.wrapper.inc set() due to failed $this->validate($value) check.

sin’s picture

Status: Active » Closed (won't fix)

I found the problem source.

The validation code in entity/includes/entity.wrapper.inc:151 causes an exeption if customer billing profile order field is marked as required at admin/commerce/config/order/fields/commerce_customer_billing.

This field is not required in Commerce Kickstart and not required in Drupal Commerce default installation. Checkout fields validation works just fine without it.

So the solution is not to mark order profile field as required :) Maybe it would be better to just disable required option. Not a Commerce Addressbook problem I think.

mibfire’s picture

This caused my a huge debug time too. Maybe address module should check these required setting for shipping and billing fields and throw a message about that the reuired setting should be disabled.

The solution would be if commerce and shipping module removed this required settings and set these to disabled by default(in this case addressbook module shouldnt do any check).

wangxb07’s picture

Issue summary: View changes

commerce_addressbook.module:452
$order_wrapper->{$field_name} = NULL;

The target field not allow be settings to NULL type.

change NULL to -1.