Jump to content

Open Source Affiliate Coupons/Promo Code (instead of link)


HostT

Recommended Posts

So what does this addon mean? It means your customers can give out promo codes, AND no longer have to use those ugly affiliate links!

 

We all know customers will make sure to use a promo code ... but will they make sure to use your link? No, not always.

 

Enter WHMCS Affiliate Coupons

 

Selection-1002x631-11.png

 

In my opinion this is one of the best and one of my favorite addons -- the original version Affiliate Coupons by Frank Lazslo:

http://forum.whmcs.com/showthread.php?31020-Affiliate-Coupons

 

Unfortunately the addon has not been updated recently (and completely understandable), I decided to go ahead and put it up on my GitHub and start working on it.

 

Latest update should be fully compatible with WHMCS 5.2+

 

So here's what's been updated so far:

  • Updated Affiliate Cookie ID
  • Updated Hook Cookie ID
  • Updated Default Template
  • Updated Client Area HTML/CSS Output

 

Planned Updates:

  • Restructure to only addon module
  • Update admin area configuration, and layout
  • Update templates and output

 

Got an idea? Well post it on GitHub under issues!

 

So what are you waiting on!? It's open source, so check it out on GitHub, and if you're feeling froggy, contribute as well!

 

https://github.com/tripflex/whmcs-affcoupons

 

NOTE: If you're using WHMCS 5.1 you will have to use the branch in link below, 5.2 has changed and the master branch is not compatible with WHMCS 5.1

 

https://github.com/tripflex/whmcs-affcoupons/tree/WHMCS-5.1

Selection-1130x736-12.png

Link to comment
Share on other sites

  • 4 weeks later...

Hi there. Please help installing this addon.

After installing it is not visible in client area. After changed affcoupons.php to show errors I get this.

 

Fatal error: Call to undefined function select_query() in /var/www/html/affcoupons.php on line 26

 

Thanks in advance.

Link to comment
Share on other sites

Hi there. Please help installing this addon.

After installing it is not visible in client area. After changed affcoupons.php to show errors I get this.

 

Fatal error: Call to undefined function select_query() in /var/www/html/affcoupons.php on line 26

 

Thanks in advance.

 

What version of WHMCS are you using? That error is from the select_query() function that is a native WHMCS MySQL query. That error says there is something wrong with your WHMCS installation, it's not related to the addon.

Link to comment
Share on other sites

  • 1 month later...

Hiya, is this confirmed working with the latest whmcs? I've tried to install, but it seems broken. I renamed the folder to just affcoupons so that it shows up as an addon, but from that point on, it just gives me broken pages.

 

Thanks!

Link to comment
Share on other sites

  • 2 weeks later...
Hiya, is this confirmed working with the latest whmcs? I've tried to install, but it seems broken. I renamed the folder to just affcoupons so that it shows up as an addon, but from that point on, it just gives me broken pages.

 

Thanks!

 

Which version, 5.3.5?

 

Did you follow the installation instructions?:

https://github.com/tripflex/whmcs-affcoupons/blob/master/INSTALL

 

Please provide any further details you can so I can try and reproduce the errors

Link to comment
Share on other sites

  • 3 weeks later...
  • 4 weeks later...
  • 5 weeks later...

i cant get this to work either, its installed and activated and i added a coupon but it is nowhere to be found other than in the ACP list

 

cannot access https://mysite.com/index.php?m=affcoupons not found

 

 

UPDATE:

 

The promo code page is located here not at the link above..

 

https://yoursite.com/whmcs/index.php?m=affcoupons

Edited by durangod
Link to comment
Share on other sites

ok folks i totally changed the layout of the promo codes page, everything is centered and i move the alert to the top of the page, to me it looks better.

 

the file name is clientaffcoupons.tpl and it goes in the modules/addons/affcoupons/

make sure you rename your old one to old or save it someplace.

 

here is what it looks like on the client side.

 

affpromsample.jpg

 

and here is the code..

 


<!-- moded version layout, all centered and added widths and colors and css and moved inputs to center page content -->

<!-- added notice style as it was not found in bootstrap -->


