1

so i have this page on my site,add to cart image

i can redirect my user to, something if the user isnt logged in, my redirection page is here, redirect image

what i want now is after the user register/log in, he will be back to add To Cart page(1st image) or to his cart with the item/product added...

i tried using rules but i can only redirect to the product/item page, i want the item the user chooses to be added the card before he registered/login..

anyone get me? thanks for the support :)

Muhammad Reda
  • 26,379
  • 14
  • 93
  • 105

2 Answers2

0

The only way is to check to see if there are any orders stored in session on the submit of login and registeration forms.

You can check if any orders in session using commerce_cart_order_session_exists()

Create a custom module, and the code would look like this:

/**
* Implementation of hook_form_alter()
*/
function [YOUR_MODULE]_form_alter(&$form, &$form_state, $form_id)
{
    $myForms = array('user_login_block', 'user_login', 'user_register_form');
    if(in_array($myForms, $form_id))
    {
        $form['submit'][] = '_yourmodule_form_submit';
    }
}

/**
* Custom form submission callback
*/    
function _yourmodule_form_submit($form, &$form_state)
{
    if(commerce_cart_order_session_exists())
        $form_state['redirect'] = 'cart';
}
Muhammad Reda
  • 26,379
  • 14
  • 93
  • 105
0

Use destination on Please login to continue... tpl page.

echo l('Log in', 'YOUR_LINK', array('query'=>array('destination'=>PRODUCT_LINK)));
echo l('Personal', 'YOUR_LINK', array('query'=>array('destination'=>PRODUCT_LINK)));
echo l('Business', 'YOUR_LINK', array('query'=>array('destination'=>PRODUCT_LINK)));

This will redirect to you product page after user action.