Force a logout out at end of a purchase?

  • Posts: 23
  • Thank you received: 2
9 years 5 months ago #180994

YeeP, did you try adding http:// onto the code I posted? Sometimes joomla does that to me if I just do www.

Sorry if I am stating the obvious :) Try:

<?php
/**
 * @package	HikaShop for Joomla!
 * @version	2.3.4
 * @author	hikashop.com
 * @copyright	(C) 2010-2014 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php
$app = JFactory::getApplication();
$app->enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') );

/*
Added custom code below to force a user logout when a purchase is complete.
Find problem solving here:
http://www.hikashop.com/forum/customers/873174-force-a-logout-out-at-end-of-a-purchase.html
*/
$app = JFactory::getApplication(); 
$app->logout();
header( "Location: http://www.domain.com/redirectpage.php" );
exit;
?>

Last edit: 9 years 5 months ago by webcandy.

Please Log in or Create an account to join the conversation.

  • Posts: 49
  • Thank you received: 1
9 years 5 months ago #180995

Understood. I will try that now. Just FYI, at least I know it is hitting the right processes here, even though the redirect is not working.

If I refresh after the purchase, the phantom cart goes away (CTRL-F5 on my browser before a new purchase and cache dump on the site made no difference to the amount in phantom cart) but I am still at the following url:

https://www.domain.com/index.php?option=com_hikashop&ctrl=checkout&task=after_end&order_id=15

Trying your idea now..

EDIT:
webcandy - just so you know, nicolas never closed the php brackets in that file, even after his recommended change. I am going to remove that line of code to keep it in the same "status" for whatever file it goes to next.

Last edit: 9 years 5 months ago by YeeP.

Please Log in or Create an account to join the conversation.

  • Posts: 23
  • Thank you received: 2
9 years 5 months ago #180997

my "?>" added at the end should take care of that

Last edit: 9 years 5 months ago by webcandy.

Please Log in or Create an account to join the conversation.

  • Posts: 49
  • Thank you received: 1
9 years 5 months ago #180998

That is what I am saying though. That never existed in the original. It ended in an "open bracket" status.

Please Log in or Create an account to join the conversation.

  • Posts: 23
  • Thank you received: 2
9 years 5 months ago #180999

oh right. I just noticed that. I would just leave it off as you said then.

Please Log in or Create an account to join the conversation.

  • Posts: 49
  • Thank you received: 1
9 years 5 months ago #181000

Webcandy-
After entering the card and hitting process, I am immediately sent somewhere where I do not have permission to go to and given a message: "Please login first".

There is only one menu item that is locked down by permissions, unless it tried to redirect to some part of the purchase process. Either way, I did loose the phantom cart, but was redirected somewhere I should not be allowed (according to Joomla!).

Please Log in or Create an account to join the conversation.

  • Posts: 23
  • Thank you received: 2
9 years 5 months ago #181002

What was the redirect URL you used? I know you say only one should be locked down, but It's going to redirect to whatever page you put in the code so I would check the permissions on that first. I would just try having it redirect to your main site for testing purposes. You can share the URL so you can see if I can get to it, if you want.

You can add "sleep(20);" before the header code to delay the redirection so they can see the message. The number is in seconds.

So your code will look like:

<?php
/**
 * @package	HikaShop for Joomla!
 * @version	2.3.4
 * @author	hikashop.com
 * @copyright	(C) 2010-2014 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php
$app = JFactory::getApplication();
$app->enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') );

/*
Added custom code below to force a user logout when a purchase is complete.
Find problem solving here:
http://www.hikashop.com/forum/customers/873174-force-a-logout-out-at-end-of-a-purchase.html
*/
$app = JFactory::getApplication(); 
$app->logout();
sleep(20);
header( "Location: http://www.domain.com/redirectpage.php" );
exit;

EDIT: you might have to move around the sleep to get the exact results you want. Not positive.

Last edit: 9 years 5 months ago by webcandy.

Please Log in or Create an account to join the conversation.

  • Posts: 49
  • Thank you received: 1
9 years 5 months ago #181004

Ok, I tried it again after figuring something out on the cart url redirect. I had that set at www.domain.com , and if you added something to the cart, then click on the "X" in the header to remove it from the cart, I would redirect to www.domain.com/www.domain.com

So I changed that redirect to a blank, and tried clicking the X again. No problem, it works fine.

Now, I tried another purchase, and end up back somewhere that I should not be... I guess.

<?php
/**
 * @package	HikaShop for Joomla!
 * @version	2.3.4
 * @author	hikashop.com
 * @copyright	(C) 2010-2014 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php
$app = JFactory::getApplication();
$app->enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') );

/*
Added custom code below to force a user logout when a purchase is complete.
Find problem solving here:
http://www.hikashop.com/forum/customers/873174-force-a-logout-out-at-end-of-a-purchase.html
*/
$app = JFactory::getApplication(); 
$app->logout();

header( "Location: http://www.domain.com" );
exit;

One thing here, I am forcing an https using both .htaccess and akeeba admin tool. I really doubt that is having an effect here, because if I just type the address into a browser, it will automatically redirect to an https.

Last edit: 9 years 5 months ago by YeeP.

Please Log in or Create an account to join the conversation.

  • Posts: 23
  • Thank you received: 2
9 years 5 months ago #181005

What happens after the purchase? The same issue with permissions?

Please Log in or Create an account to join the conversation.

  • Posts: 49
  • Thank you received: 1
