Page 1 of 1

Trying to restore cart on a custom build page

Posted: Sat May 01, 2021 2:02 pm
by loop
Hi Everyone, i have a own php file, called recovert_cart.php, after checking for a onetime password and checking if its valid, i want to restore session + shopping cart + autologin

(in did the code for early Oscommerce version and this does not work anymore of course...)

i try to understand the hook system and i thought i could make this code:

Code: Select all

 if ( is_int($cID) && ($cID > 0) ) {
            $GLOBALS['login_customer_id'] = $cID;
            $OSCOM_Hooks->call('siteWide', 'postLogin');
            
            tep_redirect(tep_href_link('shopping_cart.php','ad=recover_cart'));
        }
i hoped that after setting the global and call the hook (like in login.php) it will do the login / recreate cart ....

can somebody point me to the right direction?
thank you so much

Re: Trying to restore cart on a custom build page

Posted: Sun May 02, 2021 9:37 am
by loop
I bought "s06e08 Keys" because i hoped that the solution to my problem i can find in the source code to restore a login session / cart but unfortunately i think the module does not restore the session and not login, shows only the desired content....
edit:
OMG i found it out, this 3 lines of code (after verification that's the right customer)
makes the complete login (at the moment i don't really get, why i have to register the hook, as in the login.php there is no register to see) but it works...hmmm :)

Code: Select all

$GLOBALS['login_customer_id'] = $cID;
        $OSCOM_Hooks->register('login');
        $OSCOM_Hooks->call('login', 'postLogin');

Re: Trying to restore cart on a custom build page

Posted: Sun May 02, 2021 1:28 pm
by ecartz
The login on the login page is registered by system hook in application_top.

If you're not on the login page, you have to do it manually. You're essentially telling it that whatever page you're actually on is the login page.

Re: Trying to restore cart on a custom build page

Posted: Sun May 02, 2021 3:50 pm
by loop
oh okay..i see
and just for my understanding. where are the hocks postLogin saved? i searched quiet everywhere...couldn't find the hoocks (only in the database i saw them in the hooks table). where are they in the filesystem?

Re: Trying to restore cart on a custom build page

Posted: Sun May 02, 2021 6:36 pm
by ecartz
They are only in the database. Database hooks are an alternative to file system hooks.