7

I am trying to override tax in order review in magento 2 when click on one checkbox. How to do that?

I have one form with checkbox in magento 2 onepage checkout page.

My requirement is when I checked the checkbox the existing tax in the order Summary should be set to zero.

  • I think that you need create a custom module to use your own tax calculation based on a parameter (checkox tick or not). Check core tax calculation. – Franck Garnier Feb 20 '17 at 13:41
2

There are few steps which you need to perform in order to implement such functionality.

  1. Insert checkbox field on the Checkout. There is comprehensive manual how to do that on Official Magento DevDocs.

  2. Create controller which will trigger collectTotals() on quote. But at the same time, you'll have to rewrite \Magento\Tax\Model\Sales\Total\Quote\Tax, function collect(), in order to be able to control if tax should be applied or not.

  3. And at the and, you'll need a little KnockoutJS which will help you to replace / reload Review section on Checkout. You can find a good explanation on this post, which represents comprehensive manual how to work with KnockoutJS on Checkout.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.