8
  • I want to add a tax on custom fee. tax calculation is perfect and gets tax amount but it's not set in TAX files in quote_address in the database.

    public function collect(
        \Magento\Quote\Model\Quote $quote,
        \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment,
        \Magento\Quote\Model\Quote\Address\Total $total
    ){
    
      $total->setTaxAmount($total->getTaxAmount()+$taxAmount);
      $total->setBaseTaxAmount($total->getBaseTaxAmount()+$taxAmount); 
    }
    
  • I try to set tax Amount in collect method but it's not set.

  • I want to same like this thiscode. it's Magento1 but I want Magento 2

0

Instead of a call to $total->setTaxAmount() you need to use addTotalAmount:

$total->addTotalAmount('tax', $amount);
$total->addBaseTotalAmount('tax', $baseAmount);

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.