i want to add extra fee in multi shipping based on the item
if item is one than add $5
if 2 item than add $10

how can i do that ??

my collect function is like below

public function collect(
    Quote $quote,
    ShippingAssignmentInterface $shippingAssignment,
    Total $total

    parent::collect($quote, $shippingAssignment, $total);

    if (!sizeof($shippingAssignment->getItems())) {
        return $this;

    $total->setTotalAmount('fee', 0);
    $total->setBaseTotalAmount('fee', 0);

        $getShippingAddresses = $quote->getAllShippingAddresses();
        foreach ($getShippingAddresses as $address) {
            $fee = 20;

            $totals = $address->getTotals();
            $address->setTotalAmount('fee', $fee);
            $address->setTotalAmount('fee', $fee);

    return $this;

its not work, not add fee

  • Why are you not using extra fee extension instead ? – Partab Saifuddin Zakir Jan 2 at 14:50
  • is that extra fee extension work with multi shipping checkout? – Jigs Parmar Jan 3 at 8:38
  • Don't know but use this extension and tell me if its works. magecomp.com/magento-2-extra-fee.html – Partab Saifuddin Zakir Jan 3 at 11:08
  • not working with multi shipping checkout – Jigs Parmar Jan 3 at 12:39
  • In your question, you'r writing above code in Tax.php ? – Partab Saifuddin Zakir Jan 3 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.