diff --git a/uc_node_checkout.module b/uc_node_checkout.module index 9c0b8f7..a79b6e6 100644 --- a/uc_node_checkout.module +++ b/uc_node_checkout.module @@ -414,7 +414,31 @@ function uc_node_checkout_form_alter(&$form, &$form_state, $form_id) { // If specified, redirect anonymous customers to login. if (variable_get('uc_node_checkout_node_access', TRUE) && !$user->uid) { drupal_set_message(t('You must login or create a user account to continue.')); - $_SESSION['node_checkout_redirect'] = array('node/add/'. str_replace('_', '-', $type), 'product_nid='.$product_nid); + // Construct the 'get' array to pass information about the node the user has just configured + $get = array('product_nid='. $product_nid); + + // Pass the qty. if specified. + if (!empty($form['default_qty']['#value']) && intval($form['default_qty']['#value']) > 0) { + $get[] = 'qty='. intval($form['default_qty']['#value']); + } + + // Pass the attributes selections in the URL. + $attr = array(); + + foreach (element_children((array) $form['attributes']) as $aid) { + $oid = $form['attributes'][$aid]['#default_value']; + if ($form['attributes'][$aid]['#type'] == 'checkboxes') { + $oid = implode('|', $oid); + } + $attr[] = $aid .'-'. check_plain($oid); + } + + if (!empty($attr)) { + $get[] = 'attr='. implode('_', $attr); + } + + // Redirect them to the node add form after login or registration + $_SESSION['node_checkout_redirect'] = array('node/add/'. str_replace('_', '-', $type), implode('&', $get)); drupal_goto('user'); } else {