Question

I have followed below link to add a custom fee to order.

How to add fee to order totals in Magento 2

Custom fee is added perfectly and showing in admin order summary without any issue.

Now I Have a different store view for China and I have ordered from it, custom fee is adding and showing in admin but its base rate is not showing or added in order totals, is there something which I forgot to add.

enter image description here

Was it helpful?

Solution

I was adding extra fee using the below method.

$fee = new DataObject(
    [
        'code' => 'my_code',
        'strong' => true,
        'value' => 100,
        'label' => __('Import Duty')
    ]
);
$parent->addTotal($fee, 'doyenhub_codcharges');

I need to pass one more parameter base_value to $fee Dataobject as below

$fee = new DataObject(
    [
        'code' => 'my_code',
        'strong' => true,
        'value' => 100,
        'base_value' => 10,
        'label' => __('Import Duty')
    ]
);
$parent->addTotal($fee, 'doyenhub_codcharges');
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top