Jump to content

Calling to WHMCS from an external page returns "Down for Maintenance" error!


sufi

Recommended Posts

I am trying to show total cart items from an external page. My WHMCS is located in "shop" directory and external page is in root.

 

I can show it perfectly with following code:

 

require("shop/dbconnect.php");
$totalitems = count ($_SESSION['cart']['products']) + count ($_SESSION['cart']['addons']) + count ($_SESSION['cart']['domains']);

if($totalitems > 0){
echo '</br><b>You have ' . $totalitems . ' item</b></br>';
}
else {
echo '</br><b>You have no item</b></br>';
}

 

But when I put this code in a function, and then call that function, I get an error message saying Down for Maintenance

An upgrade is currently in progress... Please come back soon...

 

Here is the code:

function ex_whmcs(){
require("shop/dbconnect.php");
$totalitems = count ($_SESSION['cart']['products']) + count ($_SESSION['cart']['addons']) + count ($_SESSION['cart']['domains']);
if($totalitems > 0){
 		return '</br><b>You have ' . $totalitems . ' item</b></br>';
 	}
 	else {
 		return '</br><b>You have no item</b></br>';
 	}	
}

 

Can someone guide me, what is the mistake I have done?

error.jpg

Link to comment
Share on other sites

Thanks.

But I don't think I need to set an API for this. All I need to show is information on $_SESSION['cart'].

I was able to solve it. But having a different sort of error.

 

It works perfectly, when I put the require("shop/dbconnect.php"); in any file rather than header.php and functions.php (both are wordpress template files), and I am not sure what is causing that error.

 

I am trying to put this in a shortcode.

 

I don't know but take a look at:

 

http://docs.whmcs.com/API:Example_Usage

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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