<div id="affcoupons-ajax">
      <div class="affnotice">

        <!-- added if notice color to change text color on alert to red -->

         <div id="notice" class="alert alert-{if !$notice_type}success{else}{$notice_type}{/if}" {if $notice} style="color:#cc0b34;"{/if} {if !$notice}style="display: none;"{/if}>{$notice}
         </div>
      </div>

    <div class="page-header">
       <div class="styled_title" align="center">
           <h2>Landing Page</h2>
       </div>
    </div>

   <form method="POST" action="{$index_page}?m=affcoupons" name="landingpage" id="landingpageForm" align="center">
       <input type="hidden" name="cmd" value="modlanding">
       <div class="well textcenter">
           <input type="text" name="landing" id="landing" value="{$landing}" class="bigfield" size="40" maxlength="60" />
             
           <input type="submit" name="Submit" value="Update" class="btn btn-primary btn-large" id="updatelanding" />
           <div class="internalpaadding">
            <p>This option will control where your referrals will be redirected after visiting your referral link.</p>
           </div>
       </div>
   </form>
<div class="page-header">
    <div class="styled_title" align="center" style="padding-top:15px;">
        <h2>Your Coupons</h2>
    </div>
</div>
<table  class="table table-striped table-framed" cellspacing="10" cellpadding="0" style="background-color:#EBEBEB;" align="center">
    <thead>
        <tr>
            <th width="10%" align="center">Delete</th>
            <th width="30%" align="center">Coupon Code</th>
            <th width="20%" align="center">Coupon Type</th>
            <th width="20%" align="center">Coupon Value</th>
            <th width="20%" align="center">Uses</th>
        </tr>
    </thead>

    {if !$coupon}
    <tbody><tr><td colspan="5" style="text-align:center;font-weight:bold;">No Coupons Found</td></tr></tbody>
    {else}
      <tbody>
       {foreach from=$coupon key=k item=v}
	<tr>
	<td width="10%" align="center">
	<a href="{$index_page}?m=affcoupons&cmd=del&cid={$v.id}"><img src="modules/addons/affcoupons/inc/images/delete.png" alt="Delete"></a>
	</td>
	<td width="30%" align="center">{$v.code}</td>
	<td width="20%" align="center">{$v.type}</td>
	<td width="20%" align="center">{$v.value}</td>
	<td width="20%" align="center">{$v.uses}</td> 
	</tr>
       {/foreach}
     </tbody>
    {/if}

</table>
<div class="page-header">
    <div class="styled_title" align="center" style="padding-top:15px;">
        <h2>Add Coupons</h2>
    </div>
</div>

<form action="{$index_page}?m=affcoupons" method="POST" name="addcoupons" class="form-horizontal">
    <input type="hidden" name="cmd" value="add" />
    <div class="well" align="center">

<!-- modified so that it is in one control group and one class controls css (side by side) and added bkground color -->

        <div class="control-group">
                <div class="controls">
                <label for="code" class="control-label">Coupon Code:</label>
                <input type="text" name="code" id="code" />       
                <label for="code" class="control-label" style="padding-left:10px;">Coupon Type:</label>
                <select name="type">
		{foreach from=$avail_coupon item=v}
		<option value="{$v.enc_string}">{$v.label}</option>
		{/foreach}
                </select>
                         <input type="submit" name="Submit" value="Add" class="btn btn-primary btn-large" />
            </div>  <!-- close controls -->
        </div> <!-- close group -->
     	    </div>  <!-- close well -->
</form>
</div> <!-- close div affcoupons-ajax -->
<br />
<br />
<!-- end affcoupons-ajax -->


 

enjoy :)

 

ps - one simple note to developer make sure your closeing your input tags with / and i dont know what template you used for your demo image on the first post but it dont look nothing like mine at all...

 

questions:

 

as admin how do i know what coupon codes are valid, once the client assigns a code it should be shown in the ACP someplace but it is not. So how do i know what is valid and what is not as an admin.

 

And do these codes go in the promo input on the cart page?

 

I dont need to print or design anything like a flyer, that is all for the affiliates to do? I am guessing thats how this works, they hand out a flyer with the code and then that person uses the code to get the discount. Correct?

 

and i guess ill be adding a menu link or some kind of link to https://yoursite.com/whmcs/index.php?m=affcoupons because it is not showing up on the affiliate page and i thought you said it would be there.

 

