Jump to content

Recommended Posts

Hello everyone!

I made a new module from scratch.

This module allows to emulate a customer loggin, accessing from the BackOffice. Therefore, you can place an order on behalf of the client, so that the statistics and stock'll reflect same as if your client would placed it. ;)

It is very useful especially when your customers aren't able to make the purchase process by themselves (and as you surely know, that happens pretty often! :wub: )

The installation is quite easy. You have to install it as any other prestashop module. Then, go to the customer's details in the backoffice, and you'll see a LogIn button. By clicking in that button, you'll be redirected to the FrontEnd, logged on with the user that you'd chosen. Once logged in you'll be able to purchase the products that your clients ask you. This module also recover the previous cart for the selected customer (if you have active this option in your general preferences).

EDIT: Tested on prestashop 1.4.3.0, 1.4.6 and 1.4.8.2 (I think it works with lower versions, but I haven't tested it)

I've seen a similar paid modules. But I made this by myself, and it's totally free!! I hope you enjoy it! :D

Cheers!!

Axel

PS: Questions, suggestions, comments, donations and/or thanks, are always welcomed! Thank you!

I have published the module version for PrestaShop 1.5 at:
http://www.prestashop.com/forums/topic/191817-module-ps15x-login-as-customer-axel/

EDIT: VERSION 1.1 (09/27/2012)
fixed SSL BUG.
Added backward compatibility
Added customer/guest check.

post-332972-0-62494100-1342412685_thumb.png

post-332972-0-21723600-1342412697_thumb.png

Edited by axelmdp (see edit history)
  • Like 5

Share this post


Link to post
Share on other sites

Thanks for the module, it can be very usefull and your instructions are simple and clear.

 

I will try it... and thank you for sharing this free module :)

  • Like 1

Share this post


Link to post
Share on other sites

You're welcome navid68. Thanks for downloading! :) It would be nice if you can post your opinion after try it.

 

Cheers! :rolleyes:

 

Axel

Share this post


Link to post
Share on other sites

Hello Dumbelo. If you get a white blank screen, it is because the token validation isn't going well. Could you add this line in login.php at line 26 (just after the $token assign) and tell me what you see? :

 

echo 'POST='.$_POST['p4MfOvSZCwcPLsOZCU0UP01YAaqGlkXFEEJN1qhpZAq9OFnrzkLo483IXRGlZACjW9ZAMi8K5iKUnZAZAXZBqjE0XByw7YcQZCj'].'<br>';
echo 'TOKEN='.$token;

 

I'll be waiting for your reply.

 

Thank you for use this module! Cheers

 

AXEL

Share this post


Link to post
Share on other sites

Hello Axel

 

After these lines you mentioned I get white screen and this text

 

POST=

TOKEN=4b2e91c62298520bf69e1577b2012754

 

Just wondering what that means?

 

Thank you for help!

Share this post


Link to post
Share on other sites

Hello Dumbelo. That is weird. It means that the login.php page is not receiving any value for the POST variable.

 

Now, try this:

Edit the "loginascustomer.php" file and replace the line 76 with this:

return $_html.'<p>TOKEN='.$token.'</p>';

Then, try again. Now, in the customer screen, below Login button you'll see something like "TOKEN= ..... ". Please, tell me exactly what you see. The string at the right, should be something similar to the value that is shown in "login.php" (if you try with same customer as above, the value should be the same)

 

Did this happen to someone else?

 

BTW: Dumbelo: What browser are you using? Did you try with another browser?

 

I'll be waiting for your reply. Thanks!

 

Axel

Share this post


Link to post
Share on other sites

Hello Axel

 

Yes, I use Firefox 12.0 and tried it with IE 9.0....=> No help. I get same echo message as with Firefox.

 

I put your given line to loginascustomer.php in line 76.

 

I get this message below "login" button (customer is the same):

 

TOKEN=4b2e91c62298520bf69e1577b2012754

 

Thank you!

 

Edit: I tried to update Firefox to 14.0.1. No help with that.

Edited by Dumbelo (see edit history)

Share this post


Link to post
Share on other sites

Ummm... that is really strange. I can see that the value for token it is the same; so, it seems like if the value assigned to the post variable gets lost in somewhere.

 

