Tips and Tricks HQ Forum

Support Forum for Tips and Tricks HQ Products

Register or log in - lost password?

Search the Forum

Tips and Tricks HQ Forum » WP Affiliate Platform

Return value of main function "wp_aff_award_commission"

(5 posts) (2 voices)
  • Started 1 year ago by Edward
  • Latest reply from Edward
  • Related Topics:
    1. Execute custom function after registration of a specific level - API or Hooks?
    2. Estore function
    3. Whats the widget php function to display the compact version of the cart
    4. Empty Shopping Cart Error When Checking Out with PayPal
    5. Manual Payment checkout flow adjustments

Tags:

No tags yet.

  1. Edward
    Member

    Currently the return value of main function "wp_aff_award_commission" which do the job for award referer is a piece of html text always says the award is success no matter if this operation is indeed success or fail.

    The possibility of award fail is very tiny, but if the operation failed once and nobody to handle this mistake, it can occur twice, triple, and more. It is important for us to know if the operation unfortunately failed thus we can correct this manually and do something to avoid it happen again.

    Is there already a plan for this?

    Posted 1 year ago #
  2. amin007
    Key Master

    As you have mentioned already that the possibility of a failure is tiny so if it does fail just knowing about it doesn't help that much. What really helps is if you can have some sort of indication as to why it failed too.

    So I have made the function return a big string rather than just true or false. You can then search for the following in this returned string:

    "The sale has been registered in the WP Affiliates Platform Database"

    If the above is not present then that would mean a failure in which case you can print out the full string which will hopefully some indication as to why or where it actually failed.

    Posted 1 year ago #
  3. Edward
    Member

    I'm sorry, but in current logic of your script, "The sale has been registered in the WP Affiliates Platform Database" will always be presented, unless the script crashes, in that case, no message will be presented also includes this one.

    The only case it will not be presented is the input parameter $referer is empty, which is not so useful.

    Also i think crashes'd better be avoided at least in this MAIN function, because once it crashes, all following actions will not be executed

    Posted 1 year ago #
  4. amin007
    Key Master

    I see. I can add in more checks so if it returns false then it adds the appropriate message to that string. I think the only one that can fail is the database update execution.

    Posted 1 year ago #
  5. Edward
    Member

    That'd be appreciated!

    And ye, database operation, like get, update, wordpress guys did a lot of error handling in these functions to catch exception in various situation, make use of their return value is easy and greatly improve script robustness.

    Posted 1 year ago #

RSS feed for this topic

Reply

You must log in to post.

Tips and Tricks HQ Forum is proudly powered by bbPress

Tips and Tricks HQ  | WP Shopping Cart  | WP Affiliate Software  | WordPress Membership Plugin