Im sure the title sound a bit complex or lame. Im trying to develop a component that will keep the count of users that Added a product in the cart but didnt finish with a checkout ( canceled the order before paying ) .
I created a new table in the db and in the controller of virtuemart i added this code: components/com_virtuemart/controllers/cart.php
function add() {
$tmp = JFactory::getUser();
$db= JFactory::getDbo();
$ready = $db->getQuery(true);
$query= "INSERT INTO #__nobuyers (id,name,email) VALUES ( '". $tmp->id ."','". $tmp->username ."','". $tmp->email ."') ";
$db->setQuery($query);
$db->execute();
/*
$session =& JFactory::getSession();
$session->set( 'cartcheck', 'cartisnotempybro' );
$GLOBALS['yoyo']=notempty;
*/
public function confirm() {
$tmp = JFactory::getUser();
$db= JFactory::getDbo();
$ready = $db->getQuery(true);
$query= "DELETE FROM #__nobuyers where ID=". $tmp->id;
$db->setQuery($query);
$db->execute();
SO when a Registered and Loged user will add a product in his cart i keep his info at my db. If he checkout i remove him.
This is working fine. The problem is when a user first add a product to the cart and logs in after.
So what im trying to do is : When a user add a product in a cart, keep a global flag variable.
After that edit the com_users/controllers/user.php
login() function so when someone try to login check if the flag is set ( someone added a product in the cart ) and if so, add him in database right after log in.
Something like that :
$session = JFactory::getSession();
$seccode=$session->get('cartcheck');
if ($seccode) {
or
if (!empty($GLOBAL['yoyoyo'])) { //do stuff
ALtough i try to access a variable setted from com_virtuemart inside the com_users.The var_dumps
i used returns NULL. Is it possible ? And if yes how we achieve that ?