Support » Plugin: WooCommerce » How to handle negative fees in cart?

  • Resolved tastenmeister

    (@tastenmeister)


    Hello guys,

    I’m investigating in a project where a disount is calulated, if a custom field fulfils a certain condition (in this case a certain date).

    I used a negative fee (in this case -50%) to add here. But then the total sum
    and the tax is calulated wrong.

    I think there was a discussion on github concerning negative fees. But it’s old and i wonder if there is anything new here in this topic.

    You can test on the site. Chose a product and select in the date picker a 15th of a month. Now in cart will be a desposit added and as well a discount (-50%). But the sums a little bit wired here.

    Note: The problem occurs only when you pick a 15th of a month! On 1st of a month everyting is fine (because no negative fee is added).

    Thanks in advance for your help!

    Best Regards!
    Tastenmeister

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Hannah S.

    (@fernashes)

    Automattic Happiness Engineer

    Can you tell us a bit more about how you’re using those negative fees and how you’ve implemented them? There may be a better way to handle it that doesn’t cause trouble with other calculations.

    Thanks!

    Hey Hannah,

    thanks for your answer. Sorry for providing so little information. The problem is that I use an additional plugin for handling custom fields, but the dev of that plugin is a bit overwhemled with the fe calculation. That’s the reason why I’m asking here. Maybe there is a better way to solve the problem.

    The goal is to add automatically a negative fee (=discount) if a shop item fulfills a date condition. The user is able to pick a date from a custom field (renting date in my case) for every item. Depending on the selected day (if date is 15th of a month) the additional fee/discount of -50% should be applied. In best case it is applied to each item separately. It’s important for me that the original price is shown in cart next to the items, so I want the discount to show in the subtotals section below.

    I use WC Fields Factory to handle the date field and I can set the conditions there.

    I stay in contact with the dev of WC Fields Factory, but he isn’t able to fix the calculation of the fees. It seems, that WC is adding tax to the fee, so that the sum is not -50% but a little bit more. The dev managed to trick out this additional tax so the fee is now shown right (exact -50%) but now the total is too low (missing some cents), so there seems to miss something.

    My question is: how is Woocommerce handling the calculation of totals, so that I can add fees (negative and positive, taxable and non-taxable) which are dependend from custom fields.

    You can reproduce the problem if you to the following:

    visit https://staging.tastenexpress.de/produkt/roland-fp-30/ and choose a date with contains 15th of a month (if you like you can choose any other instrument from the menu).
    Put it in cart and see the subtotals section below. First line is subtotal (incl. 19% tax), second line is a deposit (a non-taxable fee) from WC Fields factory. Third line is discount for half month (negative and taxable so that tax is as well reduced).
    As you can see the total (incl. VAT) is below not correct (and so the VAT below too).

    I would be very thankful if you could investigate in that topic and help me to finish that problem.

    I can give you WP credentials if you like, so that you can have a look inside.

    Best Regards, Riccardo

    Plugin Support Con Schneider

    (@conschneider)

    Automattic Happiness Engineer

    Hi Riccardo,

    Using credentials to check out sites is not possible via this free forum. Please refrain from sharing any sensitive informations such as passwords here.

    Piecing together your discount function will take some advanced customisation work which is beyond of the scope of this forum, I am afraid. I’d suggest engaging a developer to help you with this as we’re not able to help with code customizations that magnitude.
    You can for example contact one of the services on our customizations page: https://woocommerce.com/customizations/

    Kind regards,

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to handle negative fees in cart?’ is closed to new replies.