Jump to content

aff details hook


durangod

Recommended Posts

for some reason im not getting the array passed over to the template file..

 

in the template im checking for the array this way

 

{$afconfdata|@print_r}

 

and all im getting is a 1

 

 

here is my hook


if (!defined("WHMCS"))
{
die("This file cannot be accessed directly");
} 

function hook_aff_program_details($vars) 
{   

   // conf value name array

  $afdbvalues = array('AffiliateEnabled', 'AffiliateEarningPercent', 'AffiliateBonusDeposit', 'AffiliatePayout');

    //loop thru value names to get actual values

   foreach($afdbvalues as $key => $value)
   {
   $qdat = mysql_query("SELECT `value` FROM `tblconfiguration` WHERE `setting` = '$value'");
   $res = mysql_fetch_row($qdat);     
   $afconfdata[] = $res[0]; //store result each time in array
    }//close foreach


return $afconfdata;
}//close function

add_hook("ClientAreaPage",1,"hook_aff_program_details");

 

UPDATE: so i have the array now on the hook side, but not on the template side.

 

 

//$afconfdata array

 

Array

(

[0] => on

[1] => 20

[2] => 10.00

[3] => 100.00

)

 

 

 

do i need to assign it

 

//$this->assign('$afconfdata', $afconfdata);

 

or does the hook do that for me

Edited by durangod
Link to comment
Share on other sites

i changed your code a little, your hook should be like that:

<?php
function hook_AffiliateSettings($vars){

   // conf value name array
   $affRecords = array('AffiliateEnabled', 'AffiliateEarningPercent', 'AffiliateBonusDeposit', 'AffiliatePayout');

   //loop thru value names to get actual values
   foreach($affRecords as $record) {
       # Select Values
       $getValue = full_query("SELECT `value` FROM `tblconfiguration` WHERE `setting`='{$record}'");
       $getValue = mysql_fetch_row($getValue);
       $affValues[$record] = $getValue['value']; //store result each time in array
   }//close foreach

return $affValues;
}//close function
add_hook("ClientAreaPage", 1, "hook_AffiliateSettings");

?>

 

then you can use the following tags to print values into smarty templates:

{$AffiliateEnabled}
{$AffiliateEarningPercent}
{$AffiliateBonusDeposit}
{$AffiliatePayout}

Link to comment
Share on other sites

thanks sentq, i tried the full_query and select_query also before on mine but it would not work, but yet i saw it used on the other hooks in the dir. Thats why i went with the normal query.

 

Thanks so much, i will give this a try in a few, i had to get some rest and just waking up again lol.. :)

Link to comment
Share on other sites

no values sentq, i layed out the tables in affiliates.tpl like so and no values are passed to tpl file.. mmmm

 

 


<!-- added for details view -->

        <tr>
         <td width="230" class="fieldarea">Enabled:</td>
         <td>{$AffiliateEnabled}</td>
       </tr>

        <tr>
         <td width="230" class="fieldarea">Commission Value (Percent):</td>
         <td>{$AffiliateEarningPercent}</td>
       </tr>

       <tr>
         <td width="230" class="fieldarea">Sign Up Bonus:</td>
         <td>{$AffiliateBonusDeposit}</td>
       </tr>

       <tr>
         <td width="230" class="fieldarea">Payment Threshhold:</td>
         <td>{$AffiliatePayout}</td>
       </tr>

<!-- end add -->


 

- - - Updated - - -

 

UPDATE... ahhhaaahhh no values in array... lol

 

Array

(

[AffiliateEnabled] =>

[AffiliateEarningPercent] =>

[AffiliateBonusDeposit] =>

[AffiliatePayout] =>

)

 

 

gimme a min :)

 

- - - Updated - - -

 

array is looken like this now (the query result)

 

Array ( [0] => on ) Array ( [0] => 20 ) Array ( [0] => 10.00 ) Array ( [0] => 100.00 )

 

- - - Updated - - -

 

just changed this line

 

$affValues[$record] = $getValue[0]['value']; //store result in array each loop

 

- - - Updated - - -

 

so now we have values on the page but not formated, thats what tossed me off before, i was getting 1 and not sure what that meant lol... so i guess it was working lol..

 

so now i need to either use number_format on the hook side to format or let me see if whmcs or smarty has a format function to do in on the tpl side.

Link to comment
Share on other sites

sorry my fault, we need to replace mysql_fetch_row() with mysql_fetch_array() see this code work:

<?php

function hook_AffiliateSettings($vars){

   // conf value name array
   $affRecords = array('AffiliateEnabled', 'AffiliateEarningPercent', 'AffiliateBonusDeposit', 'AffiliatePayout');

   //loop thru value names to get actual values
   foreach($affRecords as $record) {
       # Select Values
       $getValue = full_query("SELECT `value` FROM `tblconfiguration` WHERE `setting`='{$record}'");
       $getValue = mysql_fetch_array($getValue);
       $affValues[$record] = $getValue['value']; //store result each time in array
   }//close foreach

return $affValues;
}//close function
add_hook("ClientAreaPage", 1, "hook_AffiliateSettings");

