1

Setup

I have

  1. Crated different Customer Tax Classes (Retail/Company)
  2. Created different Tax Rates (21%/0%) and applied them with Tax Rule
  3. In Store Config enabled Enable Automatic Assignment to Customer Group and selected correct Customer Tax Classes based on Billing Address and Validate on each transaction

The problem

In the store front everything works as expected. The prices during checkout are calculated with different Tax Rates based on the billing address with and without VAT ID.

BUT the Order is saved with the Retail tax values, even though the Company tax group is saved properly.

So both the admin Sales -> Orders and API show that order correctly with the Company customer tax group, but the tax rates are applied from the Retail class.

0

Fixed this by modifing app/code/Magento/Quote/Model/QuoteManagement.php by adding 3 lines after the first one in the following method:

 public function placeOrder($cartId, PaymentInterface $paymentMethod = null){
    $quote = $this->quoteRepository->getActive($cartId);

    $quote->setTotalsCollectedFlag(false); // add this lines
    $quote->collectTotals(); // add this lines
    $quote->save(); // add this lines

This forces Magento to recollect prices according to the billing address before saving it to the database.

| improve this answer | |

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.