954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Saving Session Data outside of Shopping Cart

I'm making a simple box in the header of Joomla that displays the total quantity and total value of the cart. It works perfectly in VirtueMart, but once I leave the storefront the (Total) value is removed.

How do I fix this? I would like to set a permanent super global variable that will stay constant regardless of where the visitor is on the site.

<?php
$qty = getCartQty($_SESSION['cart']);
echo $qty;
?>
{/source} items ($
{source}
<?php
$session = JFactory::getSession();
$session->set('gTotal', $GLOBALS[total]);
$_SESSION[gTotal] = $GLOBALS[total];

if ($_SESSION[gTotal] > 0){
$newgTotal = $session->get('gTotal');
}
if (($newgTotal) != 0) {
var_export($newgTotal);
} else {
echo '0.00';
}
?>
{/source})</div>


Any ideas?

mpw5013
Newbie Poster
10 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
 

How do you guys do it? Almost every site out there shows a total in the header area....

mpw5013
Newbie Poster
10 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
 

I needed the following:

$session->set('sessionTotal', $GLOBALS[total]);


and

$newgTotal = $_SESSION[sessionTotal];
mpw5013
Newbie Poster
10 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: