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.



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. – Kushal Jul 19 '18 at 11:32
  • have you tried to "$order->setDiscountAmount(0);" change amount in this code? – P_U Jul 20 '18 at 9:39
  • yes, I tried your code and it is working. thanks – Kushal Jul 20 '18 at 10:12
  • @P_U, how to add tax amount for quote item? here is my question regarding it, magento.stackexchange.com/questions/274520/… – jafar pinjar May 15 '19 at 12:09
  • You saved my day, I can confirm it is working correctly in Magento 2.4.1. Thanks man – Ramkishan Suthar Mar 2 at 5:57

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.