Skip to content

Commit 89be76f

Browse files
Release v3.5.0
2 parents af5269c + 6c5b28a commit 89be76f

27 files changed

+997
-36
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
55

6+
## [3.5.0](https://github.com/packlink-dev/ecommerce_module_core/compare/v3.4.11...v3.5.0) - 2025-03-17
7+
**BREAKING CHANGES**
8+
### Added
9+
- Add manual refresh button for updating shipping services
10+
- Add additional data to Shipment
11+
### Changed
12+
- `UpdateShippingServicesTask` - update to fetch special services
13+
614
## [3.4.11](https://github.com/packlink-dev/ecommerce_module_core/compare/v3.4.10...v3.4.11) - 2025-03-10
715
### Changed
816
- Add unsupported countries Morocco, United Arab Emirates and Monaco

src/BusinessLogic/Controllers/DTO/ShippingMethodResponse.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public function toArray()
7777
'parcelDestination' => $this->parcelDestination,
7878
'logoUrl' => $this->logoUrl,
7979
'currency' => $this->currency,
80+
'activated' => $this->activated,
8081
)
8182
);
8283
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace Packlink\BusinessLogic\Controllers\DTO;
4+
5+
use Packlink\BusinessLogic\DTO\FrontDto;
6+
7+
/**
8+
* Class TaskStatus.
9+
*
10+
* @package Packlink\BusinessLogic\Controllers\DTO
11+
*/
12+
class TaskStatus extends FrontDto
13+
{
14+
/**
15+
* Fully qualified name of this class.
16+
*/
17+
const CLASS_NAME = __CLASS__;
18+
19+
/**
20+
* @var string $status
21+
*/
22+
public $status;
23+
24+
/**
25+
* @var string $message
26+
*/
27+
public $message;
28+
29+
/**
30+
* @var string
31+
*/
32+
const SUCCESS = 'success';
33+
34+
/**
35+
* @var string
36+
*/
37+
const ERROR = 'error';
38+
39+
/**
40+
* Fields for this DTO. Needed for validation and transformation from/to array.
41+
*
42+
* @var array
43+
*/
44+
protected static $fields = array(
45+
'status',
46+
'message',
47+
);
48+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?php
2+
3+
namespace Packlink\BusinessLogic\Controllers;
4+
5+
use Logeecom\Infrastructure\ORM\QueryFilter\Operators;
6+
use Logeecom\Infrastructure\ORM\QueryFilter\QueryFilter;
7+
use Logeecom\Infrastructure\ORM\RepositoryRegistry;
8+
use Logeecom\Infrastructure\ServiceRegister;
9+
use Logeecom\Infrastructure\TaskExecution\Exceptions\QueueStorageUnavailableException;
10+
use Logeecom\Infrastructure\TaskExecution\QueueItem;
11+
use Logeecom\Infrastructure\TaskExecution\QueueService;
12+
use Packlink\BusinessLogic\Configuration;
13+
use Packlink\BusinessLogic\Controllers\DTO\TaskStatus;
14+
use Packlink\BusinessLogic\Tasks\UpdateShippingServicesTask;
15+
16+
class ManualRefreshController
17+
{
18+
/**
19+
* Configuration service instance.
20+
*
21+
* @var Configuration
22+
*/
23+
protected $configuration;
24+
25+
/**
26+
* Enqueues the UpdateShippingServicesTask and returns a JSON response.
27+
*
28+
* @return TaskStatus
29+
*/
30+
public function enqueueUpdateTask()
31+
{
32+
$queueService = ServiceRegister::getService(QueueService::CLASS_NAME);
33+
34+
$configService = $this->getConfigService();
35+
36+
try {
37+
$queueService->enqueue(
38+
$configService->getDefaultQueueName(),
39+
new UpdateShippingServicesTask(),
40+
$configService->getContext()
41+
);
42+
43+
$taskStatus = new TaskStatus();
44+
$taskStatus->status = TaskStatus::SUCCESS;
45+
$taskStatus->message = 'Task successfully enqueued.';
46+
return $taskStatus;
47+
48+
} catch (QueueStorageUnavailableException $e) {
49+
$taskStatus = new TaskStatus();
50+
$taskStatus->status = TaskStatus::ERROR;
51+
$taskStatus->message = 'Failed to enqueue task: ' . $e->getMessage();
52+
return $taskStatus;
53+
}
54+
}
55+
56+
/**
57+
* Checks the status of the task responsible for getting services.
58+
*
59+
* @param string $context
60+
*
61+
* @return TaskStatus <p>One of the following statuses:
62+
* QueueItem::FAILED - when the task failed,
63+
* QueueItem::COMPLETED - when the task completed successfully,
64+
* QueueItem::IN_PROGRESS - when the task is in progress,
65+
* QueueItem::QUEUED - when the default warehouse is not set by user and the task was not enqueued.
66+
* </p>
67+
*
68+
* @throws \Logeecom\Infrastructure\ORM\Exceptions\QueryFilterInvalidParamException
69+
* @throws \Logeecom\Infrastructure\ORM\Exceptions\RepositoryClassException
70+
* @throws \Logeecom\Infrastructure\ORM\Exceptions\RepositoryNotRegisteredException
71+
* @throws \Logeecom\Infrastructure\TaskExecution\Exceptions\QueueItemDeserializationException
72+
*/
73+
public function getTaskStatus($context = '')
74+
{
75+
/**@var QueueService $service */
76+
$service = ServiceRegister::getService(QueueService::CLASS_NAME);
77+
78+
$item = $service->findLatestByType('UpdateShippingServicesTask', $context);
79+
80+
$taskStatus = new TaskStatus();
81+
82+
if ($item) {
83+
$status = $item->getStatus();
84+
$taskStatus->status = $status;
85+
86+
if ($status === QueueItem::FAILED) {
87+
$taskStatus->message = $item->getFailureDescription();
88+
}
89+
90+
if ($status === QueueItem::COMPLETED) {
91+
$taskStatus->message = 'Queue item completed';
92+
}
93+
94+
return $taskStatus;
95+
}
96+
97+
$taskStatus->status = QueueItem::CREATED;
98+
$taskStatus->message = 'Queue item not found.';
99+
100+
return $taskStatus;
101+
}
102+
103+
/**
104+
* Returns an instance of configuration service.
105+
*
106+
* @return \Packlink\BusinessLogic\Configuration Configuration service.
107+
*/
108+
protected function getConfigService()
109+
{
110+
if ($this->configuration === null) {
111+
$this->configuration = ServiceRegister::getService(Configuration::CLASS_NAME);
112+
}
113+
114+
return $this->configuration;
115+
}
116+
117+
}

src/BusinessLogic/Http/DTO/Shipment.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Packlink\BusinessLogic\Http\DTO;
44

55
use Logeecom\Infrastructure\Data\DataTransferObject;
6+
use Packlink\BusinessLogic\Http\DTO\Shipment\AdditionalData;
67

78
/**
89
* Class Shipment.
@@ -83,6 +84,10 @@ class Shipment extends DataTransferObject
8384
* @var string
8485
*/
8586
public $currency;
87+
/**
88+
* @var AdditionalData
89+
*/
90+
public $additionalData;
8691

8792
/**
8893
* Transforms DTO to its array format suitable for http client.
@@ -106,6 +111,7 @@ public function toArray()
106111
'tracking_url' => $this->carrierTrackingUrl,
107112
'service_id' => $this->serviceId,
108113
'currency' => $this->currency,
114+
'additional_data' => $this->additionalData->toArray(),
109115
);
110116
}
111117

@@ -141,6 +147,7 @@ public static function fromArray(array $raw)
141147
}
142148

143149
$shipment->carrierTrackingUrl = static::getDataValue($raw, 'tracking_url');
150+
$shipment->additionalData = AdditionalData::fromArray(static::getDataValue($raw, 'additional_data', array()));
144151

145152
return $shipment;
146153
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace Packlink\BusinessLogic\Http\DTO\Shipment;
4+
5+
use Logeecom\Infrastructure\Data\DataTransferObject;
6+
7+
/**
8+
* Class AdditionalData
9+
*
10+
* @package Packlink\BusinessLogic\Http\DTO\Shipment
11+
*/
12+
class AdditionalData extends DataTransferObject
13+
{
14+
/**
15+
* @var string
16+
*/
17+
public $orderId;
18+
19+
/**
20+
* @inheritDoc
21+
*/
22+
public function toArray()
23+
{
24+
return array(
25+
'order_id' => $this->orderId,
26+
);
27+
}
28+
29+
/**
30+
* Transforms raw array data to its DTO.
31+
*
32+
* @param array $raw Raw array data.
33+
*
34+
* @return static Transformed DTO object.
35+
*/
36+
public static function fromArray(array $raw)
37+
{
38+
$additionalData = new static();
39+
40+
$additionalData->orderId = static::getDataValue($raw, 'order_id');
41+
42+
return $additionalData;
43+
}
44+
}

src/BusinessLogic/Http/DTO/ShippingServiceDetails.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ class ShippingServiceDetails extends DataTransferObject
142142
*/
143143
public $availableDates;
144144

145+
/**
146+
* @var array
147+
*/
148+
public $tags = array();
149+
145150
/**
146151
* @inheritdoc
147152
*/
@@ -167,6 +172,7 @@ public function toArray()
167172
),
168173
'service_info' => $this->serviceInfo,
169174
'available_dates' => $this->availableDates,
175+
'tags' => $this->tags,
170176
);
171177
}
172178

