Skip to content

Commit

Permalink
Merge branch 'develop' into feat/add-carrier-ups
Browse files Browse the repository at this point in the history
  • Loading branch information
wthijmen authored Dec 4, 2023
2 parents 4da35ee + e86d3fe commit fef35de
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Block/Sales/NewShipmentForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,6 +20,7 @@ class NewShipmentForm
CarrierDHLEuroplus::class,
CarrierDHLParcelConnect::class,
CarrierUPS::class,
CarrierDPD::class,
];

public const PACKAGE_TYPE_HUMAN_MAP = [
Expand Down
8 changes: 5 additions & 3 deletions Block/Sales/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,6 +51,7 @@ public function _construct()
*
* @return string
* @throws \Magento\Framework\Exception\LocalizedException
* @throws \Exception
*/
public function getCheckoutOptionsHtml()
{
Expand All @@ -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']);
Expand All @@ -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)) {
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
3 changes: 3 additions & 0 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,13 +28,15 @@ 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,
CarrierDHLForYou::NAME => self::XML_PATH_DHLFORYOU_SETTINGS,
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,
];

/**
Expand Down
4 changes: 4 additions & 0 deletions Model/Sales/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ public function getCurrentCountry(): string
*/
public function setCurrentCountry(?string $currentCountry): void
{
if ($currentCountry === null) {
return;
}

$this->currentCountry = $currentCountry;
}
}
4 changes: 3 additions & 1 deletion Observer/SalesOrderStatusHistoryObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd" >
<module name="MyParcelNL_Magento" setup_version="4.11.0">
<module name="MyParcelNL_Magento" setup_version="4.11.1">
<sequence>
<module name="Magento_Sales"/>
</sequence>
Expand Down
1 change: 1 addition & 0 deletions i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions i18n/nl_NL.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
26 changes: 23 additions & 3 deletions view/frontend/web/js/model/checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});
},

Expand Down Expand Up @@ -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
}
Expand All @@ -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.
*
Expand Down
2 changes: 2 additions & 0 deletions view/frontend/web/js/view/delivery-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},

/**
Expand Down

0 comments on commit fef35de

Please sign in to comment.