Please, try replacing both files (login.php and loginascustomer.php) with the ones that I attached here. I renamed the post variable (now its name is simply "token"). I hope it works now! If not, please try to inspect with Firebug and see if you find a hidden input called "token" with the right value within the form near the login button.

 

Tell me how it was! Thank you.

 

Axel

 

Edit: The changes introduced here were definitely integrated on module version 1.1.

Edited by axelmdp (see edit history)

Share this post


Link to post
Share on other sites

Yeah! Got it working with your files.

 

Altough...

 

I made in with customer, I made order for her and...In payment module ( 3rd party), validition.php went in white screen. Order is not shown in BO, but it is in customers "my account". Funny, but not so handy....

 

This is not happening when I login and try to make order.

Edited by Dumbelo (see edit history)

Share this post


Link to post
Share on other sites

Ok Dumbelo! I'm glad that it worked; but I don't know why didn't work from beginning. :unsure:

 

In regards to the validation.php issue... I don't know!! :wacko: this shouldn't happen. I tested with Prestashop 1.4.8.2, and it works. I still can't figure out what is the cause of the problem, sorry.

 

Please tell me all the information you can provide, and I'll try help you.

 

Also it would help if anyone else could comment if it has getting the same problem or not.

 

Thank you!

 

Axel

Edited by axelmdp (see edit history)

Share this post


Link to post
Share on other sites

Hi,

 

Thanks for the module, could be very handy however I get a class "compareproduct" not found in LoginAsCustomerController.php on line 33. I am using an older version 1.4.0.17. Perhaps it's not compatable?

Share this post


Link to post
Share on other sites

Hello Moonmosaic. Perhaps it's not compatible, but the Compareproduct cookie is not esential. So, you could try to remove the line number 33 in LoginAsCustomerController.php.

 

I hope it help you. Thank you!

 

Axel

Edited by axelmdp (see edit history)

Share this post


Link to post
Share on other sites

Hello Axel

 

 

I got a page with this when I click "login" in customer :

Notice: Undefined index: p4MfOvSZCwcPLsOZCU0UP01YAaqGlkXFEEJN1qhpZAq9OFnrzkLo483IXRGlZACjW9ZAMi8K5iKUnZAZAXZBqjE0XByw7YcQZCj in /myshop.com/modules/loginascustomer/login.php on line 26

 

Thanks

Share this post


Link to post
Share on other sites

Hello Stamus. Please, try doing what I described in post #9:

Please, try replacing both files (login.php and loginascustomer.php) with the ones that I attached here. I renamed the post variable (now its name is simply "token"). I hope it works now!

Tell me how it was! Thank you.

 

Axel

Share this post


Link to post
Share on other sites

Hello Stamus. Please, try doing what I described in post #9:

 

Tell me how it was! Thank you.

 

Axel

 

 

 

when I click on login I go to myshop.com/myaccount.php with : fatal error

 

Thank you

Share this post


Link to post
Share on other sites

when I click on login I go to myshop.com/myaccount.php with : fatal error

Please, tell me which prestashop version are you using. Maybe is an older one?

 

Cheers,

 

Axel

Edited by axelmdp (see edit history)

Share this post


Link to post
Share on other sites

Please, tell me which prestashop version are you using. Maybe is an older one? If so, take this in account:

 

 

Cheers,

 

Axel

My prestashop version is 1.4.8.2

My code in AuthController.php is :

 

