Skip to content

Commit

Permalink
fix Fee.php
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbinaBaraliu committed Aug 21, 2024
1 parent 634cdaa commit 5829a6d
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions Block/Totals/Fee.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,27 @@ public function getTitle(): string
public function getTotal(): float
{
$totalData = $this->getSegment();
$extensionAttributes = $totalData['extension_attributes'] ?? null;
if (false === is_array($totalData)) {
throw new \UnexpectedValueException('Expecting an array but getting '.gettype($totalData));
}

$extensionAttributes = $totalData['extension_attributes'];

if (
$extensionAttributes
is_array($extensionAttributes) &&
isset($extensionAttributes['buckaroo_fee']) &&
is_scalar($extensionAttributes['buckaroo_fee'])
) {
return (floatval($extensionAttributes->getBuckarooFee()['buckaroo_fee'][0]));
return floatval($extensionAttributes['buckaroo_fee']);
}

if ($extensionAttributes instanceof \Magento\Quote\Api\Data\TotalSegmentExtension) {
/** @var \Magento\Quote\Api\Data\TotalSegmentExtension $extensionAttributes */
if ($extensionAttributes->getBuckarooFee() !== null) {
return $extensionAttributes->getBuckarooFee();
}
}

return 0;
}
}

0 comments on commit 5829a6d

Please sign in to comment.