I used below link to place an order, but in that, I cannot get any solution. how to add the tax or discount in order so anyone has done this thing?

please help to solve this issue.


1 Answer 1


Here I have share code to apply tax in your custom code:

$subTotal = 121;
$taxRate = .0825;
$taxAmount = $subTotal * $taxRate;
$shippingAmount = 15;
$totalAmount =  $subTotal + $taxAmount + $shippingAmount;


If you found answer useful please accept it.

  • I tried this code but the discount code value did not into order. Commented Jul 19, 2018 at 11:32
  • have you tried to "$order->setDiscountAmount(0);" change amount in this code?
    – P_U
    Commented Jul 20, 2018 at 9:39
  • yes, I tried your code and it is working. thanks Commented Jul 20, 2018 at 10:12
  • @P_U, how to add tax amount for quote item? here is my question regarding it, magento.stackexchange.com/questions/274520/… Commented May 15, 2019 at 12:09
  • You saved my day, I can confirm it is working correctly in Magento 2.4.1. Thanks man Commented Mar 2, 2021 at 5:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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