?>

Link to comment
Share on other sites

lol i thought about using fetch array too but it was a fleeting thought lmao... oops..

 

here is the final that i came up with using fetch row that works also

 

hook

 

<?php

/*
********************************************************************
* This hook just grabs the config settings for the affiliate setup
* so they can be displayed for the user on the affiliates.tpl page
********************************************************************
*/

if (!defined("WHMCS"))
{
die("This file cannot be accessed directly");
} 

function hook_AffiliateSettings($vars)
{

   // config value name array
   $affRecords = array('AffiliateEnabled', 'AffiliateEarningPercent', 'AffiliateBonusDeposit', 'AffiliatePayout');

   //loop thru value names to get actual values
   foreach($affRecords as $record) 
   {
       //Select Values
       $getValue = mysql_query("SELECT `value` FROM `tblconfiguration` WHERE `setting`='{$record}'");
       $results = mysql_fetch_row($getValue);
       $affValues[$record] = $results[0]; //store result in array each loop       
   }//close foreach


// convert enabled to yes no 
$convertEnabled = $affValues['AffiliateEnabled'] = "on" ? "Yes" : "No";
$affValues['AffiliateEnabled'] = $convertEnabled;


return $affValues;
}//close function
add_hook("ClientAreaPage", 1, "hook_AffiliateSettings");

?>

 

in affiliates.tpl (second table, first row (tr))

 

<!-- added for details view -->

        <tr>
         <td width="230" class="fieldarea">Program Enabled:</td>
         <td>{$AffiliateEnabled}</td>
       </tr>

        <tr>
         <td width="230" class="fieldarea">Commission Value (Percent):</td>
         <td>{$AffiliateEarningPercent}%</td>  <!-- remove % if your not doing percentage -->
       </tr>

       <tr>
         <td width="230" class="fieldarea">Sign Up Bonus:</td>
         <td>${$AffiliateBonusDeposit}</td>
       </tr>


       <tr>
         <td width="230" class="fieldarea">Payment Threshhold:</td>
         <td>${$AffiliatePayout}</td>
       </tr>

<!-- end add -->

 

now i think maybe working on some kind of curr conversion or think of other ways to make it better...

 

thanks for the help sentq :)

 

- - - Updated - - -

 

Just remember folks that these values are the default values set in admin, if you have specific client settings this does not show that, well not yet anyway lol... so if you dont set a bunch of fancy stuff like special client amounts and stick with percentage then this basic setup will work for you very well.

 

I did this because i think every client needs to know what they are making and how. I am also going to add a description popup (or maybe just on the page) about the program, what they get comm for and what they dont, just general info. And also add that to the aff signup form too.

 

also remind your clients that cookie is for 90 days by default, maybe ill add that to the form.

Edited by durangod
Link to comment
Share on other sites

as it turns out it looks better as its own table with a little seperation like this, i also added some hard coded displays values because they are defaults.

 

 



      <table width="100%" border="0" align="center" cellpadding="10" cellspacing="0">
        <tr>
         <td width="230" class="fieldarea">Program Enabled:</td>
         <td>{$AffiliateEnabled}</td>
       </tr>

        <tr>
         <td width="230" class="fieldarea">Commission Value (Percent):</td>
         <td>{$AffiliateEarningPercent}%</td>
       </tr>

       <tr>
         <td width="230" class="fieldarea">Sign Up Bonus:</td>
         <td>${$AffiliateBonusDeposit}</td>
       </tr>

       <tr>
         <td width="230" class="fieldarea">Payment Threshhold:</td>
         <td>${$AffiliatePayout}</td>
       </tr>

       <tr>
         <td width="230" class="fieldarea">Cookie Duration (days):</td>
         <td>90</td>
       </tr>

       <tr>
         <td width="230" class="fieldarea">Payment Delay (days):</td>
         <td>60</td>
       </tr>
     </table>
<br />


 

- - - Updated - - -

 

if you want to add it you can, but the default hard code is fine unless your going to change it. But there is a table value also for

payment delay, its called AffiliatesDelayCommission its not grouped with the others so i missed it, but you can add it to the array in the hook if you want..

Link to comment
Share on other sites

I guess maybe this needs to be moved to the contribution section. But anyway wanted to share the final look of it all..

 

The image is of the affiliate page after they log in... The help link opens a smaller window which has rules and such. And because i split the table i had to add a top border to the following table to get the line back, that color of the line is #EBEBEB. The text inside the more information box is from a new lang key i added, and the link is from a window open process link.

 

affdatasample.jpg

 

If you have any questions or need the basic text for the help page, let me know ill help...

Edited by durangod
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