46 lines
1.4 KiB
PHP
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';
|
|
}
|
|
}
|