Skip to content

Commit 9b836df

Browse files
authored
Merge pull request #74 from dpdconnect/1.3.0
1.3.0
2 parents f55297d + 1fe4d4a commit 9b836df

File tree

9 files changed

+243
-237
lines changed

9 files changed

+243
-237
lines changed

Controller/Adminhtml/Order/Shipment/Save.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,16 @@ public function execute()
148148

149149
// Create rows from all packages
150150
$packages = $this->getRequest()->getParam('packages');
151+
$packageId = 1;
151152
$rows = [];
152153
foreach($packages as $package) {
154+
$newPackage[$packageId] = $package;
155+
153156
$row = [
154157
'code' => $package['params']['shipping_product'],
155158
'productType' => $package['params']['product_type'],
156159
'shipmentGeneralData' => $data,
157-
'packageData' => $package,
160+
'packageData' => $newPackage,
158161
];
159162

160163
if (isset($package['params']['expiration_date'])) {
@@ -164,7 +167,7 @@ public function execute()
164167
if (isset($package['params']['goods_description'])) {
165168
$row['description'] = $package['params']['goods_description'];
166169
}
167-
170+
$packageId = $packageId + 1;
168171
$rows[] = $row;
169172
}
170173

Model/CheckoutConfigProvider.php

+1
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ public function getConfig()
144144
$availableShippingProducts[] = [
145145
'code' => $product['code'],
146146
'title' => $title,
147+
'checkoutDescription' => $shippingProductsConfig[$product['code']]['checkoutDescription'],
147148
'price' => $shippingProductsConfig[$product['code']]['price'],
148149
'onlySpecificCountries' => $shippingProductsConfig[$product['code']]['onlySpecificCountries'],
149150
'allowedCountries' => isset($shippingProductsConfig[$product['code']]['allowedCountries']) ? $shippingProductsConfig[$product['code']]['allowedCountries'] : [],

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"description": "DPD Connect - Magento2 Shipping",
44
"require": {
55
"php": ">=7.2",
6-
"dpdconnect/php-sdk": "1.1.8"
6+
"dpdconnect/php-sdk": "1.1.8",
7+
"magento/framework": ">=103.0.6"
78
},
89
"type": "magento2-module",
910
"license": "GPL-3.0-or-later",

composer.lock

+7-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

view/adminhtml/templates/order/packaging/popup.phtml

+12-42
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/**
1010
* @var $block \Magento\Shipping\Block\Adminhtml\Order\Packaging
11+
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
1112
*/
1213
?>
1314
<?php
@@ -61,7 +62,7 @@ $girthEnabled = $block->isDisplayGirthValue() && $block->isGirthAllowed() ? 1 :
6162
weight_units: pack.select('select[name="container_weight_units"]')[0].value,
6263
dimension_units: pack.select('select[name="container_dimension_units"]')[0].value,
6364
shipping_product: pack.select('select[name="shipping_product"]')[0].value,
64-
product_type: pack.select('input[name="product_type"]')[0].value
65+
product_type: 'default'
6566
};
6667

6768
if ('undefined' != typeof pack.select('input[name="expiration_date"]')[0]) {
@@ -247,32 +248,6 @@ $girthEnabled = $block->isDisplayGirthValue() && $block->isGirthAllowed() ? 1 :
247248
});
248249
packItems = packagePrepareGrid.removeClassName('grid_prepare').addClassName('package_items');
249250
packItems.select('.grid tbody tr').each(function (item) {
250-
// Set the package type if not currently set
251-
if ("" === packageBlock.select('input[name="product_type"]')[0].value) {
252-
var productType = jQuery(item).data('product-type');
253-
packageBlock.select('input[name="product_type"]')[0].value = productType;
254-
255-
// Lock the label type if needed and hide fields if needed
256-
switch(productType) {
257-
case 'fresh':
258-
packageBlock.select('select[name="shipping_product"]')[0].value = 'FRESH';
259-
break;
260-
261-
case 'freeze':
262-
packageBlock.select('select[name="shipping_product"]')[0].value = 'FREEZE';
263-
break;
264-
265-
case 'default':
266-
default:
267-
packageBlock.select('.freshfreeze').each(function(item) { item.remove(); });
268-
break;
269-
}
270-
}
271-
// Don't allow different product types in one package
272-
else if (jQuery(item).data('product_type') !== packageBlock.select('input[name="product_type"]')[0].value) {
273-
item.remove();
274-
return;
275-
}
276251

277252
var itemId = item.select('[type="checkbox"]')[0].value;
278253
var qtyValue = parseFloat(item.select('[name="qty"]')[0].value);
@@ -294,11 +269,6 @@ $girthEnabled = $block->isDisplayGirthValue() && $block->isGirthAllowed() ? 1 :
294269
}.bind(packaging));
295270
} else {
296271
packagePrepareGrid.select('.grid tbody tr').each(function (item) {
297-
// Skip the product if the type is not the same as the package product type
298-
if (jQuery(item).data('product-type') !== packageBlock.select('input[name="product_type"]')[0].value) {
299-
item.remove();
300-
return;
301-
}
302272

303273
var itemId = item.select('[type="checkbox"]')[0].value;
304274
var qtyValue = parseFloat(item.select('[name="qty"]')[0].value);
@@ -367,21 +337,21 @@ $girthEnabled = $block->isDisplayGirthValue() && $block->isGirthAllowed() ? 1 :
367337
click: function () {
368338
packaging.cancelPackaging();
369339
this.closeModal();
370-
}
371-
}, {
340+
}
341+
}, {
372342
text: '<?php echo $block->escapeJs(__('Save')) ?>',
373343
'attr': {'disabled':'disabled', 'data-action':'save-packages'},
374344
'class': 'action-primary _disabled',
375345
click: function () {
376346
packaging.confirmPackaging();
377-
}
378-
}, {
379-
text: '<?php echo $block->escapeJs(__('Add Package')) ?>',
380-
'attr': {'data-action':'add-packages'},
381-
'class': 'action-secondary',
382-
click: function () {
383-
packaging.newPackage();
384-
}
347+
}
348+
}, {
349+
text: '<?php echo $block->escapeJs(__('Add Package')) ?>',
350+
'attr': {'data-action':'add-packages'},
351+
'class': 'action-secondary',
352+
click: function () {
353+
packaging.newPackage();
354+
}
385355
}]
386356
});
387357
jQuery(document).trigger('packaging:inited');

0 commit comments

Comments
 (0)