Skip to content

Commit f275ed2

Browse files
authored
Merge pull request #4 from dpdconnect/fixes/202003
Fixed issue with settings not being remembered, phone number issue, a…
2 parents 1cf8e5e + c5a780d commit f275ed2

File tree

4 files changed

+40
-38
lines changed

4 files changed

+40
-38
lines changed

classes/DpdHelper.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -62,29 +62,29 @@ public function displayConfigurationForm($module, $formAccountSettings, $formAdr
6262
$helperForm->submit_action = 'submit'.$module->name;
6363

6464
// Load current value
65-
$helperForm->fields_value['dpdconnect_username'] = Configuration::get('dpdconnect_connect_username');
66-
$helperForm->fields_value['dpdconnect_password'] = Configuration::get('dpdconnect_connect_password');
67-
$helperForm->fields_value['dpdconnect_depot'] = Configuration::get('dpdconnect_depot');
68-
$helperForm->fields_value['company'] = Configuration::get('dpdconnect_company');
69-
$helperForm->fields_value['account_type'] = Configuration::get('dpdconnect_account_type');
70-
$helperForm->fields_value['street'] = Configuration::get('dpdconnect_street');
71-
$helperForm->fields_value['postalcode'] = Configuration::get('dpdconnect_postalcode');
72-
$helperForm->fields_value['place'] = Configuration::get('dpdconnect_place');
73-
$helperForm->fields_value['country'] = Configuration::get('dpdconnect_country');
74-
$helperForm->fields_value['email'] = Configuration::get('dpdconnect_email');
75-
$helperForm->fields_value['vatnumber'] = Configuration::get('dpdconnect_vatnumber');
76-
$helperForm->fields_value['eorinumber'] = Configuration::get('dpdconnect_eorinumber');
77-
$helperForm->fields_value['spr'] = Configuration::get('dpdconnect_spr');
78-
$helperForm->fields_value['gmaps_client_key'] = Configuration::get('gmaps_client_key');
79-
$helperForm->fields_value['gmaps_server_key'] = Configuration::get('gmaps_server_key');
80-
$helperForm->fields_value['default_product_hcs'] = Configuration::get('dpdconnect_default_product_hcs');
81-
$helperForm->fields_value['default_product_weight'] = Configuration::get('dpdconnect_default_product_weight');
82-
$helperForm->fields_value['default_product_country_of_origin'] = Configuration::get('dpdconnect_default_product_country_of_origin');
83-
$helperForm->fields_value['country_of_origin_feature'] = Configuration::get('dpdconnect_country_of_origin_feature');
84-
$helperForm->fields_value['customs_value_feature'] = Configuration::get('dpdconnect_customs_value_feature');
85-
$helperForm->fields_value['hs_code_feature'] = Configuration::get('dpdconnect_hs_code_feature');
86-
$helperForm->fields_value['hs_code_feature'] = Configuration::get('dpdconnect_hs_code_feature');
87-
$helperForm->fields_value['dpdconnect_url'] = Configuration::get('dpdconnect_connect_url');
65+
$helperForm->fields_value['dpdconnect_username'] = Configuration::get('dpdconnect_connect_username') ?: Tools::getValue('dpdconnect_username');
66+
$helperForm->fields_value['dpdconnect_password'] = Configuration::get('dpdconnect_connect_password') ?: Tools::getValue('dpdconnect_password');
67+
$helperForm->fields_value['dpdconnect_depot'] = Configuration::get('dpdconnect_depot') ?: Tools::getValue('dpdconnect_depot');
68+
$helperForm->fields_value['company'] = Configuration::get('dpdconnect_company') ?: Tools::getValue('company');
69+
$helperForm->fields_value['account_type'] = Configuration::get('dpdconnect_account_type') ?: Tools::getValue('account_type');
70+
$helperForm->fields_value['street'] = Configuration::get('dpdconnect_street') ?: Tools::getValue('street');
71+
$helperForm->fields_value['postalcode'] = Configuration::get('dpdconnect_postalcode') ?: Tools::getValue('postalcode');
72+
$helperForm->fields_value['place'] = Configuration::get('dpdconnect_place') ?: Tools::getValue('place');
73+
$helperForm->fields_value['country'] = Configuration::get('dpdconnect_country') ?: Tools::getValue('country');
74+
$helperForm->fields_value['email'] = Configuration::get('dpdconnect_email') ?: Tools::getValue('email');
75+
$helperForm->fields_value['vatnumber'] = Configuration::get('dpdconnect_vatnumber') ?: Tools::getValue('vatnumber');
76+
$helperForm->fields_value['eorinumber'] = Configuration::get('dpdconnect_eorinumber') ?: Tools::getValue('eorinumber');
77+
$helperForm->fields_value['spr'] = Configuration::get('dpdconnect_spr') ?: Tools::getValue('spr');
78+
$helperForm->fields_value['gmaps_client_key'] = Configuration::get('gmaps_client_key') ?: Tools::getValue('gmaps_client_key');
79+
$helperForm->fields_value['gmaps_server_key'] = Configuration::get('gmaps_server_key') ?: Tools::getValue('gmaps_server_key');
80+
$helperForm->fields_value['default_product_hcs'] = Configuration::get('dpdconnect_default_product_hcs') ?: Tools::getValue('default_product_hcs');
81+
$helperForm->fields_value['default_product_weight'] = Configuration::get('dpdconnect_default_product_weight') ?: Tools::getValue('default_product_weight');
82+
$helperForm->fields_value['default_product_country_of_origin'] = Configuration::get('dpdconnect_default_product_country_of_origin') ?: Tools::getValue('default_product_country_of_origin');
83+
$helperForm->fields_value['country_of_origin_feature'] = Configuration::get('dpdconnect_country_of_origin_feature') ?: Tools::getValue('country_of_origin_feature');
84+
$helperForm->fields_value['customs_value_feature'] = Configuration::get('dpdconnect_customs_value_feature') ?: Tools::getValue('customs_value_feature');
85+
$helperForm->fields_value['hs_code_feature'] = Configuration::get('dpdconnect_hs_code_feature') ?: Tools::getValue('hs_code_feature');
86+
$helperForm->fields_value['hs_code_feature'] = Configuration::get('dpdconnect_hs_code_feature') ?: Tools::getValue('hs_code_feature');
87+
$helperForm->fields_value['dpdconnect_url'] = Configuration::get('dpdconnect_connect_url') ?: Tools::getValue('dpdconnect_url');
8888

8989
return $helperForm->generateForm($fields_form);
9090
}

