27
27
use Magento\Framework\App\Helper\Context;
28
28
use Magento\Sales\Api\Data\OrderAddressInterface;
29
29
use Magento\Sales\Model\Order;
30
+ use Magento\Store\Model\ScopeInterface;
30
31
31
32
class OrderConvertService extends AbstractHelper
32
33
{
@@ -89,7 +90,7 @@ private function getProductCode(Order $order, ?Order\Shipment $shipment = null,
89
90
}
90
91
91
92
// Fetch the code from the shipment, if any, else default to the order code
92
- if ($shipment && $shipment->hasData(Constants::SHIPMENT_EXTRA_DATA)) {
93
+ if ($shipment && !empty( $shipment->hasData(Constants::SHIPMENT_EXTRA_DATA)['code'] )) {
93
94
return $shipment->getData(Constants::SHIPMENT_EXTRA_DATA)['code'];
94
95
}
95
96
@@ -164,7 +165,7 @@ public function addParcels(Order $order, ?Order\Shipment $shipment = null, bool
164
165
$parcel = [
165
166
'customerReferences' => [
166
167
$order->getIncrementId() ?? '',
167
- ($this->dpdSettings->isSetFlag(DpdSettings::ADVANCED_PRINT_ORDER_ID) ? $order->getEntityId() : ''),
168
+ ($this->dpdSettings->isSetFlag(DpdSettings::ADVANCED_PRINT_ORDER_ID, ScopeInterface::SCOPE_STORE, $order->getStoreId() ) ? $order->getEntityId() : ''),
168
169
$order->getDpdParcelshopId() ?? '',
169
170
$shipment->getEntityId() ?? '',
170
171
],
@@ -208,7 +209,7 @@ public function addParcelsFromPackages(Order $order, ?Order\Shipment $shipment =
208
209
$parcel = [
209
210
'customerReferences' => [
210
211
$order->getIncrementId() ?? '',
211
- ($this->dpdSettings->isSetFlag(DpdSettings::ADVANCED_PRINT_ORDER_ID) ? $order->getIncrementId() : ''),
212
+ ($this->dpdSettings->isSetFlag(DpdSettings::ADVANCED_PRINT_ORDER_ID, ScopeInterface::SCOPE_STORE, $order->getStoreId() ) ? $order->getIncrementId() : ''),
212
213
$order->getDpdParcelshopId() ?? '',
213
214
$shipment->getEntityId(),
214
215
],
@@ -242,20 +243,20 @@ public function convert(Order $order, ?Order\Shipment $orderShipment = null, boo
242
243
243
244
$shipment = [
244
245
'orderId' => $order->getIncrementId(),
245
- 'sendingDepot' => $this->dpdSettings->getValue(DpdSettings::ACCOUNT_DEPOT),
246
+ 'sendingDepot' => $this->dpdSettings->getValue(DpdSettings::ACCOUNT_DEPOT, ScopeInterface::SCOPE_STORE, $order->getStoreId() ),
246
247
'sender' => [
247
- 'name1' => $this->dpdSettings->getValue(DpdSettings::SHIPPING_ORIGIN_NAME1),
248
- 'street' => $this->dpdSettings->getValue(DpdSettings::SHIPPING_ORIGIN_STREET),
249
- 'housenumber' => $this->dpdSettings->getValue(DpdSettings::SHIPPING_ORIGIN_HOUSE_NUMBER),
250
- 'country' => $this->dpdSettings->getValue(DpdSettings::SHIPPING_ORIGIN_COUNTRY),
251
- 'postalcode' => $this->dpdSettings->getValue(DpdSettings::SHIPPING_ORIGIN_ZIP_CODE),
252
- 'city' => $this->dpdSettings->getValue(DpdSettings::SHIPPING_ORIGIN_CITY),
253
- 'phoneNumber' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_PHONE),
254
- 'email' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_EMAIL),
248
+ 'name1' => $this->dpdSettings->getValue(DpdSettings::SHIPPING_ORIGIN_NAME1, ScopeInterface::SCOPE_STORE, $order->getStoreId() ),
249
+ 'street' => $this->dpdSettings->getValue(DpdSettings::SHIPPING_ORIGIN_STREET, ScopeInterface::SCOPE_STORE, $order->getStoreId() ),
250
+ 'housenumber' => $this->dpdSettings->getValue(DpdSettings::SHIPPING_ORIGIN_HOUSE_NUMBER, ScopeInterface::SCOPE_STORE, $order->getStoreId() ),
251
+ 'country' => $this->dpdSettings->getValue(DpdSettings::SHIPPING_ORIGIN_COUNTRY, ScopeInterface::SCOPE_STORE, $order->getStoreId() ),
252
+ 'postalcode' => $this->dpdSettings->getValue(DpdSettings::SHIPPING_ORIGIN_ZIP_CODE, ScopeInterface::SCOPE_STORE, $order->getStoreId() ),
253
+ 'city' => $this->dpdSettings->getValue(DpdSettings::SHIPPING_ORIGIN_CITY, ScopeInterface::SCOPE_STORE, $order->getStoreId() ),
254
+ 'phoneNumber' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_PHONE, ScopeInterface::SCOPE_STORE, $order->getStoreId() ),
255
+ 'email' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_EMAIL, ScopeInterface::SCOPE_STORE, $order->getStoreId() ),
255
256
'commercialAddress' => true,
256
- 'vatnumber' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_VAT_NUMBER),
257
- 'eorinumber' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_EORI),
258
- 'sprn' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_SPRN),
257
+ 'vatnumber' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_VAT_NUMBER, ScopeInterface::SCOPE_STORE, $order->getStoreId() ),
258
+ 'eorinumber' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_EORI, ScopeInterface::SCOPE_STORE, $order->getStoreId() ),
259
+ 'sprn' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_SPRN, ScopeInterface::SCOPE_STORE, $order->getStoreId() ),
259
260
],
260
261
'receiver' => $this->getReceiverData($order),
261
262
'product' => [
@@ -272,16 +273,16 @@ public function convert(Order $order, ?Order\Shipment $orderShipment = null, boo
272
273
'totalAmount' => (float) $order->getBaseGrandTotal(),
273
274
'customsLines' => $this->addCustomsLines($order),
274
275
'consignor' => [
275
- 'name1' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_NAME),
276
- 'street' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_STREET),
277
- 'housenumber' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_HOUSE_NUMBER),
278
- 'postalcode' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_ZIP_CODE),
279
- 'city' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_CITY),
280
- 'country' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_COUNTRY),
276
+ 'name1' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_NAME, ScopeInterface::SCOPE_STORE, $order->getStoreId() ),
277
+ 'street' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_STREET, ScopeInterface::SCOPE_STORE, $order->getStoreId() ),
278
+ 'housenumber' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_HOUSE_NUMBER, ScopeInterface::SCOPE_STORE, $order->getStoreId() ),
279
+ 'postalcode' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_ZIP_CODE, ScopeInterface::SCOPE_STORE, $order->getStoreId() ),
280
+ 'city' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_CITY, ScopeInterface::SCOPE_STORE, $order->getStoreId() ),
281
+ 'country' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_COUNTRY, ScopeInterface::SCOPE_STORE, $order->getStoreId() ),
281
282
'commercialAddress' => true,
282
- 'vatnumber' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_VAT_NUMBER),
283
- 'eorinumber' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_EORI),
284
- 'sprn' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_SPRN),
283
+ 'vatnumber' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_VAT_NUMBER, ScopeInterface::SCOPE_STORE, $order->getStoreId() ),
284
+ 'eorinumber' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_EORI, ScopeInterface::SCOPE_STORE, $order->getStoreId() ),
285
+ 'sprn' => $this->dpdSettings->getValue(DpdSettings::STORE_INFORMATION_SPRN, ScopeInterface::SCOPE_STORE, $order->getStoreId() ),
285
286
],
286
287
'consignee' => $this->getReceiverData($order)
287
288
];
@@ -331,7 +332,7 @@ private function addCustomsLines(Order $order)
331
332
foreach ($order->getItems() as $item) {
332
333
/** @var \Magento\Catalog\Model\Product $product */
333
334
$product = $item->getProduct();
334
- $originCountry = $this->dpdSettings->getValue(DpdSettings::SHIPPING_ORIGIN_COUNTRY);
335
+ $originCountry = $this->dpdSettings->getValue(DpdSettings::SHIPPING_ORIGIN_COUNTRY, ScopeInterface::SCOPE_STORE, $order->getStoreId() );
335
336
$hsCode = '';
336
337
337
338
if ($product !== null) {
0 commit comments