Make affiliate coupons case-insensitive?

We’re in the last steps in trying to get our site up, and discovered something in testing.
There’s a mis-match between WooCommerce coupons and AffiliatesPro on case-sensitivity.

Woo coupons are case-insensitive.
Our coupons, as imported from our previous solution, contain mixed cases.
The affiliate-coupon attributes were likewise imported identically.
So far, so good.
Affiliates got properly credited with test orders.

Now, any time anything is updated for a given coupon, the entire coupon name string gets converted to lower case.
Coupon still works for the customer, but affiliate no longer gets credited with the sale.

This is a major issue since we’re talking about pre-existing long standing coupons.
If a customer enters the code in any case(s), it looks fully successful but the affiliates credit falls into an invisible crack.

The safest way for us to make, both, our customers and affiliates happy would be to just have the affiliate-coupon association case-insensitive.
PLEASE help ASAP

UPDATE: I’ve sifted through some of the code, and I believe the culprit is Affiliates_Attributes_WordPress::get_affiliate_for_coupon(). I’ll go on the hunt for that class, but PLEASE give any direction you can. Time is of the essence.

Posted in
Tags

Comments

15 responses to “Make affiliate coupons case-insensitive?”

  1. William Avatar

    SOLVED!!!

    Thanks-a-bunch for the fix!

  2. William Avatar

    Fantastic!
    I’ll take a look, thanks.

  3. Hi William,

    Affiliates plugin has been updated to 2.15.8 where a new filter affiliates_coupons_equality_test has been included to cover the issue with case-sensitive coupons.
    The filter usage is described also in the documentation and can be implemented like this.
    add_filter( 'affiliates_coupons_equality_test', 'check_coupons', 10, 3 );
    function check_coupons( $test, $coupon1, $coupon2 ) {
    if ( strcasecmp( $coupon1, $coupon2 == 0 ) ) {
    $test = true;
    } else {
    $test = false;
    }

    return $test;
    }

    Please have a look and include the filter in your functions.php file.

    Kind regards,
    George

  4. William Avatar

    Hrmmm, OK.
    We must have accepted an update at some point between tests because my hack is no longer in the file, and case-sensitivity is back to how it was previously … breaking things >[

    Keep in mind that the problem is NOT whether coupons are created in upper, lower, or mixed case.
    As such, the update to the Affiliates Coupons plugin misses the point.

    The problem is case-sensitivity.
    I can foresee no use-cases where case-sensitivity would be desirable, and can imagine several use-cases (including fringe) where case sensitivity would be undesirable.
    Please fix asap.
    If the next version of your plugin comes out without addressing this issue and the problem reverts while we are running live, that would create MAJOR issues.

    As always, thanks-a-bunch for your hard work.

    BTW, I restored my hack and everything works as it should again.

  5. William Avatar

    Additionally, as discovered in my auto-coupon post, there seems to be a difference between how commissions are handled for regular sales and “auto-coupons”.

    Please give some hints on what I’m looking for.
    The obfuscated code is a bear to sort through.

  6. William Avatar

    Before installing the update, I just wanted to confirm that this addresses the case-sensitivity … not just creation of coupons in lower case.
    The former solves the problem.
    The latter only covers some use cases.

  7. Hi guys,

    We’ve prepared an updated version that will generate the coupons accordingly so that you don’t need to apply this hack. Please switch to Affiliates Coupons 1.2.0 which is now available in the http://www.itthinx.com/downloads/ section and you’ll see the coupons generated will use lowercase.

    Thanks for your patience and efforts!

    Cheers

  8. William Avatar

    Ahhh, good to know.
    I never thought about that.
    Thanks

  9. That should do the job too.

    The obfuscated code reduces the code significantly, thus giving a pretty much smaller plugin.

    Cheers

  10. William Avatar

    For reference, here’s what I did:

    I changed
    if ( $IXAP387 === $IXAP380 )
    to
    if ( strtolower($IXAP387) == strtolower($IXAP380) )
    in /plugins/affiliates-pro/lib/ext/wordpress/class-affiliates-attributes-wordpress.php

  11. William Avatar

    Yes, thank you.
    I finally found where the hosting service had their dir search, so I was able to find it.

    De-obfuscating the script is a bear, but was able to get mostly through it the other morning.
    I’ll be finishing that today.

    Again, thank you.
    And, why the obfuscated code?

  12. Hi William,

    You should have a look at the definition of this method and modify the coupon check. It is located at class-affiliates-attributes-wordpress.php.

    Cheers

  13. William Avatar

    I’m back on this project for a couple hours this morning.
    Decided not to do the export/import for those case changes because it still leaves our biggest problem in play.

    I understand how it goes and that you may not be able to get the patch out immediately.
    If that’s the case, please at least point me to where I can find the offending code.

    Any amount of time that can be saved will be deeply appreciated.
    I can simply put a bandage over it, if I have to, until the update gets released.

  14. William Avatar

    THANK YOU!

    I’ll go ahead and do something like this, but just to re-iterate, this only covers a part of our problem.
    The largest issue remains, in that these coupon codes are already out there in in use in their mixed case.

    Since it’s 100% inevitable that some user(s) will enter the coupon in mixed case, I’m crossing my fingers that this patch is pushed out SOON.
    (this is holding up our going live)

    Thanks-a-bunch!

  15. Hi William,

    Indeed you are right about this. The issue has been reported and the plugin will be updated asap.

    In the meantime, you can edit your affiliates export file and convert all affiliate coupons to lowercase. If you edit the file with Excel, you can use the formula

    =LOWER(A1)

    in an empty column where A1 is the first cell containing the first coupon code. Then drag it down until all the coupons are converted to lowercase and finally cut+paste the new lowercase coupons column to the old Coupons column. Please have a look at this topic from Microsoft Office.
    After that you can re-import your affiliates data again.

    Kind regards,
    George

Share