Hello,

I have a Drupal Commerce site using Commerce Checkout Redirect and Profile2.

I have a custom Profile2 profile which is not meant to appear on the default user/register page but only at its own custom path.

However, if an anonymour user adds a product to the cart and then initiates checkout, the /user/register page shows the custom Profile2 fields as well. If the user removes the product from the cart, or if I disable the Commerce Checkout Redirect module, the custom fields no longer appera at /user/register.

For the time being I am hiding the custom profile fields with css, but this approach forces me to make those custom fields optional while they should be required because the custom profile is related to a special role.

PS I believe this issue is quite recent because I never noticed in the past.

Comments

dave bruns’s picture

Just confirming that I've seen the same problem on a site I'm testing. However, one correction, the conflict is not with Profile2, but rather with Profile2 Registration Path (https://www.drupal.org/project/profile2_regpath)

The problem seems to be that Profile2 reg path relies on the form #action, i.e. in profile2_regpath_form_alter:

$url = drupal_parse_url($form['#action']);

but commerce checkout redirect unsets $form['#action'] in commerce_checkout_redirect_form_alter:

// Append the checkout redirect function on user's forms.
$form['#submit'][] = 'commerce_checkout_redirect_redirect_anonymous_submit';
unset($form['#action']);
kunalkursija’s picture

I also faced this #action issue , this was breaking profile registration page on site.

i had no time to fix this, so i uninstalled the module and fix checkout redirection by using "checkout_router" .

oksana-c’s picture

This solution does not involve modification of Commerce Checkout Redirect module.

I was able to fix same issue in my implementation of commerce + profile2 + profile2 reg path by modifying a line in profile2_regpath.module:

<?php 
/**
 * Implements hook_form_alter().
 */
function profile2_regpath_form_alter(&$form, &$form_state, $form_id) {
  $menu_item = menu_get_item();
.......
.......
else {
      // Get profile2 profile types from current path.
      -      $url = drupal_parse_url($form['#action']);
     +      $url = drupal_parse_url(current_path());
.......
?>
spanners’s picture

#3 fixed my issue. Thank you.

drupal-son’s picture

Same issue here.
When anonymous user registered using profile2 registration path, it assigned all roles instead the registration path role.
This error message is present in logs: Notice: Undefined index: #action in profile2_regpath_form_alter() (line 427 of /srv/bindings/44d5fa834e8a49ff83095483f58d6e8d/code/sites/all/modules/profile2_regpath/profile2_regpath.module).

#3 fixed the issue.

You should think on publish a patch here https://www.drupal.org/node/2502115

Thanks.