• Resolved DaanvandenBergh

    (@daanvandenbergh)


    Hi!

    One of my users for my Moneybird plugin filed an issue that tax rules for negative fees (i.e. discounts) weren’t applied properly.

    Upon further inspection I noticed that the no_tax property for fees isn’t stored/fetched properly when the EDD_Payment is created, e.g. when using edd_get_payment().

    In includes/payments/class-edd-payments.php on line 2850, there’s this code:

    So, while creating the EDD_Payment object, the no_tax property is based upon the fact whether the current fees tax is 0.

    While in includes/class-edd-fees.php on line 115 in the edd_add_fee() function (which is used when storing it to the session) the no_tax property is based upon the fact whether the fee is negative or not:

    So, for negative fees, this creates an inconsistency between what’s stored in the session and what’s present in the fees property of the EDD_Payment.

    IMO, line 2850 in includes/payments/class-edd-payments.php should be changed to (bool) $args['amount'] < 0 to fix this. But, that’s just an assumption.

    Looking forward to a fix!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Mihai Joldis

    (@misulicus)

    Hey @daanvandenbergh

    Could you tell us the version of EDD that you are on and if possible a scenario that we can use to test and replicate this?

    Also, if you are using edd_get_payment we would recommend to move to edd_get_order if you don’t need to support EDD 2.x anymore.

    Thread Starter DaanvandenBergh

    (@daanvandenbergh)

    Hi again,

    The code I quoted is present in the latest version.

    I’m not using edd_get_payment(). I’m hooking into the edd_complete_purchase action which holds the EDD_Payment object and fetches it using edd_get_payment() as you can see in the screenshot:

    Thread Starter DaanvandenBergh

    (@daanvandenbergh)

    A possible scenario would be:

    • Create a plugin that hooks into the edd_complete_purchase action.
    • Add a negative fee to your purchase (doesn’t matter how you achieve this, you can use Discounts Pro, or programatically, whatever)
    • Complete your purchase.
    • Check the fee’s properties in the EDD_Payment object supplied in the edd_complete_purchase action. You’ll notice that the no_tax property is set to false.
    • Compare that to the output of EDD()->session->get('edd_cart_fees') and you’ll see, there the no_tax property is set to true as per the logic of EDD.

    This is due to the bug I mentioned above. Both method use a different logic to determine whether tax should applied, which shouldn’t happen.

    Plugin Support Mihai Joldis

    (@misulicus)

    Hey @daanvandenbergh,

    Thanks for the detailed report!

    We were able to see this on our end now and we got it logged to be changed so that it’s consistent across the board.

    Thread Starter DaanvandenBergh

    (@daanvandenbergh)

    Great!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘no_tax for fees isn’t fetched properly when creating EDD_Payment object’ is closed to new replies.