Checkbox to make billing information same as shipping information does not work for Anonymous users

by Wesley Musgrove   Last Updated April 23, 2015 22:03 PM

For Anonymous users, the My Shipping information is the same as my Billing information checkbox doesn't reload the Shipping Information checkout pane.

I have the checkbox working for authenticated users, but when an anonymous user is going through checkout, the ajax callback never fires. The #element_validate function 'commerce_customer_profile_copy_validate' is never called. The #ajax['callback'] => 'commerce_customer_profile_copy_refresh' is never called.

Watching the network tab in Chrome, the ajax request is never fired.

The checkbox is checked by default and nothing happens when I un-check it. The Shipping Information pane doesn't expand and show the shipping information form fields via ajax.

Is there some permission I'm missing that would allow anonymous users to use this checkbox?



Answers 1


Turns out I was kicking myself on this one. I forgot I had some custom hook_js_alter code in my template.php that removes unnecessary js from the page for anonymous users. This was done to improve site speed and because my custom theme didn't require these default Drupal js libraries.

function theme_js_alter(&$javascript) {
  $logged_in_user = user_uid_optional_load();
  if(!in_array("authenticated user", $logged_in_user->roles)) {
    foreach($javascript as $key => $value) {
      unset($javascript[$key]);
    }
  }
}

However I do need these javascripts on commerce checkout pages apparently, so I added a request_path() check for checkout and cart pages so the js would not be unset.

I confirmed the My Shipping information is the same as my Billing information checkbox now works for anonymous users.

Wesley Musgrove
Wesley Musgrove
April 23, 2015 19:56 PM

Related Questions


Check if certain line item type exists

Updated April 11, 2015 00:03 AM

Display 2 checkout panes side by side

Updated August 03, 2015 16:03 PM

Prepopulating county/state field (ajax driven field)

Updated February 25, 2016 01:03 AM

Go to Checkout Complete without checkout payment

Updated July 21, 2015 13:03 PM