if (Tools::isSubmit('SubmitLogin'))
{
Module::hookExec('beforeAuthentication');
$passwd = trim(Tools::getValue('passwd'));
$email = trim(Tools::getValue('email'));
if (empty($email))
$this->errors[] = Tools::displayError('E-mail address required');
elseif (!Validate::isEmail($email))
$this->errors[] = Tools::displayError('Invalid e-mail address');
elseif (empty($passwd))
$this->errors[] = Tools::displayError('Password is required');
elseif (Tools::strlen($passwd) > 32)
$this->errors[] = Tools::displayError('Password is too long');
elseif (!Validate::isPasswd($passwd))
$this->errors[] = Tools::displayError('Invalid password');
else
{
$customer = new Customer();
$authentication = $customer->getByEmail(trim($email), trim($passwd));
if (!$authentication OR !$customer->id)
{
/* Handle brute force attacks */
sleep(1);
$this->errors[] = Tools::displayError('Authentication failed');
}
else
{
self::$cookie->id_compare = isset(self::$cookie->id_compare) ? self::$cookie->id_compare: CompareProduct::getIdCompareByIdCustomer($customer->id);
self::$cookie->id_customer = (int)($customer->id);
self::$cookie->customer_lastname = $customer->lastname;
self::$cookie->customer_firstname = $customer->firstname;
self::$cookie->logged = 1;
self::$cookie->is_guest = $customer->isGuest();
self::$cookie->passwd = $customer->passwd;
self::$cookie->email = $customer->email;
if (Configuration::get('PS_CART_FOLLOWING') AND (empty(self::$cookie->id_cart) OR Cart::getNbProducts(self::$cookie->id_cart) == 0))
self::$cookie->id_cart = (int)(Cart::lastNoneOrderedCart((int)($customer->id)));
/* Update cart address */
self::$cart->id_carrier = 0;
self::$cart->id_address_delivery = Address::getFirstCustomerAddressId((int)($customer->id));
self::$cart->id_address_invoice = Address::getFirstCustomerAddressId((int)($customer->id));
// If a logged guest logs in as a customer, the cart secure key was already set and needs to be updated
self::$cart->secure_key = $customer->secure_key;
self::$cart->update();
Module::hookExec('authentication');
if (!Tools::isSubmit('ajax'))
{
if ($back = Tools::getValue('back'))
Tools::redirect($back);
Tools::redirect('my-account.php');
}
}
}

Edited by Stamus (see edit history)

Share this post


Link to post
Share on other sites

Ok Stamus, thanks for the info. I based on the SAME file version that you (but the module it works for me, lol). Could you provide more information about the "fatal error"? It generated a "error_log" file in some folder? I'd really like help you with this.

 

Thank you.

 

Axel

Share this post


Link to post
Share on other sites

Hello Axel

 

I see that you are strugling with other things, just mentioning that your module looks to work perfect now.

I had updated from 1.3 to 1.4.8.2, so I had one module which was not working with 1.4.8.2. I updated it and

with same your module works ok.

 

Thanks for help!

  • Like 1

Share this post


Link to post
Share on other sites
... I updated it and with same your module works ok. Thanks for help!

Hello Dumbelo! I'm glad to read you and know that it works now. :)

 

Any other help that you could need, please feel free to contact me.

 

@moonmosaic, @stamus: Are there any news regarding your respective issues?

 

Greetings,

 

Axel

Share this post


Link to post
Share on other sites

Ummm... that is really strange. I can see that the value for token it is the same; so, it seems like if the value assigned to the post variable gets lost in somewhere.

 

Please, try replacing both files (login.php and loginascustomer.php) with the ones that I attached here. I renamed the post variable (now its name is simply "token"). I hope it works now! If not, please try to inspect with Firebug and see if you find a hidden input called "token" with the right value within the form near the login button.

 

Tell me how it was! Thank you.

 

Axel

 

Nice module, had the same probleme like Dumbelo but solved with post #9

Share this post


Link to post
Share on other sites

Nice module, had the same probleme like Dumbelo but solved with post #9

Cool Outblast! I'm glad to read you. :) Thanks for comment. Cheers!

Share this post


Link to post
Share on other sites

hello

when I try to log in as a customer, I am getting 500Internal Server Error

I use ps1.4.7.0

 

any idea?

Share this post


Link to post
Share on other sites

when I try to log in as a customer, I am getting 500Internal Server Error

I use ps1.4.7.0

Hello a_smith; The error you are getting is too generic. I cannot know the specific cause, but I suggest you look in your server's folders and see if there is any error_log file (at your root folder, at modules/loginascustomer, or within your administration folder). Also please check if the file coding for php files within loginascustomer folder is Ok (I used Unix EOL format).

 

Please, let me know if you can solve this issue.

 

Thank you!

Share this post


Link to post
Share on other sites

This module worked great for me the very first time I used it. It refuses to login again since then, all I get is a fatal error, with the address of https://mywebsite.co...omer/login.php. Any ideas? I did try the updated files you posted, and those did not help either.

Hello jowaju. I see you are using HTTPS; I couldn't test the module with HTTPS because I don't use any server with that. But I thought there shouldn't be problems. Please, try deleting the cookies of your browser and try accessing again. Please let me know if you can draw any conclusions.

 

Thanks!

Share this post


Link to post
Share on other sites

Hello again,

 

I've looked into the server logs, and only one message I see is in Apache error log:

[notice] EACCELERATOR(9090): PHP crashed on opline 25 of main() at /var/www/web-owner/data/www/xxxxxxxxxxl/modules/loginascustomer/login.php:28

 

I am on a new server recently. The old server had no eAccelerator installed but I was getting the seme issue (http 500). So I assume that this problem is not eAccelerator related.

 

Line 25 of login.php is

$token = Tools::getAdminToken('LoginAsCustomer'.$id_customer);

 

After I put extra code from your post #5 i can see that POST value is empty and only TOKEN is returned.

 

I have replaced original files with the two you gave in post #9. Still, under FF I am getting blank screen and HTTP 500 under IE8. ps1.4.7.0

 

Any help?

Regards

Edited by a_smith (see edit history)

Share this post


Link to post
Share on other sites

After I put extra code from your post #5 i can see that POST value is empty and only TOKEN is returned.

 

I have replaced original files with the two you gave in post #9. Still, under FF I am getting blank screen and HTTP 500 under IE8. ps1.4.7.0

Hello again a_smith :) I see you are now using post #9's files. This is a correct step, because previously the POST value was empty. Could you please add this code in login.php at line 26 (just after the $token assign) and tell me what you see? :

