Jump to content

Getting Order Details in complete.tpl


brian-

Recommended Posts

I need to display custom messages when products in certain product groups are purchased.

 

I put {debug} at the bottom of complete.tpl and unfortunately the purchased products are not directly available as variables. The only thing that looks useful in the debug window is $orderid.

 

So first of all, I assume that I'm going to need to enable {php} in my templates under the General - Security tab since the data I need isn't available in complete.tpl.

 

Can anyone tell me what whmcs api functions I should use to fetch the order by $orderid and check if it contains any products from productgroup id 5?

 

I know php well but am very new to the whmcs api. Someone who could sketch out the process with whmcs function names would be my hero.

Link to comment
Share on other sites

I need to display custom messages when products in certain product groups are purchased.

I put {debug} at the bottom of complete.tpl and unfortunately the purchased products are not directly available as variables. The only thing that looks useful in the debug window is $orderid.

So first of all, I assume that I'm going to need to enable {php} in my templates under the General - Security tab since the data I need isn't available in complete.tpl.

if that's your first thought, think again! eventually, and I imagine almost certainly in WHMCS v8 next year, the use of {php} will be prevented, so it may be best to get out of the habit and only use it as an absolute last resort (and even then, only temporarily).

 

Can anyone tell me what whmcs api functions I should use to fetch the order by $orderid and check if it contains any products from productgroup id 5?

just a personal choice, but where possible I try not to use the API for things like this, as often in new releases certain API functions don't work and you're then left waiting for WHMCS to fix them... so for something as basic as this, i'd just query the db in an action hook.

 

I know php well but am very new to the whmcs api. Someone who could sketch out the process with whmcs function names would be my hero.

take a look at sentq's hook in the thread below as a starting point...

 

https://forums.whmcs.com/showthread.php?115218-Custom-Link-in-complete-tpl-Template

 

I would imagine for you, the query would need changing to...

 

$getService = Capsule::table("tblhosting")->where("orderid", $params['orderid'])->wherein("packageid",[1,2,3])->take(1);

i'm slightly cheating here as i'm searching if the order contains product IDs 1,2,3 (replace with the Ids in productgroup 5) - tblhosting doesn't contain product groups IDs for the ordered products, you'd have to join with tblproducts to find the group ID value for a product... that would be the thorough way to do it with a join, and i'm sure you'd fine loads of examples of hooks with joins in in the forums posted by sentq and myself!

then it's just a case of changing the output in the hook to suit your requirements. :idea:

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