0

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.

http://www.blogtreat.com/programmatically-create-new-order-in-magento-2%EF%BB%BF/

2

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;

$order->setSubtotal($subTotal);
$order->setBaseSubtotal($subTotal);
$order->setGrandTotal($totalAmount);
$order->setBaseGrandTotal($totalAmount);
$order->setTaxAmount($taxAmount);
$order->setDiscountAmount(0);

If you found answer useful please accept it.

  • I tried this code but the discount code value did not into order. – Kushal Dani 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 Dani 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 at 12:09

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.