echo 'POST='.$_POST['token'].'<br>';
echo 'TOKEN='.$token;

 

Both values should be the same.

 

BTW: I think the real error is not on line 25; when you added the code from post #5, the line 26 and 27 were properly reached as you could see the values on the screen.

 

I look forward for your reply. Cheers!

 

Axel

Share this post


Link to post
Share on other sites

Thanks Axel for your reply. With 'echo' lines added the token and post are both returned and they same value.

Unfortunatelly even with the 2 files from post #9 I am getting HTTP500 and blank screen as commented above.

In error log I see

[notice] EACCELERATOR(9090): PHP crashed on opline 25 of main() at /var/www/web-owner/data/www/xxxxxxxxxxl/modules/loginascustomer/login.php:28

Share this post


Link to post
Share on other sites

Thanks Axel for your reply. With 'echo' lines added the token and post are both returned and they same value.

Unfortunatelly even with the 2 files from post #9 I am getting HTTP500 and blank screen as commented above.

In error log I see

[notice] EACCELERATOR(9090): PHP crashed on opline 25 of main() at /var/www/web-owner/data/www/xxxxxxxxxxl/modules/loginascustomer/login.php:28

Hello a_smith. I'll try to help you. Can you please replace the code within "login.php" with the code below? :

require(dirname(__FILE__). '/../../config/config.inc.php');
$id_customer = (int)$_POST['id_customer'];
$token = Tools::getAdminToken('LoginAsCustomer'.$id_customer);
echo 'POST='.$_POST['token'].'<br>';
echo 'TOKEN='.$token.'<br>';
if($_POST['token'] == $token) {
  echo 'A<br>';
  ControllerFactory::includeController('AuthController');
  echo 'B<br>';
  require_once(dirname(__FILE__). '/LoginAsCustomerController.php');
  echo 'C<br>';
  $loginAsCustomerController = new LoginAsCustomerController(false, false);
  echo 'D<br>';
  $loginAsCustomerController->run();
  echo 'E<br>';
} else {
  echo 'F<br>';
}

 

Then, please tell me what you see. It will help to determine which line is having trouble.

 

Cheers,

 

Axel

Share this post


Link to post
Share on other sites
Hello a_smith. I'll try to help you. Can you please replace the code within "login.php" with the code below? :
 require(dirname(__FILE__). '/../../config/config.inc.php'); $id_customer = (int)$_POST['id_customer']; $token = Tools::getAdminToken('LoginAsCustomer'.$id_customer); echo 'POST='.$_POST['token'].'
'; echo 'TOKEN='.$token.'
'; if($_POST['token'] == $token) { echo 'A
'; ControllerFactory::includeController('AuthController'); echo 'B
'; require_once(dirname(__FILE__). '/LoginAsCustomerController.php'); echo 'C
'; $loginAsCustomerController = new LoginAsCustomerController(false, false); echo 'D
'; $loginAsCustomerController->run(); echo 'E
'; } else { echo 'F
'; } 

