I need to set $smarty.session.cart.amount to a cookie or session for outside use

I’m using a separate CMS for a site and need to show the cart quantity outside of CS Cart. I know within CS Cart the var is $smarty.session.cart.amount, and I know this value is calculated in core/fn.cart.php. I’ve tried various ways of getting this into a cookie and session and accessing it from outside the cart but I can’t seem to get it right. Can anyone help?

I found my answer in another thread here: [url]http://forum.cs-cart.com/showthread.php?t=17145&highlight=cart+amount[/url]

My variable is $this->_tpl_vars[‘cart’][‘amount’]

And finally, by placing this on line 2 in /index.tpl:



setcookie(“cart_amount”, $_SESSION[‘cart’][‘amount’], time()+3600247, “/”);



I could then access the cart_amount cookie throughout the entire website even outside for CS-Cart.

I'm also trying to set a cookie this way, but the shop doesn't seem to accept PHP-code?

setcookie("network", $smarty.get.network, time()+3600*24*100, "/");

Affiliate networks will send visitors with a parameter in the url which I'd like to GET from url and put in a cookie.

EDIT: found out why it doesn't work!! In newer versions (2.2.1 and up) cs-cart changed the config and you need to enable the possibility to add php in template files!

Look for this line:

$config["tweaks"]["allow_php_in_templates"] = false; // Allow to use {php} tags in templates


I came across the same situation and I need to use the cs cart session data outside the cs cart. I have used cookie as of now and while testing, the cookies doesn't seem to change everytime when I sign out and sign in.

Is there any possibility that I can use the same session value outside cs cart.

Also, in localhost, I could get the session data from cscart_sessions table which is in a serializable array(not encrypted) and in server it seems the session data is encrypted which I can;t figure out how to decrypt it.

If I could decrypt the session data frmo the cscart_sessions table, may be I can get the session values passed to the app outside of cs cart.

Is there any possible way to do this other than setting up a cookie ?