Jump to content

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


HostT

Recommended Posts

ok folks here is the fix for this addon, gosh willy wonka im a nice guy lmao ....

 

issue: if you use this addon your page will not pass w3c because the way they coded this, it puts html input tags in your header, which is not where they go. This fixes that issue..

 

so here we go..

 

open your templates/<whatever you use>/header.tpl file

 

i did mine for portal so yours may be different but basically you want the hidden inputs to be right after the top container. They are hidden but if you need to test and make them visible then you dont mess up your page layout if you put them here, its a good empty place... so whereever you put them just put them where it works for you.. but near the top of the page.

 

here is my layout to give you an idea..

 


<body>

{$headeroutput}
<div id="top_container">
 <div id="top">
   <div id="company_title">{$companyname}</div>

    <div id="welcome_box">{if $loggedin}{$LANG.welcomeback}, <strong>{$loggedinuser.firstname}</strong>   <img src="templates/{$template}/images/icons/details.gif" alt="{$LANG.clientareanavdetails}" width="16" height="16" border="0" class="absmiddle" /> <a href="clientarea.php?action=details" title="{$LANG.clientareanavdetails}"><strong>{$LANG.clientareanavdetails}</strong></a>   <img src="templates/{$template}/images/icons/logout.gif" alt="{$LANG.logouttitle}" width="16" height="16" border="0" class="absmiddle" /> <a href="logout.php" title="Logout"><strong>{$LANG.logouttitle}</strong></a>{else}{$LANG.please} <a href="clientarea.php" title="{$LANG.loginbutton}"><strong>{$LANG.loginbutton}</strong></a> {$LANG.or} <a href="register.php" title="{$LANG.clientregistertitle}"><strong>{$LANG.clientregistertitle}</strong></a>{/if}
  </div>
</div>
</div>

<!-- so this is where i put mine right after the 3 close divs -->


 

so now that we have the postion, lets put the code.

 

basically what this does (and youll understand better when you see the other file we will work on) is it physically puts the input tags on the page in the right place. And then we pass the values to the js to load the inputs.

 

The way they did it was they had a string "<input type=...........blah blah" and just stuck that in the header from their file. so we will fix that..

 

 

You have two values to be passed 'page value' and the 'script name'. I found the {literal} to be required but if yours it not working you might try without it but it should be ok..

 

 

what this js does is it pulls the values from a session strorage area that we store the values in, and it checks to see if the page is freshed it updates the value.

 

 



<!-- added for affiliate inputs -->

<div id="affcoupInput">
<input type="hidden" id="index_page" value="" />
<input type="hidden" id="script_name" value="" />
</div>

{literal}
<script type="text/javascript">

/* page value */

  var pagefield = document.getElementById("index_page");

 if (sessionStorage.getItem("couppage")) 
 {
  pagefield.value = sessionStorage.getItem("couppage");
  }

 pagefield.addEventListener("change", function() 
 {
 sessionStorage.setItem("couppage", pagefield.value);
 });

/* script name */

 var sname = document.getElementById("script_name");

if (sessionStorage.getItem("coupsname")) 
{
sname.value = sessionStorage.getItem("coupsname");
}

sname.addEventListener("change", function() 
{
 sessionStorage.setItem("coupsname", sname.value);
 });

</script>
{/literal}

<!-- end add -->

 

save your header.tpl

 

 

and then open whmcs/modules/addons/affcoupons/inc/clientarea.php

 

 

the original code looks like this

 


$return_html .= '<input type="hidden" id="index_page" value="' . parent::$index_page . '"/>';
$return_html .= '<input type="hidden" id="script_name" value="' . $vars['SCRIPT_NAME'] . '"/>';

 

since that runs right along with their other js above it thats why it all gets put in the header..

 

so we are going to comment that old code out and put some new code above it..

 

here is the finished replacement code

 

 

IMPORTANT!

 

your going to be working in the 'else' section... the first $return_html statement looks like this

 

$return_html = '<script type="text/javascript" src="' . AC_WHMCSe::get_module_url( 'affcoupons' ) . '/inc/js/affiliates.js"></script>';

 

LEAVE THAT ONE ALONE, dont mess with it... just do the changes below that one.

 

 

and here are the changes, this grabs those values and stores them so we can grab them when the header loads and the js runs.

 


 //added to fix the input in the header issue, there is also new js in the header tpl file
 $return_html .= '<script type="text/javascript"> 
 sessionStorage.setItem("couppage", "' . parent::$index_page . '");
 sessionStorage.setItem("coupsname", "' . $vars['SCRIPT_NAME'] . '");
 </script>';


  //old code not used - puts inputs in header does not pass w3c
  //$return_html .= '<input type="hidden" id="index_page" value="' . parent::$index_page . '"/>';
  //$return_html .= '<input type="hidden" id="script_name" value="' . $vars['SCRIPT_NAME'] . '"/>';


 

 

save it, thats it..

 

you can go back to your header if you want and change the inputs from hidden to text to see the values, click on some different pages to make sure it changes... and then set them back to hidden..

 

all done..

 

this one was a challenge, me and jquery are not buddies and honestly i tried several different ways to make this happen and no dice so i went back to old reliable normal js lol..

 

glad to help..

Edited by durangod
Link to comment
Share on other sites

  • 4 weeks later...
How do I fix this:

http://prntscr.com/3v7904

 

to make it look like it does when here:

http://prntscr.com/3v795z

 

I use a custom theme.

 

As I mentioned in our emails back and forth, this is related to your theme and how it completely changed the div tag layout from the default setup. The next release will have a lot of fixes including an option to use Ajax to dynamically load, or use smarty template tag to output.

 

 

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...

 

Yes I agree the tags should use self closing syntax to be XHTML compliant as i'm guessing some people are using XHTML as their doctype. There are some issues with self closing tags in HTML5 but input is not one of them. I'll add this as an issue on GitHub and get it fixed in next release.

 

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

 

As for the screenshots, those were from a blank WHMCS install using the Default theme, I did not change anything on the actual install and it should have been using the Bootstrap 2 framework. Chances are they changed something in later releases so it's probably best to just integrate a framework myself or write my own CSS code as it wouldn't be much. I'll add this as an issue as well.

 

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

 

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.

 

Right now there is no way to do so, this is planned feature but I haven't had time to implement it yet, the original addon did not have this available so it has to be added from scratch.

 

Here's the existing feature/issue:

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

 

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

 

Yes, just like a regular promo code.

 

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?

 

You can use it however you want, it's actually just an easier way for your affiliates to give out instead of a link, because when you think about it, if someone has a promo code chances are they are def going to use it, when they do it's tied to the affiliate who gave it to them, so there's no worries about making sure they go to the right URL.

 

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.

 

This addon wasn't designed to automatically add menu items to your site, you will need to manually add a link if you want them to go to that page. That is the default WHMCS addon module page, right now it loads that DIV through Ajax and appends it to the bottom of the Affiliates page. As mentioned above in the next release I will add an option to use JS to automatically add it (like it is now), use custom smarty template variable, or just a button linking to it.

 

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

 

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?

 

That was is the sidebar link that still showing the demo HTML link. I just copied it out of the sample addon file and forgot to change it, will be fixed on next release.

 

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

 

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

 

Not sure what you mean, "list both if you can" ... list both what? If you're referring to updating the first post in this thread, that's not possible as unfortunately WHMCS has locked the thread so I can't edit it.

 

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.ph...-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

 

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.

 

Yes, this will be fixed in next release, I rewrote the entire codebase of this addon over a weekend when I found numerous security issues with the original version, so never got around to testing for valid HTML. Regarding the type="text/javascript" it is not required in HTML5 but for compatibility with HTML4/XHTML i will add it.

 

script type attribute:

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

 

header issues:

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

Link to comment
Share on other sites

1. As Affiliate option in WHMCS which can to Enable/Disable the Affiliate System, I also want to give the option to Enable/Disable the Landing Page feature on the Affiliate page in the Client Area.

 

2. I want to restrict members to make 1 Coupon Code for 1 Coupon Type.

They also can Edit the existing Coupon Code and they can Delete it.

 

I think this idea is needed by many people. I give thanks and appreciation for this job.

Link to comment
Share on other sites

  • 2 weeks later...

I have the same problem... I posted on GitHub as well; hopefully we'll hear something soon.

 

Any idea on how to get this to work? The link: index.php?m=affcoupons, works properly. But if you go to the Affiliates link through WHMCS it does not show up on the bottom of the affiliates page like it is supposed to.
Link to comment
Share on other sites

  • 1 month later...
  • 9 months later...
  • 4 weeks later...
Hi,

 

Will this be updated to work with WHMCS v6.0? - As the new WHMCS affiliate system has anice look and feel, it would be great to integrate this plugins functionality with it.

 

Because the author is not often here in the forum, the question should be better placed on GitHub.

Link to comment
Share on other sites

  • 2 months later...
  • 3 months later...

Looks like I have fixed it for 6.2.2

 

in

modules/addons/affcoupons/hooks.php

add

use WHMCS\Cookie;

 

and change

WHMCS_Cookie::get ---> Cookie::get

WHMCS_Cookie::set ---> Cookie::set

 

Now not show error messages and looks like working.

 

Test on your side

Link to comment
Share on other sites

  • 1 month later...
Looks like I have fixed it for 6.2.2

 

in

modules/addons/affcoupons/hooks.php

add

use WHMCS\Cookie;

 

and change

WHMCS_Cookie::get ---> Cookie::get

WHMCS_Cookie::set ---> Cookie::set

 

Now not show error messages and looks like working.

 

Test on your side

 

bro , can help us for whmcs 6.3 ???

Link to comment
Share on other sites

This is great to hear! From the OP download link is this the only change required?

 

Looks like I have fixed it for 6.2.2

 

in

modules/addons/affcoupons/hooks.php

add

use WHMCS\Cookie;

 

and change

WHMCS_Cookie::get ---> Cookie::get

WHMCS_Cookie::set ---> Cookie::set

 

Now not show error messages and looks like working.

 

Test on your side

Link to comment
Share on other sites

  • 1 month later...
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