magento 2 checkout extra fee adding twice to grand total collect function calling 4 to 5 times
parent::collect($quote, $shippingAssignment, $total);
if (!count($shippingAssignment->getItems())) {
return $this;
}
+
$address = $shippingAssignment->getShipping()->getAddress();
if($address->getAddressType() != 'billing'){
return $this;
}
// My code
return $this;
(or)
$address = $shippingAssignment->getShipping()->getAddress();
if($address->getAddressType() == 'billing'){
// My code
return $this;
}
Reference: https://stackoverflow.com/a/42141291/8237294