In Magento 1, you could retrieve amounts from the Fooman Surcharge extension using
|
1 |
$order->getFoomanSurchargeAmount(); |
. This no longer works in Magento 2. Instead, Magento 2 provides extension attributes. The following code retrieves surcharges from different Fooman extensions for further processing:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
$extAttr = $order->getExtensionAttributes(); if (!$extAttr) { return; } $foomanGroup = $extAttr->getFoomanTotalGroup(); if (empty($foomanGroup)) { return; } $totals = $foomanGroup->getItems(); if (empty($totals)) { return; } foreach ($totals as $total) { $description = $total->getLabel(); $baseAmount = $total->getBaseAmount(); $baseTaxAmount = $total->getBaseTaxAmount(); $amount = $total->getAmount(); $taxAmount = $total->getTaxAmount(); $identifier = $total->getTypeId(); $qty = 1; /** Process the surcharges ... */ } |
Viel Erfolg :-)!
Reading Fooman Surcharge data from an order
Need help implementing this solution, or still looking for a fix to your Magento problem? Get in touch and I will be happy to help with your project.