Jump to content

How to read number of items in cart & cart total from outside WHMCS?


phoenix04

Recommended Posts

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

  • 2 years later...
  • 1 year later...
  • 1 month later...
  • 4 years later...

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

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated