Coupon referrals – shortcodes

Posted in

Hi, I just bought Affiliates Pro because I need a referral program for my e-commerce. I have a website where people sign up and renew their subscriptions monthly/six months/yearly, and I would like to have a referral program where each subscriber is associated with a referral code (coupon code), which allows him to get a credit for the next renewal for each purchase that has been made by entering his referral code as a coupon during the checkout.
So, the coupon code doesn’t give a discount to who is buying, but it gives a credit to the affiliate associated with the code.
I don’t use Woocommerce subscriptions because of checkout incompatibilities, so subscriptions are sold as simple product and renewed manually monthly/six months/yearly.

I created a coupon code in Woocommerce (that doesn’t give any discount to the costumer) and associated it as attribute in the “manage affiliates” area. I set “Cantidad Referencia” under Affiliates > Settings > Commissions with an amount of “20.0” , because I want to credit 20€ for every sale. I downloaded and installed WooCommerce Affiliates Gateway to allow subscribers to use the accumulated credit during the renewal checkout.

First of all I want to be sure with you that I made everything correctly for get what I want to do. And know if there is a way to limit the amount of credit that an user can earn?

I haven’t done a real test yet to see if the system works, but I’m writing to you because I have a problem with shortcodes. I use a builder (Divi), so I insert them as a code element in the “my profile” page. I would simply like to add the field of the personal referral code and the list of accumulated credits.
So I try to add these two shortcodes:
[affiliates_affiliate_profile show_attributes=”coupons”]
[affiliates_referrals show=”total” status=”closed”]

But in the front end of the “my profile” page logged in as one of the accounts associated with a coupon (created in Woocommerce and associated to the affiliate as attribute) nothing is shown. Can you please help me to find out if I’ve done anything wrong with it?
Thank you!

