Skip to content

Commit

Permalink
#37374 send weight for return label creation
Browse files Browse the repository at this point in the history
  • Loading branch information
mbe1987 committed Dec 5, 2024
1 parent 8e303ba commit 0b0cda3
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/modules/mo/mo_dhl/Adapter/RetoureRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public function build(Order $order)
->setReceiverId($this->buildReceiverId($order->getFieldData('oxbillcountryid')))
->setSenderAddress($this->buildSenderAddress($order))
->setEmail($order->getFieldData('oxbillemail'))
->setTelephoneNumber($order->moDHLGetAddressData('fon'));
->setTelephoneNumber($order->moDHLGetAddressData('fon'))
->setWeightInGrams(array_sum(array_map([$this, 'getWeightInGrams'], $order->getOrderArticles()->getArray())));
$country = $this->buildCountry($order->getFieldData('oxbillcountryid'));

if (!in_array($country->getCountryISOCode(), Country::EU_COUNTRIES_LIST)) {
Expand Down Expand Up @@ -112,11 +113,21 @@ protected function buildPositions(Order $order)
$positions[] = (new CustomsDocumentPosition())
->setPositionDescription(substr($orderArticle->getArticle()->getFieldData('oxtitle'), 0, 50))
->setCount($count)
->setWeightInGrams($orderArticle->getFieldData('oxweight') * 1000.0 * $count)
->setWeightInGrams($this->getWeightInGrams($orderArticle))
->setValues($orderArticle->getPrice()->getPrice() * $count)
->setArticleReference($orderArticle->getArticle()->getId());
}

return $positions;
}

/**
* @param OrderArticle $orderArticle
* @return float
*/
public function getWeightInGrams(OrderArticle $orderArticle): float
{
var_dump($orderArticle);
return $orderArticle->getFieldData('oxweight') * 1000.0 * $orderArticle->getFieldData('oxamount');
}
}

0 comments on commit 0b0cda3

Please sign in to comment.