Then, please tell me what you see. It will help to determine which line is having trouble. Cheers, Axel

 

Hello Axel,

 

I'm having the same problem getting a blank screen. I've already changed the files login.php and loginascustomer.php from post 9.

The respons from the site when i replace the code with the above code is:

 

POST=049754c310f24fe3326b74a4484c369d

TOKEN=049754c310f24fe3326b74a4484c369d

A

B

C

D

 

Hope this helps solving the problem. I'm using PS 1.4.8.2 and https

 

regards Maniot

Edited by maniot (see edit history)

Share this post


Link to post
Share on other sites

Hello Axel,

 

I'm having the same problem getting a blank screen. I've already changed the files login.php and loginascustomer.php from post 9.

The respons from the site when i replace the code with the above code is:

 

POST=049754c310f24fe3326b74a4484c369d

TOKEN=049754c310f24fe3326b74a4484c369d

A

B

C

D

 

Hope this helps solving the problem. I'm using PS 1.4.8.2 and https

 

regards Maniot

 

Hello Maniot. Thanks for post your issue here. I hope I can help you.

 

Thank for the output info. Now, please do the following:

1 - Go back to the original version of login.php file (from post 9).

2 - Edit "LoginAsCustomerController.php" in order to add this five echo sentences for debugging:


public function preProcess() {
  $id_customer = (int)$_POST['id_customer'];
  echo 'id_customer: '.$id_customer.'<br>';
  Module::hookExec('beforeAuthentication');
  $customer = new Customer($id_customer);
  echo 'customer: '.$customer->firstname.'<br>';
  if($id_customer != 0 and $customer->firstname != NULL and $customer->firstname != '') {
  echo 'A <br>';
  self::$cookie->id_compare = isset(self::$cookie->id_compare) ? self::$cookie->id_compare: CompareProduct::getIdCompareByIdCustomer($customer->id);
  self::$cookie->id_customer = (int)($customer->id);
  self::$cookie->customer_lastname = $customer->lastname;
  self::$cookie->customer_firstname = $customer->firstname;
  self::$cookie->logged = 1;
  self::$cookie->is_guest = $customer->isGuest();
  self::$cookie->passwd = $customer->passwd;
  self::$cookie->email = $customer->email;
  if (Configuration::get('PS_CART_FOLLOWING'))
		self::$cookie->id_cart = (int)(Cart::lastNoneOrderedCart((int)($customer->id)));
  self::$cart->id_carrier = 0;
  self::$cart->id_address_delivery = Address::getFirstCustomerAddressId((int)($customer->id));
  self::$cart->id_address_invoice = Address::getFirstCustomerAddressId((int)($customer->id));
  self::$cart->secure_key = $customer->secure_key;
  self::$cart->update();
  Module::hookExec('authentication');
  echo 'B <br>';
  Tools::redirect('my-account.php');
  }
  echo 'F <br>';
}

 

Try with this, and tell me what you see. Also please tell me if you see any "error_log" file on modules folder, on another location.

 

Cheers,

 

Axel

Share this post


Link to post
Share on other sites

Hello Axel,

 

Thank you for your fast respons.

The result after changing the code in "LoginAsCustomerController.php" gives me a blank screen. I didn't find any file named "error_log"

 

Regards

 

Maniot

Share this post


Link to post
Share on other sites

The result after changing the code in "LoginAsCustomerController.php" gives me a blank screen. I didn't find any file named "error_log"

Hello Maniot. I see. It seems that "preProcess" method is never reached. Unfortunately I haven't a server with https in order to reproduce and solve your problem now. But maybe next week I could configure an https server on my localhost. Meanwhile, can you please modify the "canonicalRedirection" method on "LoginAsCustomerController" as it's specified below? :


protected function canonicalRedirection() {
  echo 'cannonicalRedirection<br>';
}

This is for be sure that this method is reached.

 

 

Please also restore the "preProcess" method to the original version.

 

I think there is something related with https that I didn't take in account and I would like to analyze it. If you want, you'll can contact me on Skype (seek for my skype ID on my profile).

 

Thank you! Cheers,

 

Axel

