Jump to content

Licensing Addon: Parsing addons returned by the integration code


Recommended Posts

Hi all,


I am using the licensing addon and need a little help, because I'm losing my mind trying to wrap my head around this.


$results['addons'] returns something like this:

name=Branding Removal;nextduedate=0000-00-00;status=Active|name=Another Addon;nextduedate=0000-00-00;status=Active


I'm trying to figure out how to convert this into a usable string. For example, if "Branding Removal" is in the addons and the status of the addon is "Active", $brandingremoval would return true, but otherwise false.


I found another thread on this at http://forum.whmcs.com/showthread.php?31986-Parsing-WHMCS-Licensing-Product-Addons-in-PHP - but the code provided there doesn't work. Any ideas?

Link to comment
Share on other sites

Got a reply from Andrew, figured I'd share in case anyone else gets stuck. The code provided worked.


The addons are returned in the format "name=Addon Name;nextduedate=Next Due Date;status=Status|


So, from this, you can see that each addon data is separated by a |. You can explode this | to obtain each addon separately in the list.

Once you have done this, you can explode on ; to get separate variables with the separate options and then finally on the = symbol. This will then give you the addon name, next due date and status.


Something like:


$addonarray = array();

$addonslist = explode('|',$results['addons']);

foreach ($addonslist as $addons){

$addondata = explode(';',$addons);

$addonname = $addonnextduedate = $addonstatus = "";

foreach ($addondata as $addon){

$addonnvp = explode('=',$addon);

if($addonnvp[0] == 'name') $addonname = $addonnvp[1];

if($addonnvp[0] == 'nextduedate') $addonnextduedate = $addonnvp[1];

if($addonnvp[0] == 'status') $addonstatus = $addonnvp[1];


$addonarray[$addonname] = array("nextduedate"=>$addonnextduedate,"status"=>$addonstatus);



The code above assumes that each addon has a different name and is just a sample. You should create and check your own code to obtain the list in the format that you require.

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.

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