classes/DpdLabelGenerator.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function generateLabel($orderIds, $parcelCount, $return)
125125
if (count($orderIds) > 1) {
126126
return $this->redirectToZipDownload($labelsForDirectDownload);
127127
}
128-
128+
129129
return $this->redirectToPdfDownload($labelsForDirectDownload[0]);
130130
}
131131

@@ -219,20 +219,20 @@ public function generateShipmentInfo($orderId, $parcelCount, $return)
219219
'sender' => [
220220
'name1' => Configuration::get('dpdconnect_company'),
221221
'street' => Configuration::get('dpdconnect_street'),
222-
'country' => Configuration::get('dpdconnect_country'),
222+
'country' => strtoupper(Configuration::get('dpdconnect_country')),
223223
'postalcode' => Configuration::get('dpdconnect_postalcode'),
224224
'city' => Configuration::get('dpdconnect_place'),
225-
'phone' => Configuration::get('PS_SHOP_PHONE'),
225+
'phoneNumber' => Configuration::get('PS_SHOP_PHONE'),
226226
'email' => Configuration::get('dpdconnect_email'),
227227
'commercialAddress' => true,
228228
],
229229
'receiver' => [
230230
'name1' => $fullName,
231231
'street' => $street,
232-
'country' => $country->iso_code,
232+
'country' => strtoupper($country->iso_code),
233233
'postalcode' => $address->postcode, // No spaces in zipCode!
234234
'city' => $address->city,
235-
'phone' => $phone,
235+
'phoneNumber' => $phone,
236236
'commercialAddress' => false,
237237
'vat_number' => Configuration::get('dpdconnect_vatnumber'),
238238
'eori_number' => Configuration::get('dpdconnect_eorinumber'),
@@ -297,8 +297,9 @@ public function generateShipmentInfo($orderId, $parcelCount, $return)
297297
}
298298
$amount = $customsValue * $row['product_quantity'];
299299
$totalAmount += $amount;
300+
300301
$customsLines[] = [
301-
'description' => substr($row['product_name'], 0, 35),
302+
'description' => mb_strcut($row['product_name'], 0, 35),
302303
'harmonizedSystemCode' => $hsCode ? $hsCode : "",
303304
'originCountry' => $originCountry ? $originCountry : "",
304305
'quantity' => (int) $row['product_quantity'],
@@ -315,7 +316,7 @@ public function generateShipmentInfo($orderId, $parcelCount, $return)
315316
'street' => Configuration::get('dpdconnect_street'),
316317
'postalcode' => Configuration::get('dpdconnect_postalcode'),
317318
'city' => Configuration::get('dpdconnect_place'),
318-
'country' => Configuration::get('dpdconnect_country'),
319+
'country' => strtoupper(Configuration::get('dpdconnect_country')),
319320
'commercialAddress' => true,
320321
];
321322