Share this post


Link to post
Share on other sites

Hello Axel,

 

I changed the code in "LoginAsCostumerController" and it gives me a blank screen.

I disabled https and tried again and it worked :rolleyes:. After re-enabeling https it still continued to work.

After that i disconnected from the admin area and logged in again; to my surprise it gave me again a blank screen <_< while htpps was enabled. So i think what you assumed is correct it has something to do with https.

I also found 2 files in the folder "modules" named login.php and loginascustomer.php which i deleted.

 

Hope this helps you solving the problem.

 

Regards

 

Maniot

Share this post


Link to post
Share on other sites

I changed the code in "LoginAsCostumerController" and it gives me a blank screen.

I disabled https and tried again and it worked :rolleyes:. After re-enabeling https it still continued to work.

After that i disconnected from the admin area and logged in again; to my surprise it gave me again a blank screen <_< while htpps was enabled. So i think what you assumed is correct it has something to do with https.

Hello Maniot. Thank you very much for your information. That gives me a clue. I'll try to reproduce it, and I'll tell you what I found. :ph34r:

I also found 2 files in the folder "modules" named login.php and loginascustomer.php which i deleted.

I think you had put accidentally these files on folder modules (because the code doesn't perform any copy operation). :huh: Maybe you had copied the two files from post #9 on modules folder instead modules/loginascustomer. Anyway, they couldn't cause any trouble there.

 

I hope I can help you. I'll let you know when I have some news. :D

 

Thanks!

 

Axel

Share this post


Link to post
Share on other sites

Yes, it was me probably who put the files in the folder modules. If i can assist in anyway by performing tests, please let me know.

 

I've noticed that if i have been connected as a customer, i have to clear cookies otherwise i get the error " you are not allowed to view this categorie" and i can't change language.

After i deleted the cookies everything was back to normal.

 

Thanks

 

Maniot

Edited by maniot (see edit history)

Share this post


Link to post
Share on other sites

Thank you Maniot for the information. If I'm able to reproduce the error, I'll find a solution and I'll post it here. I'm sorry, but I still couldn't try because I'm too busy this days. But surely next week I'll can do it, I promise you.

 

Cheers,

 

Axel

Share this post


Link to post
Share on other sites

I changed the code in "LoginAsCostumerController" and it gives me a blank screen.

I disabled https and tried again and it worked :rolleyes:. After re-enabeling https it still continued to work.

After that i disconnected from the admin area and logged in again; to my surprise it gave me again a blank screen <_< while htpps was enabled. So i think what you assumed is correct it has something to do with https.

 

Hi Maniot. I have some good news for you!!! :rolleyes: Finally, as I promised, I was able to reproduce the error and I found the issue.

 

The problem arose when the SSL configuration is ENABLED and the access to the BO uses HTTP (without "S"). The link generated start with "http"; so, according to the confiuration it was redirected to HTTPS and finally the request couldn't continue. So, I fixed the issue making the link generation according to the SSL configuration and... problem solved :)

 

Now, you'll can download the current latest version (v1.1), published on the post #1. I hope I can solve your issue with this! Please give me your feedback.

 

If it is useful for you, please consider making a donation ;-) I really would appreciate that.

 

 

 

nice!

 

Thanks fernando! ^_^

 

Cheers,

 

Axel

Share this post


Link to post
Share on other sites

Hi Axel,

 

Thanks for all your wonderfull support. I will check it out and come back with the results.

 

Regards,

 

Maniot

  • Like 1

Share this post


Link to post
Share on other sites

Hi Axel,

 

Thanks for all your wonderfull support. I wil check it out and come back with the results.

 

Regards,

 

Maniot

 

Hello Maniot! You're welcome! I'm sure that now it will work for you. Please, let me know how it was. ;)

Share this post


Link to post
Share on other sites

hi,

 

tried with latest 1.5.17 and not working. Admin customer deatil page, click on LogIn and -> http://localhost/pre...tomer/login.php HTTP 500 (Internal Server Error

 

Hello Ender666. This free module won't work for PS1.5. I've created the same module for PS1.5 (including backward compatibilty), but I'm afraid that it is not free. It only costs a donation of at least U$S 9,00 . You can find the topic here:

 

http://www.prestasho...-customer-axel/

 

