Skip to content

Commit

Permalink
fix(fulfilment): add order notes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Ernst committed Jul 12, 2023
1 parent 8d48824 commit e14fa32
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Pdk/Order/Repository/PsPdkOrderRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Address;
use Country;
use Customer;
use CustomerMessage;
use MyParcelNL\Pdk\App\Order\Collection\PdkOrderCollection;
use MyParcelNL\Pdk\App\Order\Contract\PdkProductRepositoryInterface;
use MyParcelNL\Pdk\App\Order\Model\PdkOrder;
Expand All @@ -15,6 +16,7 @@
use MyParcelNL\Pdk\Base\Contract\WeightServiceInterface;
use MyParcelNL\Pdk\Facade\Logger;
use MyParcelNL\Pdk\Facade\Platform;
use MyParcelNL\Pdk\Fulfilment\Collection\OrderNoteCollection;
use MyParcelNL\Pdk\Shipment\Model\CustomsDeclaration;
use MyParcelNL\Pdk\Shipment\Model\CustomsDeclarationItem;
use MyParcelNL\Pdk\Shipment\Model\Shipment;
Expand All @@ -25,6 +27,7 @@
use MyParcelNL\PrestaShop\Repository\PsOrderDataRepository;
use MyParcelNL\PrestaShop\Repository\PsOrderShipmentRepository;
use Order;
use OrderMessage;
use State;

class PsPdkOrderRepository extends AbstractPdkOrderRepository
Expand Down Expand Up @@ -134,6 +137,30 @@ public function get($input): PdkOrder
});
}

public function getOrderNotes(?string $externalIdentifier): OrderNoteCollection
{
$orderNoteCollection = new OrderNoteCollection();
$customerNotes = CustomerMessage::getMessagesByOrderId($externalIdentifier);

foreach ($customerNotes as $customerNote) {
$orderNoteCollection->push([
'note' => $customerNote['message'],
'author' => 'customer',
]);
}

$webshopNotes = OrderMessage::getOrderMessages($externalIdentifier);

foreach ($webshopNotes as $webshopNote) {
$orderNoteCollection->push([
'note' => $webshopNote['message'],
'author' => 'webshop',
]);
}

return $orderNoteCollection;
}

/**
* @param \MyParcelNL\Pdk\App\Order\Model\PdkOrder $order
*
Expand Down

0 comments on commit e14fa32

Please sign in to comment.