Affiliates getting credit for coupon use, but commissions calculated at 0 (zero)

Posted in

Alright, We’ve installed and activated:
– Affiliates Pro
– Affiliates WooCommerce Integration
Affiliates Custom Method Coupon Rates

Additionally, I’ve added the filter to my functions.php as instructed in make-affiliate-coupons-case-insensitive.

I’ve added a coupon-prefix rule at Affiliates>AffiliateCMCouponRates, setting a commission rate to 0.35 for any coupon with a “wholesale” prefix.
Additionally, I couldn’t find/recall how to set a default referral rate in the admin GUI, so I set the REFERRAL_RATE_DEFAULT to 0.1 (not ‘0.1’) in `affiliates-cm-coupon-rates.php`. (all other class constants were left as-is, so if I need to change anything in there ….)

I put through three $0.50 test orders.
Two for one affiliate …one of which should have yielded $0.05 commissions, and the other $0.175 commissions.
The third for a second affiliate which should have also yielded $0.05 commissions.
After seeing no commissions for open orders, I changed status to Processing, then Completed and checked after each status change.
Still no commissions.

WHAT AM I MISSING ???

15 Responses to Affiliates getting credit for coupon use, but commissions calculated at 0 (zero)

  1. William May 30, 2017 at 6:36 pm #

    …in fact, that idea COULD probably be made extendable pretty easily with an `affiliate_coupon_group_type`, and implemented for assigning coupons to affiliates.
    The existing comma-separated way works well enough, but if the structure and UI come out nicely, it _may_ be a worthy re-use 🙂

    • George June 15, 2017 at 12:11 pm #

      An Affiliate-Coupon-Groups plugin sounds interesting, so i will check existing implementations we have like Groups Coupons and how it could integrate with Affiliates plugin.

      Thanks a lot for your cooperation and suggestions.

  2. William May 30, 2017 at 6:26 pm #

    Just an idea, if you made an Affiliate-Coupon-Groups plugin, we’d buy it.

    Something along the lines of:

    Add the ability (and in interface) to create coupon-groups, and to add coupons to them.
    (I’m expecting coupons can only belong to a single group (for simplicity)).
    Then, have a commission-rate setting for each group and a check-box for whether to calculate the payout from the base_amount, or final amount after discounts.

    In addition to allowing us to drop the coupon-prefix idea (limited), one would also gain the ability to scale out as many rates as needed.
    …and even move existing coupons from one commision/payout rate to another en-masse.

  3. William May 30, 2017 at 5:12 pm #

    Tested, and it works as you’ve shown.
    There was a precision problem, though, so I customized the code a little and the issue is now resolved.

    Since commissions are calculated from base-price, a high precision is required to calculate the correct commissions for the after-coupon price, and apparently floats don’t quite cut it.

    As such, rather than type casting with `floatval()` in Affiliates_CR_Method, I used `bcmul(XXXXX, ‘1’, 9)`.
    I used that, both, when storing the referral rate settings and when calculating the sum.

    All that was left at that point was rounding the sum when calculating commissions.
    Since bcmath apparently doesn’t have a rounding function, I threw in the function found on the bcscale docs:
    http://php.net/manual/en/function.bcscale.php/#79628
    It worked like a charm.

    My implementation lacks some checks (and eloquence) that would make it more portable, but my PHP has bcmath enabled, so it’s working for us.

    Thank you for the help.
    (still, though, if there were any way to improve the efficiency of your support cycle, I strongly recommend doing so.)
    Again, THANKS FOR ALL THE FANTASTIC SUPPORT!

    • George June 15, 2017 at 12:07 pm #

      Thanks for the suggestion, i will make some tests myself regarding the calculation and update accordingly. Also, if you are familiar with GitHub and git, you can send a PR there.

      I’m glad it’s working now and trust me we are constantly working on improving all the services provided.

      Cheers

  4. William May 29, 2017 at 7:27 pm #

    THANK YOU
    I will check it out later today and post back.

  5. George May 29, 2017 at 6:12 am #

    Hi William,

    Thanks for providing access to your test site.
    The issue with the custom method was because it didn’t truncate the coupon prefix. Probably you modified the code yourself to keep a bigger part of the coupon code.
    The main purpose is to keep a record of the coupon prefix for a maximum of 3 characters. I’ve updated the plugin, added a default referral rate in the admin page and installed in your test site.
    Everything works as it should now, but please have a look by yourself in case there is something else missing.

    Cheers,
    George

  6. William May 26, 2017 at 11:16 am #

    Downloaded/installed the latest from GitHub.
    Still zero commissions, and still same two deprecation errors for each test order.

    We’re in the middle of pushing the site live (without that feature), so once I get done with all this craziness, I’ll get that email out to you.
    Thanks-a-bunch

  7. William May 26, 2017 at 10:43 am #

    Oh goodness!
    When you said “get the new copy and try again”, I just @$$umed you were talking about Affiliates Pro.
    Thanks for specifying.

    I’ll post back with an update regardless.

  8. George May 26, 2017 at 9:19 am #

    Hi William,

    This plugin is a custom made solution which is offered for free. Also, support is provided through this forum only. The only way to download it, is through GitHub. I host it there instead of the WP plugin repository simply because it takes at least a week until a plugin is approved( or rejected ) by the WP plugin repository.

    As i mentioned, you can download the zip file from GitHub from this link. You press the green button and select Download ZIP. After that you upload the zip on your Dashboard and install it as you would with any other plugin.

    If though after installing the updated version you still have issues, please send me temp admin access to your Dashboard to george at itthinx dot com.

    Cheers,
    George

  9. William May 25, 2017 at 10:40 pm #

    Well …kinda outa desperation just because time is SO limited, I tried uninstalling the plugin and reinstalling from a fresh download.

    Of course, no improvement.
    Commissions still coming out to zero, and it still threw errors for both of those deprecated methods:
    >[25-May-2017 22:30:36 UTC] The WC_Order::get_order function is deprecated since version 3.0.
    >[25-May-2017 22:30:36 UTC] The WC_Order::populate function is deprecated since version 3.0.

    As an aside, posting one question/answer per day, and then having to pause the whole project is really not working too well on this end.
    How can we OPEN a line of communication so that there isn’t a FULL DAY’S DELAY between messages ??

  10. William May 25, 2017 at 3:00 pm #

    Thanks.
    I’m not seeing the update avail, though.
    I do have the ITThinx Updates plugin, and that doesn’t seem to be picking up any new version availability (no that I’d know how to tell :P).
    The Plugins page doesn’t show an update available.
    And the Downloads page on your site only provides the same version I already have …2.18.1

    Am I missing something?

  11. George May 25, 2017 at 9:19 am #

    Thanks for your feedback.
    Indeed WC_Order::get_order is deprecated but i didn’t get the notice on my installation.
    Anyway, i have updated the plugin, feel free to get the new copy and try again.

    Cheers,
    George

  12. William May 24, 2017 at 3:43 pm #

    Thanks.
    To clarify, I am also getting referrals _recorded_ …their amounts are just zero =/

    Verified that we have Affiliates_CR_Method::coupon_rates selected under Affiliates > Settings > Commissions.
    Enabled debug mode and logging.

    Then ran another test order.
    Same results …showing referral, but zero commissions.
    Log says:
    >[24-May-2017 15:30:09 UTC] The WC_Order::get_order function is deprecated since version 3.0.
    >4-May-2017 15:30:09 UTC] The WC_Order::populate function is deprecated since version 3.0.

  13. George May 24, 2017 at 9:56 am #

    Hi William,

    This sounds odd.
    I made the same tests like you but i got referrals recorded.
    Please enable debugging and see if there is something logged.
    Also, keep in mind that REFERRAL_RATE_DEFAULT is used as a fallback, so that the referral amount under Affiliates > Referrals is not empty but zero.
    Check once again that you have chosen Affiliates_CR_Method::coupon_rates under Affiliates > Settings > Commissions.

    To enable debugging, edit your wp-config file and replace the following line:
    define('WP_DEBUG', false);
    with these lines:
    define('WP_DEBUG', true);
    define('WP_DEBUG_LOG', true);

    Finally create a new file named debug.log under your wp-content folder.

    Kind regards,
    George

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

Share