10 Responses to Coupon referrals – shortcodes

  1. George December 28, 2022 at 7:38 am #

    Hi Angela,

    Sure you may follow-up here and I’ll guide as much as possible.
    What you need is basically a WooCommerce gateway, that will provide another payment option using the affiliate commissions. We also have an example implementation here which you can use as reference for your own implementation.

    Kind regards,

  2. George December 21, 2022 at 4:45 pm #

    Hi Angela,

    I have also included several screenshots from my tests, that you can also use.
    The issue wasn’t even related to the coupon code, because after assigning it to my own affiliate account, the data was correctly rendered in both languages.

    The affiliate you mentioned didn’t use an existing username and basically you were viewing affiliate data without being an affiliate.
    I have edited the affiliate and fixed the record.

    The second part now, appears to be related only to this specific page. When creating another page with only two shortcodes, the results are also correct.

    Maybe there are restrictions applied to the content or the cache is not serving the correct results. Perhaps you should also try excluding it from caching as well or temporary disable caching for the whole site. Furthermore, you can also try using my account, once you reset the password. The results are there but something else is preventing the proper representation.

    Kind regards,

    • Donna Page December 23, 2022 at 9:06 am #

      Hi George! I’m glad to tell you that everything with shortcodes in the my profile section is fine now. Thank you very much for your help.

      If I need help with Affiliates Gateway, can you help me or is better for me to open a new ticket?
      Basically, I need to understand if there’s a way to use the credit as discount on total during checkout. I’ve tried with my 20€ credit on a 110€ product, but the error is “Error, you don’t have enough credit.” like I’m supposed to pay the whole product with my credit.

      Thank you so much again!

  3. George December 21, 2022 at 1:41 pm #

    You’re welcome Angela.

    Sure I’ll have another look and show you what I get with screenshots. If it doesn’t relate to the Builder then I’ll also check the coupon(s) you’ve assigned to your affiliates. Once I have an update, I will follow up on this thread.

    Kind regards,

  4. George December 20, 2022 at 4:38 pm #

    Hi Angela,

    Thanks I’ve received the password reset link to your site.

    I think that the issue with shortcodes you have relates to the position of the element and the Builder. For a strange reason when the shortcode is placed after the account details, nothing shows up. On the other hand when placed before the account details, everything shows up.
    I have cloned the profile page and added the shortcode on top, where you can see the result properly rendering. Also, to exclude that the shortcode doesn’t work properly I’ve created another page containing only the shortcode which also renders information correctly. I think that you should take a second opinion on this matter from Divi support and if there are any additional actions needed from our side after that, you are more than welcome to notify us.

    As for limits to referrals you need to create a custom implementation to support this use case. Affiliates Pro supports commissions calculated by a formula rate which in turn allows you to use a filter hook and adjust the formula arguments and results programmatically.


    Using that filter and through its callback function, you can get the totals for the affiliate involved in that new referral, check if they have reached your limit and then decide what to do with this new referral, ie give a zero commission. Furthermore, there are a couple more details that you haven’t mentioned earlier and IMO are important. Should the affiliate first exhaust their credit, or can keep it in the system? Would you allow them to get more referrals and credits, or once they have reached the limit, they should spend it?
    In other words, what you’re looking for can be done but only through a custom addon that will perform these checks.

    Kind regards,

    • Donna Page December 20, 2022 at 7:31 pm #

      Hi George, I’m sorry that I have to bother you again, but in the frontend I still can’t see the shortcode elements.
      I’ve first go to see what you have done without making any edit, and I already couldn’t see them (you did??). So then that’s what I’ve done (using Divi builder):
      1. I moved the shortcodes at the top of the my profile page, in the same section (the green one) of the woocommerce elements but they were still hidden; I then tried to isolate them in a section of their own, but they still not show.
      2. I created a new page, with only the shortcode of the coupon code (like you did), but it shows nothing.
      3. I deactivated Divi for that page and I used the classic editor, insert the shortcode but it still empty – the text of the shortcode is not shown so it’s valid but it doesn’t show the value.

      In all of this I checked the frontend being logged in as marta.beretta@ , an account that you can see in Affiliates > Manage Affiliates is registered and with a coupon code as attribute. Plus, this is the account that received our first referrals – we did all the proceeding to see if everything works (you can check that a referral was correctly attributed to that account in the backend) – so I totally don’t get why nothing is shown. This account has a 20€ credit gained.
      I also cleaned the cache a couple of times after making an edit, but nothing changed.
      Is there any other attempt you can do to see you can work this out please? Feel obviously free to create new pages, it is not even need to make them private. If it’s needed to check that everyting is set correctly in the Affiliates backend area feel free to take a look and make all the necessary changes or create new affiliates or new coupons.

      For limit referrals I totally get what you’re saying and I don’t want to make things harder than they already are so I think we’ll go with manual checking. We don’t think that the referral program would go so wild to make it unfavourable for us.

      Thank you very very much for your support.

  5. George December 20, 2022 at 1:57 pm #

    Hi Angela,

    Does it render the affiliate profile form or nothing at all? Normally when you use a shortcode with the Divi Builder, you can see what will be rendered even while on the Builder view. Can we have a look at your Dashboard? You may use my personal email address, george at itthinx dot com, and create a temp admin account for your site.

    As for the limit on referrals that you asked, does the affiliate renew their own subscriptions? Or do they get a coupon based on their referrals? Can you share some more details on your affiliate plan?

    Kind regards,

    • Donna Page December 20, 2022 at 2:21 pm #

      Hello George, it shows nothing at all. I just created a temporary admin account with, did you receive the email for the psw reset?

      Anyway about renewals: we associate to our six months and annual active subscribers a coupon code through Affiliates. This assigned referral code can be shared with friends/familiars/etc and if one of them subscribes a six month or an annual subscription, the owner of the code received a 20€ credit that can be used on his next renewal. So, basically, the amount of accumulated credit will be used during the renewal checkout as discount. For example: my 6 months subscription (value 110€) is expired, I accumulated 40€ of credit thanks of 2 referrals (a friend of mine and my mom subscribed to the website and used my referral code during their checkout). When I’m about to pay for the renewal, the accumulated credit will be deducted from the total (and I will pay 70€).

      Thank you again for your help,

  6. George December 19, 2022 at 11:44 am #

    Hi Angela,

    Welcome to our support forum and many thanks for choosing Affiliates Pro as your affiliate management system.

    Your settings are mostly correct, you just need some minor refinements.
    As for the commission calculations you should go to Affiliates > Settings > Commissions and set the Method to Rates. The other commission methods are deprecated and should be avoided. Then go to Affiliates > Rates and create a new rate of type Amount and a value of 20. This way you can ensure that the referral commission will always be 20 regardless of the sale amount.

    Regarding the coupon(s) shown to your affiliates in the frontend, the shortcode is correct as long as the double-quotes are correct

    [affiliates_affiliate_profile show_attributes="coupons"]

    and then you are viewing the page containing the shortcodes as an active affiliate. The logging-in affiliate must exist on your system under Affiliates > Manage Affiliates and the coupon must be set in their attributes.

    The next shortcode

    [affiliates_referrals show="total" status="closed"]

    will render the commission totals that have been marked as Closed, either manually or through Affiliates > Totals. Perhaps IMO you should render accepted totals instead but this also depends on your requirements. Again for this shortcode, the logging-in affiliate must exist on your system under Affiliates > Manage Affiliates.

    Kind regards,

    • Donna Page December 19, 2022 at 10:33 pm #

      Hello George, thanks for your reply. I’ve done everything but I still have problems with the shortcodes, I am logged in as one of the affiliates (registered under Affiliates > Manage Affiliates and with a coupon as attribute), but it stills show nothing… do you know what could be causing it?

      Can I also ask you if there is a way to set a maximum total amount of credit that a user can earn from referrals (for example 3 referrals – 60€) that resets after be spent as discount for a renewal?
      Thanks again

We use cookies to optimize your experience on our site and assume you're OK with that if you stay.
OK, hide this message.

Affiliates · Contact · Jobs · Terms & Conditions · Privacy Policy · Documentation · Downloads · Useful Plugins · My Account