Trying to restore cart on a custom build page

Ask the community for help and support.
Post Reply
loop
VIP Member
VIP Member
Posts: 230
Joined: Thu Mar 25, 2021 12:26 pm
Has thanked: 7 times
Been thanked: 3 times

Trying to restore cart on a custom build page

Post 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
loop
VIP Member
VIP Member
Posts: 230
Joined: Thu Mar 25, 2021 12:26 pm
Has thanked: 7 times
Been thanked: 3 times

Re: Trying to restore cart on a custom build page

Post 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');
ecartz
Lead Developer
Lead Developer
Posts: 2637
Joined: Tue Nov 05, 2019 6:02 pm
Has thanked: 4 times
Been thanked: 181 times

Re: Trying to restore cart on a custom build page

Post 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.
loop
VIP Member
VIP Member
Posts: 230
Joined: Thu Mar 25, 2021 12:26 pm
Has thanked: 7 times
Been thanked: 3 times

Re: Trying to restore cart on a custom build page

Post 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?
ecartz
Lead Developer
Lead Developer
Posts: 2637
Joined: Tue Nov 05, 2019 6:02 pm
Has thanked: 4 times
Been thanked: 181 times

Re: Trying to restore cart on a custom build page

Post by ecartz »

They are only in the database. Database hooks are an alternative to file system hooks.
Post Reply