1

Is it possible to change the tax value based on the tax class of a product when it is added to the cart? To put this clear, I do not want to change the class itself or the percentage it's calculated against, but simply the value itself.

We have products on the site that are second hand items, and tax is worked out on the profit margin instead of the price alone. Therefore the tax is based on the price the customer pays minus the cost price. For example, If we have an item that's £1000, and the cost is £700, then the tax is calculated against £1000 - £700 = £300, and as the tax in the UK is 20%, this will come to £50. Therefore a generic tax class would not solve this issue as the tax percentage would be different each time. I could use Fixed Product Taxes instead, however it doesn't take into account automated Special Prices, and the admin users would have to enter all of these values against each product (there's 3000+ products, so this will be infeasible).

I have tried to create a plugin that listens to Magento\Checkout\Model\Cart, created an event that observes sales_quote_collect_totals_before, and abstracted Magento\Tax\Model\Sales\Total\Quote\Tax to eventually override updateItemTaxInfo - the final approach did save the required values into the quote_item table in the database, but upon traversing through the checkout, the cart seems to recalculate the tax again, and does not use the value saved in the table.

Any help would be highly grateful, thank you!

  • hi @Smithee, found any solution? I am also facing same issue – jafar pinjar May 15 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.