and also please tell me what this is i the image. if this is just a sample, how do i get rid of it i dont like samples on my site. What is planned here?

 

exampsb.jpg

 

thats all questions for now thanks.

 

thanks :)

Edited by durangod
Link to comment
Share on other sites

here is another change...

 

Issue: setting the type to Percentage still show for example 20.00 under coupon value..

 

Fix.. toss in an if statement to change the display accordingly.

 

here is the new code snippet for inside of modules/addons/affcoupons/clientaffcoupons.tpl

 

original code

 

<td>{$v.value}</td> 

 

i changed to this (this is my version with the width and align - you dont have to use those i just did it thats all

 


//basic version 

               {if $v.type == "Percentage"}
               <td>{$v.value|string_format:"%d"}</td> 
               {else}
               <td>{$v.value}</td> 
               {/if}



// or fancy version

               {if $v.type == "Percentage"}
               <td width="20%" align="center">{$v.value|string_format:"%d"}</td> 
               {else}
               <td width="20%" align="center">{$v.value}</td> 
               {/if}


 

so that will show lets say 20 if percentage and 20.00 if not..

Link to comment
Share on other sites

Seems to me your going to have to do some serious css mods or have someone do them for you. Im not sure where the dev got his screen shot on the first page. Maybe he also uses a custom theme im not that familiar with all the other themes, i just use portal. But i still believe your going to have to do some big changes to the tpl file to get that look.

Link to comment
Share on other sites

  • 3 weeks later...

hi,

 

first please update your thread in the add on section or maybe list both if you can.

 

but i found an issue. Seems like its a battle between your addon and the SEO addon, i made a post there as well.

 

http://forum.whmcs.com/showthread.php?47572-FREE-ADDON-WHMCS-SEO-Page-Manager/page3

 

 

when i went to try to get this to pass w3c it told me that my meta did not belong so i looked and i understand why now

 

this is what it showed i source.

 

 

<script type="text/javascript" src="https://xxxxxxx.com/billing/modules/addons/affcoupons/inc/js/affiliates.js"></script><input type="hidden" id="index_page" value="index.php"/><input type="hidden" id="script_name" value="/billing/index.php"/>

<meta name="description" content="The Portal home page has an assortment of hosting options and features for clients and non clients of DDH. Order your domain, become and affiliate, check network, submit tickets, check announcements and many more features. " />

<meta name="keywords" content="Members Area, Members Home, Portal Home, DDH Portal, DDH Client Area, Hosting Home Page, hosting" />

 

</head>

 

 

i dont know why the meta ended up below your js but it needs to be above, again i left them a post as well.

 

also i think those hidden inputs are yours and they dont belong in the header without an object assignment of some kind. They need to be either in the hook or somehow inside the parsed body section.

 

also i had to add type="text/javascript" to your modules file to get rid of that issue and also had to close a few inputs with / as well in your modules files.

 

is there any way we can get those inputs out of the head section and into the body, and is there any way you can move your js after the meta section so they dont conflict.

 

thanks :)

Link to comment
Share on other sites

you probably need to redo this section in your clientarea php file

 


} else {
$return_html = '<script type="text/javascript" src="' . AC_WHMCSe::get_module_url( 'affcoupons' ) . '/inc/js/affiliates.js"></script>';
$return_html .= '<input type="hidden" id="index_page" value="' . parent::$index_page . '"/>';
$return_html .= '<input type="hidden" id="script_name" value="' . $vars['SCRIPT_NAME'] . '"/>';
      }

 

 

especially the last two lines which put inputs in the header and they dont belong there. I would suggest possibly converting those to js and just using innerHTML and getElementById to load the values. If you cant do that i think i remember seeing a .loadafter function someplace that you can load stuff like that after the initial body container which is just as good.

 

 

yeah its called insertafter and you have it in your affiliates.js file

 

if (checkAffHeader || checkAffPath == '/affiliates.php' || script_name == '/affiliates.php') {
       $('<div>').load( '/' + index_page + '?m=affcoupons #affcoupons-ajax').insertAfter('.whmcscontainer .contentpadded .pagination');

 

 

just use the same function and load the inputs after the header is loaded.

 

if you need help let us know.

Edited by durangod
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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