If you are interested, please don't hesitate to contact me, and I give you the proper module for PS1.5

 

Thank you very much!

 

Axel

Share this post


Link to post
Share on other sites

The new 1.1 version works perfectly for me! Thanks so much!

  • Like 1

Share this post


Link to post
Share on other sites

The new 1.1 version works perfectly for me! Thanks so much!

 

I'm really glad to know it. :) Thank you very much for your comment Jowaju. Enjoy it!

 

Cheers,

 

Axel

Share this post


Link to post
Share on other sites

I'use on my store and its work very fine

 

Tks a lot Axel for the support

I'll give you a donation.

 

Dashe

www.beer-shop.it

  • Like 1

Share this post


Link to post
Share on other sites

hello Axel

 

This is regardles of SSL on or off, I did try both

 

I did try ver1.0 and I got blank screen issue. I updated to ver1.1 and still I am getting blank screen when loging in as a customer. PS 1.4.7.0

Share this post


Link to post
Share on other sites

hello Axel

 

This is regardles of SSL on or off, I did try both

 

I did try ver1.0 and I got blank screen issue. I updated to ver1.1 and still I am getting blank screen when loging in as a customer. PS 1.4.7.0

Hello again, a_smith. I'm willing to help you. So, I'd like to know if you could try the procedure that I told you on post #32. Could you tell me which was the output?

 

Thank you. Cheers,

 

Axel

Share this post


Link to post
Share on other sites

We have this module in 1.5.2 and so far so good.

It works great.

 

Thanks for the comment!!! :-) I'm glad to know it.

Share this post


Link to post
Share on other sites

Hi Axel... just to let you know, I installed this module on a fresh, live 1.5.4 store and it seem to work exactly as described... my client is thrilled that he handle his call-in customers this way. Thanks a bunch!

 

Rod

 

P.S. I'm taking you up on your special offer based my biggie-size donation... Thanks again.

Share this post


Link to post
Share on other sites

Hello All,

 

To make this module Work in Prestashop 1.5.x.y there needs some minor changes to do in module. Here are all that changes...

 

1) Open login.php file and replace ( line 27 ) this

ControllerFactory::includeController('AuthController');

With this code

Controller::getController('AuthController');

2) Open LoginAsCustomerController.php File and do following changes.

 

2 -a)Replace ( Line 30 ) this 

Module::hookExec('beforeAuthentication');

With this code 

Hook::exec('beforeAuthentication');

2 -b ) Replace ( From Line 33 to 54 ) this code

$ps_version = substr(_PS_VERSION_,0,5);			
if($ps_version>='1.4.6') {				
	self::$cookie->id_compare = isset(self::$cookie->id_compare) ? self::$cookie->id_compare: CompareProduct::getIdCompareByIdCustomer($customer->id);
}			
self::$cookie->id_customer = (int)($customer->id);
self::$cookie->customer_lastname = $customer->lastname;
self::$cookie->customer_firstname = $customer->firstname;
self::$cookie->logged = 1;
self::$cookie->is_guest = $customer->isGuest();
self::$cookie->passwd = $customer->passwd;
self::$cookie->email = $customer->email;
if (Configuration::get('PS_CART_FOLLOWING'))
	self::$cookie->id_cart = (int)(Cart::lastNoneOrderedCart((int)($customer->id)));
self::$cart->id_carrier = 0;
self::$cart->id_address_delivery = Address::getFirstCustomerAddressId((int)($customer->id));
self::$cart->id_address_invoice = Address::getFirstCustomerAddressId((int)($customer->id));
if($ps_version>='1.4.6') {
	self::$cart->secure_key = $customer->secure_key;
}
self::$cart->update();
Module::hookExec('authentication');
Tools::redirect('my-account.php');

with this code 

$this->context->cookie->id_compare = isset($this->context->cookie->id_compare) ? $this->context->cookie->id_compare: CompareProduct::getIdCompareByIdCustomer($customer->id);
$this->context->cookie->id_customer = (int)($customer->id);
$this->context->cookie->customer_lastname = $customer->lastname;
$this->context->cookie->customer_firstname = $customer->firstname;
$this->context->cookie->logged = 1;
$customer->logged = 1;
$this->context->cookie->is_guest = $customer->isGuest();
$this->context->cookie->passwd = $customer->passwd;
$this->context->cookie->email = $customer->email;

