Files
kupshop/bundles/KupShop/BalikonosBundle/BalikobotAdapters/BalikobotUPSAdapter.php
2025-08-02 16:30:27 +02:00

46 lines
1.4 KiB
PHP

<?php
namespace KupShop\BalikonosBundle\BalikobotAdapters;
class BalikobotUPSAdapter implements IBalikobotAdapter
{
public function transformOrderData(\Order $order, array $data, array &$custom_data): array
{
$contentData = [];
foreach ($order->fetchItems() as $item) {
if (!empty($item['product'])) {
/** @var \Product $product */
$product = $item['product'];
$tmpItem = [
'content_name_en' => $item['descr'],
'content_weight' => $product->weight,
'content_pieces' => $item['pieces'],
'content_price' => $item['piece_price']['value_with_vat']->asFloat(),
'content_currency' => $order->getCurrency(),
'content_country' => 'CZ',
];
if (!empty($item['ean'])) {
$tmpItem['content_ean'] = $item['ean'];
}
$contentData[] = $tmpItem;
$data['content'] = $this->getItemsContentDescription();
}
}
$data['ins_currency'] = $order->getCurrency();
$data['content_data'] = $contentData;
if (!empty($order->delivery_state)) {
$data['rec_region'] = $order->delivery_state;
}
return $data;
}
public function getItemsContentDescription(): string
{
return 'Product';
}
}