diff --git a/Block/Sales/NewShipmentForm.php b/Block/Sales/NewShipmentForm.php index fb620722..fe542f5a 100644 --- a/Block/Sales/NewShipmentForm.php +++ b/Block/Sales/NewShipmentForm.php @@ -6,6 +6,7 @@ use MyParcelNL\Sdk\src\Model\Carrier\CarrierDHLEuroplus; use MyParcelNL\Sdk\src\Model\Carrier\CarrierDHLForYou; use MyParcelNL\Sdk\src\Model\Carrier\CarrierDHLParcelConnect; +use MyParcelNL\Sdk\src\Model\Carrier\CarrierDPD; use MyParcelNL\Sdk\src\Model\Carrier\CarrierFactory; use MyParcelNL\Sdk\src\Model\Carrier\CarrierPostNL; use MyParcelNL\Sdk\src\Model\Carrier\CarrierUPS; @@ -19,6 +20,7 @@ class NewShipmentForm CarrierDHLEuroplus::class, CarrierDHLParcelConnect::class, CarrierUPS::class, + CarrierDPD::class, ]; public const PACKAGE_TYPE_HUMAN_MAP = [ diff --git a/Block/Sales/View.php b/Block/Sales/View.php index 53715050..7b5b896f 100755 --- a/Block/Sales/View.php +++ b/Block/Sales/View.php @@ -18,6 +18,7 @@ namespace MyParcelNL\Magento\Block\Sales; +use DateTime; use Magento\Framework\App\ObjectManager; use Magento\Sales\Block\Adminhtml\Order\AbstractOrder; use MyParcelNL\Magento\Helper\Checkout as CheckoutHelper; @@ -50,6 +51,7 @@ public function _construct() * * @return string * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Exception */ public function getCheckoutOptionsHtml() { @@ -59,10 +61,11 @@ public function getCheckoutOptionsHtml() /** @var object $data Data from checkout */ $data = $order->getData(CheckoutHelper::FIELD_DELIVERY_OPTIONS) !== null ? json_decode($order->getData(CheckoutHelper::FIELD_DELIVERY_OPTIONS), true) : false; + $date = new DateTime($data['date'] ?? ''); + $dateTime = $date->format('d-m-Y H:i'); + if ($this->helper->isPickupLocation($data)) { if (is_array($data) && key_exists('pickupLocation', $data)) { - $dateTime = date('d-m-Y H:i', strtotime($data['date'])); - $html .= __($data['carrier'] . ' location:') . ' ' . $dateTime; if ($data['deliveryType'] != 'pickup') { $html .= ', ' . __($data['deliveryType']); @@ -78,7 +81,6 @@ public function getCheckoutOptionsHtml() $html .= __($data['packageType'] . ' '); } - $dateTime = date('d-m-Y H:i', strtotime($data['date'] ?? '')); $html .= __('Deliver:') . ' ' . $dateTime; if (key_exists('shipmentOptions', $data)) { diff --git a/CHANGELOG.md b/CHANGELOG.md index bc1a9c8b..a1c6ac0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [4.11.1](https://github.com/myparcelnl/magento/compare/v4.11.0...v4.11.1) (2023-11-23) + + +### :bug: Bug Fixes + +* **checkout:** show delivery options for tablerate when appropriate ([#790](https://github.com/myparcelnl/magento/issues/790)) ([8e29ac1](https://github.com/myparcelnl/magento/commit/8e29ac167466ba12b6b6d35da66127c5f1d94038)) +* **ordernotes:** bail early without order ([#788](https://github.com/myparcelnl/magento/issues/788)) ([37bacb5](https://github.com/myparcelnl/magento/commit/37bacb59f58ab2f9ee96b40113028f6ed2af2dea)), closes [#772](https://github.com/myparcelnl/magento/issues/772) + ## [4.11.0](https://github.com/myparcelnl/magento/compare/v4.10.0...v4.11.0) (2023-11-10) diff --git a/Helper/Data.php b/Helper/Data.php index d539b78e..95f21f6c 100755 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -12,6 +12,7 @@ use MyParcelNL\Sdk\src\Model\Carrier\CarrierDHLEuroplus; use MyParcelNL\Sdk\src\Model\Carrier\CarrierDHLForYou; use MyParcelNL\Sdk\src\Model\Carrier\CarrierDHLParcelConnect; +use MyParcelNL\Sdk\src\Model\Carrier\CarrierDPD; use MyParcelNL\Sdk\src\Model\Carrier\CarrierPostNL; use MyParcelNL\Sdk\src\Model\Carrier\CarrierUPS; use MyParcelNL\Sdk\src\Model\Consignment\AbstractConsignment; @@ -27,6 +28,7 @@ class Data extends AbstractHelper public const XML_PATH_DHLEUROPLUS_SETTINGS = 'myparcelnl_magento_dhleuroplus_settings/'; public const XML_PATH_DHLPARCELCONNECT_SETTINGS = 'myparcelnl_magento_dhlparcelconnect_settings/'; public const XML_PATH_UPS_SETTINGS = 'myparcelnl_magento_ups_settings/'; + public const XML_PATH_DPD_SETTINGS = 'myparcelnl_magento_dpd_settings/'; public const DEFAULT_WEIGHT = 1000; public const CARRIERS_XML_PATH_MAP = [ CarrierPostNL::NAME => self::XML_PATH_POSTNL_SETTINGS, @@ -34,6 +36,7 @@ class Data extends AbstractHelper CarrierDHLEuroplus::NAME => self::XML_PATH_DHLEUROPLUS_SETTINGS, CarrierDHLParcelConnect::NAME => self::XML_PATH_DHLPARCELCONNECT_SETTINGS, CarrierUPS::NAME => self::XML_PATH_UPS_SETTINGS, + CarrierDPD::NAME => self::XML_PATH_DPD_SETTINGS, ]; /** diff --git a/Model/Sales/Package.php b/Model/Sales/Package.php index f7badd3f..8e4e22a3 100755 --- a/Model/Sales/Package.php +++ b/Model/Sales/Package.php @@ -245,6 +245,10 @@ public function getCurrentCountry(): string */ public function setCurrentCountry(?string $currentCountry): void { + if ($currentCountry === null) { + return; + } + $this->currentCountry = $currentCountry; } } diff --git a/Observer/SalesOrderStatusHistoryObserver.php b/Observer/SalesOrderStatusHistoryObserver.php index 0ffeda9c..d879e961 100644 --- a/Observer/SalesOrderStatusHistoryObserver.php +++ b/Observer/SalesOrderStatusHistoryObserver.php @@ -41,7 +41,9 @@ public function execute(Observer $observer): self $history = $observer->getData()['status_history'] ?? null; if (! is_a($history, History::class) - || ! $history->getComment()) { + || ! $history->getComment() + || ! $history->getOrder() + ) { return $this; } diff --git a/composer.json b/composer.json index be83c927..0eead232 100755 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "myparcelnl/magento", - "version": "4.11.0", + "version": "4.11.1", "description": "A Magento 2 module that creates MyParcel labels", "keywords": [ "myparcel", diff --git a/etc/module.xml b/etc/module.xml index 435c2cef..17b90eca 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,5 +1,5 @@ - + diff --git a/i18n/en_US.csv b/i18n/en_US.csv index 6b63c82e..8ae980a6 100755 --- a/i18n/en_US.csv +++ b/i18n/en_US.csv @@ -45,6 +45,7 @@ myparcelnl_magento_dhlforyou_settings/delivery/only_recipient/signature, DHL For myparcelnl_magento_dhleuroplus_settings/delivery, DHL Europlus delivery myparcelnl_magento_dhlparcelconnect_settings/delivery, DHL Parcel Connect delivery myparcelnl_magento_ups_settings/delivery, UPS delivery +myparcelnl_magento_dpd_settings/delivery, DPD delivery myparcelnl_magento_error_no_shipments_to_process, No MyParcel shipments to process. no_account_settings, No account settings found. Press the import button in general configuration to fetch account settings. manage_drop_off_point, Manage your default drop-off point in the diff --git a/i18n/nl_NL.csv b/i18n/nl_NL.csv index 3a925a29..b747a2ba 100755 --- a/i18n/nl_NL.csv +++ b/i18n/nl_NL.csv @@ -37,6 +37,7 @@ myparcelnl_magento_dhlforyou_settings/delivery/only_recipient/signature, DHL For myparcelnl_magento_dhleuroplus_settings/delivery, DHL Europlus bezorging myparcelnl_magento_dhlparcelconnect_settings/delivery, DHL Parcel Connect bezorging myparcelnl_magento_ups_settings.delivery, UPS bezorging +myparcenl_magento_dpd_settings/delivery, DPD bezorging myparcelnl_magento_error_no_shipments_to_process, Geen MyParcel zendingen om te verwerken. Version and support,Versie en support General settings,Algemene instellingen diff --git a/package.json b/package.json index 511a1218..4da1b985 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@myparcel/magento", - "version": "4.11.0", + "version": "4.11.1", "private": true, "description": "Voor de handleiding en meer informatie ga naar: https://myparcelnl.github.io/magento/", "homepage": "https://myparcelnl.github.io/magento", diff --git a/view/frontend/web/js/model/checkout.js b/view/frontend/web/js/model/checkout.js index 3a2d743e..3adb8c5c 100644 --- a/view/frontend/web/js/model/checkout.js +++ b/view/frontend/web/js/model/checkout.js @@ -148,7 +148,22 @@ function( */ findRateByMethodCode: function(methodCode) { return Model.rates().find(function(rate) { - return rate.method_code === methodCode; + return rate.carrier_code === methodCode || rate.method_code === methodCode; + }); + }, + + /** + * Search the rates for the given method code. + * + * @param {string} carrierCode - Carrier code to search for. + * + * @returns {Object} - The found rate, if any. + */ + findOriginalRateByCarrierCode: function(carrierCode) { + return Model.rates().find(function(rate) { + if (-1 === rate.method_code.indexOf('myparcel')) { + return rate.carrier_code === carrierCode; + } }); }, @@ -185,8 +200,14 @@ function( if ('undefined' !== typeof MyParcelConfig && MyParcelConfig.hasOwnProperty('methods')) { MyParcelConfig.methods.forEach(function(code) { + const method = Model.findOriginalRateByCarrierCode(code); + + if (! method) { + return; + } + try { - document.getElementById('label_method_' + code + '_' + code).remove(); + document.getElementById('label_method_' + method.method_code + '_' + method.carrier_code).parentNode.remove(); } catch (e) { // when the element is not there as such, it is already ok } @@ -197,7 +218,6 @@ function( row.style.display = 'none'; }); }, - /** * Get shipping method rows by finding the columns with a matching method_code and grabbing their parent. * diff --git a/view/frontend/web/js/view/delivery-options.js b/view/frontend/web/js/view/delivery-options.js index e491f4a4..17f4524c 100644 --- a/view/frontend/web/js/view/delivery-options.js +++ b/view/frontend/web/js/view/delivery-options.js @@ -88,6 +88,8 @@ define( 'myparcelnl_magento_dhleuroplus_settings/delivery': 'config.carrierSettings.dhleuroplus.priceStandardDelivery', 'myparcelnl_magento_dhlparcelconnect_settings/delivery': 'config.carrierSettings.dhlparcelconnect.priceStandardDelivery', 'myparcelnl_magento_ups_settings/delivery': 'config.carrierSettings.ups.priceStandardDelivery', + 'myparcelnl_magento_dpd_settings/delivery': 'config.carrierSettings.dpd.priceStandardDelivery', + 'myparcelnl_magento_dpd_settings/pickup': 'config.carrierSettings.dpd.pricePickup', }, /**