// Add customer to the context
$this->context->customer = $customer;

if (Configuration::get('PS_CART_FOLLOWING') && (empty($this->context->cookie->id_cart) || Cart::getNbProducts($this->context->cookie->id_cart) == 0))
	$this->context->cookie->id_cart = (int)Cart::lastNoneOrderedCart($this->context->customer->id);

// Update cart address
$this->context->cart->id = $this->context->cookie->id_cart;
$this->context->cart->setDeliveryOption(null);
$this->context->cart->id_address_delivery = Address::getFirstCustomerAddressId((int)($customer->id));

$this->context->cart->id_address_invoice = Address::getFirstCustomerAddressId((int)($customer->id));
$this->context->cart->secure_key = $customer->secure_key;
$this->context->cart->update();
$this->context->cart->autosetProductAddress();

Hook::exec('actionAuthentication');

// Login information have changed, so we check if the cart rules still apply
CartRule::autoRemoveFromCart($this->context);
CartRule::autoAddToCart($this->context);

Do these changes and you are able to login from backoffice. That's It!!! Enjoy....

Edited by divyeshp (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

anyone test it for ps 1.5.6?

 

sorry the link for 1.5 is here

 

but i don't understand it's free or paid?

 

where can i download the last version for ps 1.5.6?

 

thanks

Edited by papich (see edit history)

Share this post


Link to post
Share on other sites

they... just posted the information that you're looking for, papich. Try to read a bit before writing.

Share this post


Link to post
Share on other sites

Hello All.

 

To work "Login As Customer" in 1.5.6 here are final steps to do, it's working and tested well.

Download module from here,

Do the changes I have suggested in comment  #55, In addition to this do one more change as suggested below,

 

Open LoginAsCustomerController.php File and replace ( line 25 ) this code

protected function canonicalRedirection() {
	}

with this


protected function canonicalRedirection() {
		$this->preProcess();
	} 

Do these all changes and it will work fine.

Edited by divyeshp (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

Hello everyone!

 

I made a new module from scratch.

 

This module allows to emulate a customer loggin, accessing from the BackOffice. Therefore, you can place an order on behalf of the client, so that the statistics and stock'll reflect same as if your client would placed it. ;)

 

It is very useful especially when your customers aren't able to make the purchase process by themselves (and as you surely know, that happens pretty often! :wub: )

 

The installation is quite easy. You have to install it as any other prestashop module. Then, go to the customer's details in the backoffice, and you'll see a LogIn button. By clicking in that button, you'll be redirected to the FrontEnd, logged on with the user that you'd chosen. Once logged in you'll be able to purchase the products that your clients ask you. This module also recover the previous cart for the selected customer (if you have active this option in your general preferences).

 

EDIT: Tested on prestashop 1.4.3.0, 1.4.6 and 1.4.8.2 (I think it works with lower versions, but I haven't tested it)

 

I've seen a similar paid modules. But I made this by myself, and it's totally free!! I hope you enjoy it! :D

 

Cheers!!

 

Axel

 

PS: Questions, suggestions, comments, donations and/or thanks, are always welcomed! Thank you!

 

I have published the module version for PrestaShop 1.5 at:

http://www.prestashop.com/forums/topic/191817-module-ps15x-login-as-customer-axel/

 

EDIT: VERSION 1.1 (09/27/2012)

fixed SSL BUG.

Added backward compatibility

Added customer/guest check.

 

module free?

where?

i want try it, but i not downloading module

for ps 1.4

Share this post


Link to post
Share on other sites

I'm having a slight problem... when I click on the icon to login as customer, the incorrect name is at the top and correct lower right under 'Your Account'... and the account is correct... just the name at the top where it reads 'Welcome, xxxxx xxxxx'

Share this post


Link to post
Share on other sites

Hello Axel

Unfortunatelly there is a problem with your module ver 2.6.1 for PS1.6.

It doesn’t work on multistore.

I can login as a customer but only when working in main (primary) store context.

 

It is not possible to log as a customer for any other store (multistore).

Regardles of which store context is active, your module always keep redirecting to main store URL and not to active store URL.

 

Previous version was working fine on multistore. Any chance for you to fix it please?

 

Thanks

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More