phoenix04 Posted September 28, 2008 Share Posted September 28, 2008 Hi, Has anyone written any php code to read the contents of the whmcs cart outside of whmcs (e.g. inside a Joomla module?) So far, we have found out that the _$SESSION['cart'] variable is responsible for holding the information about the cart contents, but when we add the php code provided in another post to a module, the $cartitems variable is set to '0' even when there is something in the whmcs cart in the current browser session (which you can see by going to cart.php?a=view). This means the code posted on the forum is somehow not reading the whmcs session. The code is: $cartitems = count ($_SESSION['cart']['products']) + count ($_SESSION['cart']['addons']) + count ($_SESSION['cart']['domains']); If anyone knows what code we need to put into our Joomla module to read the WHMCS cart variable in our module, could you please post it? We are still learning php, and by no means advanced developers. It is probably something easy that we need to add to our php Joomla module to be able to read the whmcs cart from outside whmcs. We only want to report back to the user the total number of items in the cart and the $ value spent so far so they can browse between whmcs and the rest of the site seamlessly. Please help. Link to comment Share on other sites More sharing options...
Gert Posted September 1, 2011 Share Posted September 1, 2011 Hi did you find out anything on that? We have the same problem. Thanks Link to comment Share on other sites More sharing options...
alex_emerion Posted November 26, 2012 Share Posted November 26, 2012 maybe you need to start the session before: session_start(); Link to comment Share on other sites More sharing options...
nahosting Posted January 13, 2013 Share Posted January 13, 2013 Did you get anywhere with this? I want to display the cart items count in the header and it appears that the $cartitems variable is only populated in the cart/checkout area. Link to comment Share on other sites More sharing options...
jmtech Posted October 31, 2017 Share Posted October 31, 2017 I know this is quite old but I'm going to be doing something like this shortly so I thought I'd comment instead of starting a new thread. The reason you the variable is 0 is because session variables do not share across domains. I'll let you read up on why. My approach is to put my wordpress site at www.jmtech.com.au and my WHMCS at the subdomain of client.jmtech.com.au and then crate a hook or similar to create and update some variables that I will be able to use cross sub-domain using code similar to the below. session_name("2620368ghwahw90w"); session_set_cookie_params(0, '/', '.mydomain.com'); session_start(); I'll post an update when I've got it working. Cheers, Jason Link to comment Share on other sites More sharing options...
jmtech Posted October 31, 2017 Share Posted October 31, 2017 The important thing here is to name the session and then define the scope of the cookie. Link to comment Share on other sites More sharing options...
Recommended Posts