Working with a site that sells e-courses and other non-shippable stuff, so there is only one customer profile address (billing info). Users must register to use the site, so the customer profile billing address is linked to the user profile address field.

In checkout, if the billing address country is changed to something other than the value in the user's profile address, the checkout process silently fails: form submits and returns the same checkout page with no messages, error or otherwise. (Expected behaviour: move forward to order review.)

If the user edits their profile address, changing the country, then they can checkout with that same country. (So the problem isn't the countries themselves. It seems to be changing the value in the cart to a different value than in the user profile.) The customer profile billing address and the user profile address field have identical settings.

Happens with and without JS turned on.

Comments

rszrama’s picture

Category: bug » support
Status: Active » Postponed (maintainer needs more info)

Without JS turned on, that's the expected behavior for Drupal's #ajax system in the Forms API. We set the form to rebuild, and since it can't do it via AJAX, when you submit the form it will rebuild and display the same form without submitting it.

When you have JS turned on - not sure. We'll need to know what other modules / customizations you have on there, what browser you're using, if any errors are turning up in the watchdog or logs, and perhaps if you have issues with other #ajax related functionality.

steve.m’s picture

I have been testing in FF + Crome on Linux, but it was reported from users using FF + IE on Windows. Nothing in the logs.

AJAX works fine in other places: views slideshows and so on. I don't think there are any other ajax forms, however.

There are lots of cart + product customizations, but very little once we reach checkout. Pretty much just one piece of custom validation, but it's pretty straightforward (it's added to $form['buttons']['continue']['#validate'][] in a form_alter function):

function btcommerce_checkout_valid_postal_code($form, &$form_state) {
$address = $form_state['values']['customer_profile_billing']['commerce_customer_address'][LANGUAGE_NONE][0];
$result = postal_code_validation_validate($address['postal_code'], $address['country']);

if (!$result || $result['postal_code'] == FALSE) {
$err = !empty($result['error']) ? $result['error'] : 'Postal code error';
form_set_error('', t($err));
}
}

wiipiiw’s picture

Version: 7.x-1.4 » 7.x-1.5

Hi

I have exactly the same issue as Steve, with Commerce 1.5. No errors in the logs and no relevant customisations.
Is there any progress or are there any workarounds for this problem?

I think the problem started when I installed the commerce_eu_vat module, but I'm not sure. I'm gonna disable the module and check if it has any effect.

Thanks in advance!

rszrama’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

It'd be great to know if that module was a problem for you, but I still haven't been able to reproduce this error. Feel free to open it back up if you have a reproducible failure.

jeremylichtman’s picture

Status: Closed (cannot reproduce) » Active

I've had this same issue.

Here's what I've found so far:

1. commerce_checkout_form_validate (in commerce/modules/checkout/includes/commerce_checkout.pages.inc) contains a call that triggers the individual pane's hook_checkout_form_submit functions.

2. when I go through checkout flow, add a new customer profile, submit (i.e. arrive on the review page), and then go back to edit the profile - and then change the country in the addressfield -> the commerce_checkout_form_validate function is no longer called. I stuck a drupal_add_error message at the top of the function, and confirmed that it is called if I go back, leave the country as-is, and then submit.

This doesn't appear to be a validation error within the function, since my drupal_add_message is right at the top of it.

Possibilities:
- the ajax action on addressfield is damaging the form somehow
- the validation is skipped due to some magic that I don't know about

rszrama’s picture

Go back using the back button of the form or your browser?

jeremylichtman’s picture

Back button, not browser button.

Just to provide some further info about our setup:
- commerce 1.8
- commerce_addressbook - 2.0-rc7
- addressfield - 1.0-beta4
- ctools - 1.3

Many other modules, but don't think they're modifying anything on this form.

jeremylichtman’s picture

It looks like the addressfield module does a blanket #limit_validation_errors on the country field.

I've removed that in a form alter, which still does not resolve the issue.

However, could that potentially be part of the problem?

rszrama’s picture

I don't think that should be an issue; if anything, #limit_validation_errors would prevent a silent failure.

rszrama’s picture

Issue summary: View changes
Status: Active » Closed (cannot reproduce)

I'm not sure I have enough information to pursue this any further. Perhaps it's an issue with the Addressbook module? In any event, if we're to track this down any further in core, we need steps to reproduce the issue on a clean installation of Commerce Kickstart 1.x. Feel free to reopen if you can provide those.

thim’s picture

For future people having the same issue.

Scenario:
- set country field in code to a default value
- During checkout change the country

Result:
- no error but you will return to the /checkout page where you have to fill-in all the contact details

Cause:
No sure but if I comment out the "addressfield_standard_country_validate" then I can continue the checkout.

// Put this in comment
//  $format['country']['#element_validate'] = array('addressfield_standard_country_validate');

/addressfield/plugins/format/address.inc

I think the solution lies in the function addressfield_standard_country_validate($element, &$form_state)
and doing "$form_state['rebuild'] = TRUE;" when needed, but not sure how to resolve it permantly.

PS: I'm using the addressfield beta 3 module (so this might be fixed in the latest releases).

iancawthorne’s picture

I'm getting this problem and echo what @thim has said in post #11.

I am using the commerce_extra module with it's address_populate sub module, which will populate the billing address in the checkout with the users address used by the addressfield module.

If the billing address country is left the same as the users address, checkout can proceed, if it is changed to anything else, it silently fails with no log errors.

I've also tried what @thim has said and commenting out the "addressfield_standard_country_validate" line in address.inc does allow to continue, but does stop the address fields from dynamically updating when a different country is chosen.

I'm on beta5 of the addressfield module, so I don't think there is a fix there yet.

I will post back if I can make any useful progress on this issue.

iancawthorne’s picture

I managed to track down the problem I was having to be with the commerce_extra modules address_populate module. I was using 7.x-1.0-alpha1. Switching to the dev release (at the time of this post) resolved the problem.

So my question for anyone else that is having this issue would be; are you using the commerce_extra module to pre populate your address fields?

george2u’s picture

I got a similar problem when trying to change country for billing address (or shipping address): an error occurred while attempting to process /system/ajax: this is undefined.

this seems to be an ajax issue, can anyone shed some light on this?

thx

BITANUBE’s picture

Subscribe with #11

Same error and same solution.

I think is related with https://www.drupal.org/node/1488294
And a possible explanation here : http://stackoverflow.com/a/13025563

With a different workarounds, I think it's better to use this hook on your theme or custom module. Removing #element_validate was enough without commenting address.inc module.

/**
  * Implements hook_form_FORMID_alter() for `commerce_checkout_form_checkout`.
  */
function hook_form_commerce_checkout_form_checkout_alter(&$form, &$form_state) {
	unset($form['customer_profile_shipping']['commerce_customer_address'][LANGUAGE_NONE][0]['country']['#element_validate']);
	
}

But this is partial solution because unsetting ['#element_validate'] the rest of the dependant fields values are not reset and user may not take care about this.

To fix this i purpose to add invoking of js function that reset field values like adressfield-module does.
We could do this adding js command in hook_addressfield_standard_widget_refresh that offer us to add commands ( but not change $form or $form_state that could be simplest way )

shi99’s picture

I have the same issue.
The workaround in #15 worked for me.

shi99’s picture

Status: Closed (cannot reproduce) » Active