How to properly implement an affiliate script for discount-based commissions?

Hi!

I need help implementing an affiliate script. I have implemented it and but it does not work properly.

There something wrong with the order value - it returns the regular price, not the actual price. So this will cause problem since I’m going to work with affiliates and they are going to offer discount to their followers and their commission should be based on the sales price, not the regular.

So my problem is: the parameter for order is with tax and on regular price. I need to change the script so it is based on price without tax and the actual price no matter if its regular or on discount.

This is the script that I added to the checkout:

Appreciate all help I can get!

Thank you, Merih

www.urbanjoi.com