9 years 5 months ago #181006

Yes, same as before. I am adding the sleep command right now and trying again just for the heck of it.

Please Log in or Create an account to join the conversation.

  • Posts: 49
  • Thank you received: 1
9 years 5 months ago #181007

Webcandy - I think something is doing a redirect on this site and I cannot find it. Possibly permissions on the site?

It wants me to log in no matter what now, like even when I go to the site, not logged in. That could be a cause of this, but I have no idea what is doing it.

That was not happening this morning and I have no idea what change did it.... lovely.

Please Log in or Create an account to join the conversation.

  • Posts: 23
  • Thank you received: 2
9 years 5 months ago #181008

I don't know why it'd be hika. Check out your modules associated to menus...check out your HikaShop Cart Module and make sure the access is public...and any other things you can think of.

That sucks a lot and I hope it's not hikashop related :(

Please Log in or Create an account to join the conversation.

  • Posts: 49
  • Thank you received: 1
9 years 5 months ago #181009

Ya, it really does suck... Right now, if you try to just go to:

www.domain.com
you end up at:
www.domain.com/component/users/?view=login

I just changed the permissions

EDIT: If i hit the HOME button on the menu, I a redirected to the alias: www.domain.com/home and am not requested to log in.

reconfigured the way the url is printed in the browser to try and find cause. I don't think this is any help but...
www.domain.com/index.php?option=com_users&view=login

EDIT 2 - I am going to use the "sledgehammer" method here and backup the site. I will uninstall components one by one to see if I can get to the regular domain address. Then reload the backup after I find the culprit.

Last edit: 9 years 5 months ago by YeeP.

Please Log in or Create an account to join the conversation.

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
9 years 5 months ago #181023

Hi,

If you enter a URL in the "return URL" parameter of your payment method, the default thank you page of HikaShop is not used and instead HikaShop redirects you to that return URL.
So I would recommend to check on that.

Please Log in or Create an account to join the conversation.

  • Posts: 49
  • Thank you received: 1
9 years 5 months ago #181025

Good shot Nicolas, but there is nothing in that field right now. Any other ideas?

Please Log in or Create an account to join the conversation.

  • Posts: 23
  • Thank you received: 2
9 years 5 months ago #181031

just so I understand, are you being redirected to that crazy page even when you just type in the domain name in your address bar?

Please Log in or Create an account to join the conversation.

  • Posts: 49
  • Thank you received: 1
9 years 5 months ago #181032

You are correct. However, I fixed that and can now return to the standard domain address without being forced to a login. I will now test the sleep idea you had, as that is when I found this other issue (I think I found the issue because your idea worked). I won't be in front of my computer for a couple of hours, but will report back. Thanks for your help.

Please Log in or Create an account to join the conversation.

  • Posts: 23
  • Thank you received: 2
9 years 5 months ago #181033

Glad to hear it! I hope that is the case. Make sure to use sleep in conjuction wit the redirect like I have up there. Good luck!

Please Log in or Create an account to join the conversation.

  • Posts: 49
  • Thank you received: 1
9 years 5 months ago #181150

Webcandy- after three tests this morning, I can say that we are close, but not there yet.

Test 1

<?php
/**
 * @package	HikaShop for Joomla!
 * @version	2.3.4
 * @author	hikashop.com
 * @copyright	(C) 2010-2014 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php
$app = JFactory::getApplication();
$app->enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') );

/*
Added custom code below to force a user logout when a purchase is complete.
Find problem solving here:
http://www.hikashop.com/forum/customers/873174-force-a-logout-out-at-end-of-a-purchase.html
*/
$app = JFactory::getApplication(); 
$app->logout();
/*
sleep(8);
header( "Location: http://www.domain.com/" );
exit;*/
Result: End up back with phantom cart, still logged in. I tried commenting out your code in hopes that the other issue I was having was the cause of that problem. Turns out it was not.

Test 2
<?php
/**
 * @package	HikaShop for Joomla!
 * @version	2.3.4
 * @author	hikashop.com
 * @copyright	(C) 2010-2014 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php
$app = JFactory::getApplication();
$app->enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') );

/*
Added custom code below to force a user logout when a purchase is complete.
Find problem solving here:
http://www.hikashop.com/forum/customers/873174-force-a-logout-out-at-end-of-a-purchase.html
*/
$app = JFactory::getApplication(); 
$app->logout();
sleep(8);
header( "Location: http://www.domain.com/" );
exit;
Result: I never see the "Thank you for purchase" message. It looks to "process" with a blank page after the purchase, then it loads on to the home page with no message, logged out.


Nicolas, I really appreciate all the help webcandy and you are giving me, but I am starting to feel like this is something the software should do. At least, based on your first repose to this and the following suggestions related to settings in Joomla and Hikashop. All of which I have already had set to your recommendations. I am literally at a standstill and cannot test the clients real bank money transfers. I can type fake credit card numbers in all day, but this is a serious problem now.

I am happy to admit if I made a mistake, and I think I have shown that. Please help in any way you have the time to.

Last edit: 9 years 5 months ago by YeeP.

Please Log in or Create an account to join the conversation.

  • Posts: 49
  • Thank you received: 1
9 years 5 months ago #181156

Just tried a run with the "exit;" statement removed. This made no difference to the above "Test 2". It just processes aka sleeps for the amount of time assigned, then pops to the main home page.

Please Log in or Create an account to join the conversation.

Time to create page: 0.102 seconds
Powered by Kunena Forum