@@ -324,9 +325,9 @@ public function generateShipmentInfo($orderId, $parcelCount, $return)
324325
'street' => $street,
325326
'postalcode' => $address->postcode,
326327
'city' => $address->city,
327-
'country' => $country->iso_code,
328+
'country' => strtoupper($country->iso_code),
328329
'commercialAddress' => false,
329-
'sprn' => Configuration::get('dpdconnect_spr'),
330+
'sprn' => Configuration::get('dpdconnect_spr') ?: '',
330331
];
331332

332333
$shipment['customs']['customsLines'] = $customsLines;

classes/OrderResponseTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ class OrderResponseTransformer
1414
*/
1515
public static function parseDetail($map, $detail)
1616
{
17-
$stringPath = 'body.shipments[';
17+
$stringPath = 'shipments[';
1818
return self::parse($map, $detail, $stringPath);
1919
}
2020

2121
public static function parseAsyncDetail($map, $detail)
2222
{
23-
$stringPath = 'body.label.shipments[';
23+
$stringPath = 'label.shipments[';
2424
return self::parse($map, $detail, $stringPath);
2525
}
2626

dpdconnect.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public function install()
7070
if (parent::install()) {
7171
Configuration::updateValue('dpd', 'dpdconnect');
7272
Configuration::updateValue('dpdconnect_parcel_limit', 12);
73+
Configuration::updateValue('dpdconnect_connect_url', \DpdConnect\Sdk\Client::ENDPOINT);
7374
}
7475

7576
// Install Tabs
@@ -276,13 +277,13 @@ public function getContent()
276277
'type' => 'text',
277278
'label' => $this->l('Google Maps Static & Javascript API key'),
278279
'name' => 'gmaps_client_key',
279-
'required' => true
280+
'required' => false
280281
],
281282
[
282283
'type' => 'text',
283284
'label' => $this->l('Google Maps Geocoding API key'),
284285
'name' => 'gmaps_server_key',
285-
'required' => true
286+
'required' => false
286287
],
287288
],
288289
];
@@ -420,13 +421,13 @@ public function getContent()
420421
'legend' => [
421422
'title' => $this->l('Advanced settings'),
422423
],
423-
'description' => 'Settings below can be left empty, they are used for development and debugging purposes.',
424+
'description' => 'Settings below can be used for development and debugging purposes.',
424425
'input' => [
425426
[
426427
'type' => 'text',
427428
'label' => $this->l('DPD-Connect url'),
428429
'name' => 'dpdconnect_url',
429-
'required' => false
430+
'required' => true
430431
],
431432
],
432433
];

0 commit comments

Comments
 (0)