Jump to content

php code to check if product is purchased


Recommended Posts

Ok, I'm trying to have a page that will show something different depending on whether a certain product is purchased or not. Right now the code looks basically like:

 

if ($_SESSION['uid']) {
if (some how check to see if they're purchased the product) {
  echo '
	show this if they've purchased the product
  ';
} else {
  echo '
	show this if they don't have the product
  ';
}
} else {
 echo '
show this if they're not logged in
 ';
}

 

They problem is... well, I have no idea how to do that check. Neither the documentation nor Google have been much help to me.

Link to comment
Share on other sites

take a look at the documentation on hooks...

 

http://docs.whmcs.com/Hooks

 

basically, you're going to have to query the database to see if the client has purchased a specific product.... there are other ways, but querying the db will probably be the easiest.

 

which specific hook you need to use will depend on where you're trying to do this, it might be ClientAreaPage.

Link to comment
Share on other sites

  • 2 weeks later...
I don't see anything in the "Hooks" documentation that does anything like what I need it to do. I was hoping that there was something simple like a variable with a 1 or 0 value to check,

if there was a variable, you wouldn't need a hook. :)

 

or at least a way to create such a variable.

that would be a hook. :idea:

 

basically, you'll need to query the database table, tblhosting, and see if any records exist where the logged in user has a specific packageid value - if so, create a variable in the hook and pass it back to the page... then in your template, you can detect whether the variable exists and code the output accordingly accordingly.

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