@@ -179,7 +185,7 @@ public static function fromArray(array $raw)
179185

180186
$instance->id = self::getDataValue($raw, 'id');
181187
$instance->carrierName = self::getDataValue($raw, 'carrier_name');
182-
$instance->serviceName = self::getDataValue($raw, 'service_name');
188+
$instance->serviceName = self::getDataValue($raw, 'name');
183189
$instance->currency = self::getDataValue($raw, 'currency');
184190
$instance->country = self::getDataValue($raw, 'country');
185191
$instance->departureDropOff = self::getDataValue($raw, 'dropoff', false);
@@ -204,6 +210,7 @@ public static function fromArray(array $raw)
204210
$instance->serviceInfo = self::getDataValue($raw, 'service_info', array());
205211
$instance->availableDates = self::getDataValue($raw, 'available_dates', array());
206212
$instance->national = self::getDataValue($raw, 'national', null);
213+
$instance->tags = self::getDataValue($raw, 'tags', array());
207214

208215
return $instance;
209216
}

src/BusinessLogic/Order/OrderService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ class OrderService extends BaseService
5353
/**
5454
* @var ShopOrderService
5555
*/
56-
private $shopOrderService;
56+
protected $shopOrderService;
5757
/**
5858
* @var OrderShipmentDetailsService
5959
*/
60-
private $orderShipmentDetailsService;
60+
protected $orderShipmentDetailsService;
6161

6262
/**
6363
* OrderService constructor.

src/BusinessLogic/Resources/countries/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,9 @@
488488
"selectCountriesSubheader": "Select availability of at least one country and add <br> as many required",
489489
"discardChangesQuestion": "There are unsaved changes.<br>Are you sure you want to go back and discard them?",
490490
"atLeastOneCountry": "At least one country must be selected.",
491-
"misconfiguration": "Due to store currency change, you must set a Fixed Price value by clicking \"edit\" on the shipping service."
491+
"misconfiguration": "Due to store currency change, you must set a Fixed Price value by clicking \"edit\" on the shipping service.",
492+
"refreshServiceList" : "Refresh service list",
493+
"refreshError": "An error occurred while refreshing the service list"
492494
},
493495
"orderListAndDetails": {
494496
"printed": "Printed",

0 commit comments

Comments
 (0)