Skip to content

Commit

Permalink
v1.0.43
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisvanderhammen-devnl committed Aug 29, 2023
1 parent 5f27814 commit 436819f
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Block/Adminhtml/System/SameDayFieldCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(
public function getElementHtml()
{
$message = __('No shipping days have been set, for sameday to function this field is required');
$shippingDays = explode(',', $this->helper->getConfigData('delivery_times/shipping_days'));
$shippingDays = explode(',', $this->helper->getConfigData('delivery_times/shipping_days') ?? '');
if (is_array($shippingDays) && count($shippingDays) > 0) {
$message = '<span class="dhlparcel-sameday-check valid-shipping-days">' . $message . '</span>';
} else {
Expand Down
2 changes: 1 addition & 1 deletion Controller/Adminhtml/Shipment/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function execute()

protected function setDefaultSize(&$sizes)
{
$ignoredSizes = explode(',', $this->helper->getConfigData('label/ignored_sizes'));
$ignoredSizes = explode(',', $this->helper->getConfigData('label/ignored_sizes') ?? '');
foreach ($sizes as &$size) {
if (!in_array($size['key'], $ignoredSizes)) {
$size['selected'] = true;
Expand Down
2 changes: 1 addition & 1 deletion Model/Carrier.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ public function getTrackingUrl($trackerCode)
$postalCode = $piece->getPostalCode();
$search = ['{{trackerCode}}', '{{postalCode}}', '{{locale}}'];
$replace = [$trackerCode, $postalCode, $locale];
return str_replace($search, $replace, $trackingUrl);
return str_replace($search, $replace, $trackingUrl ?? '');
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Model/ResourceModel/Carrier/Rate/CSV/ColumnResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(array $headers, array $columns = [])
/**
* @param string $column
* @param array $values
* @return string|int|float|null
* @return string|int|float
* @throws ColumnNotFoundException
*/
public function getColumnValue($column, array $values)
Expand All @@ -61,6 +61,6 @@ public function getColumnValue($column, array $values)
throw new ColumnNotFoundException(__('Value for column "%1" not found', $column));
}

return trim($values[$columnIndex]);
return trim($values[$columnIndex] ?? '');
}
}
2 changes: 1 addition & 1 deletion Model/Service/DeliveryServices.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ protected function sanitizeData($array)
if (is_array($array) && count($array) > 0) {
foreach ($array as $item) {
if (in_array($item, $this->availableOptions)) {
$sanitized[] = strtoupper($item);
$sanitized[] = strtoupper($item ?? '');
}
}
}
Expand Down
13 changes: 9 additions & 4 deletions Model/Service/DeliveryTimes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use DHLParcel\Shipping\Helper\Data;
use DHLParcel\Shipping\Model\Api\Connector;
use DHLParcel\Shipping\Model\Data\DeliveryTime;
use DHLParcel\Shipping\Model\Data\DeliveryTimeFactory;
use DHLParcel\Shipping\Model\Data\Api\Response\TimeWindowFactory;
use DHLParcel\Shipping\Model\Data\TimeSelectionFactory;
Expand Down Expand Up @@ -198,6 +199,7 @@ public function filterTimeFrames($deliveryTimes, $dayTime = true)
$timezoneString = $this->timezone->getConfigTimezone();
$timezone = new \DateTimeZone($timezoneString);

/** @var DeliveryTime $deliveryTime */
foreach ($deliveryTimes as $deliveryTime) {
$datetime = date_create_from_format('d-m-Y Hi', $deliveryTime->source->deliveryDate . ' ' . $deliveryTime->source->startTime, $timezone);
$timestamp = $datetime->getTimestamp();
Expand Down Expand Up @@ -245,7 +247,7 @@ public function showSameday()

/** @var \DateTime $currentDateTime */
$currentDateTime = $this->timezone->date();
$shippingDays = explode(',', $this->helper->getConfigData('delivery_times/shipping_days'));
$shippingDays = explode(',', $this->helper->getConfigData('delivery_times/shipping_days') ?? '');

if (!in_array($currentDateTime->format('w'), $shippingDays)) {
return false;
Expand Down Expand Up @@ -280,7 +282,7 @@ public function showSamedayAfterCutoff()
/** @var \DateTime $tomorrowDateTime */
$tomorrowDateTime = $this->timezone->date();
$tomorrowDateTime->modify('+1 day');
$shippingDays = explode(',', $this->helper->getConfigData('delivery_times/shipping_days'));
$shippingDays = explode(',', $this->helper->getConfigData('delivery_times/shipping_days') ?? '');

if (!in_array($tomorrowDateTime->format('w'), $shippingDays)) {
return false;
Expand Down Expand Up @@ -511,7 +513,7 @@ protected function getCutoffTimestamp()
protected function getShippingDays()
{
$shippingDaysSetting = $this->helper->getConfigData('delivery_times/shipping_days');
$shippingDaysArray = array_map('trim', explode(',', $shippingDaysSetting));
$shippingDaysArray = array_map('trim', explode(',', $shippingDaysSetting ?? ''));

$weekdays = $this->weekdays->toOptionArray();

Expand Down Expand Up @@ -545,6 +547,7 @@ protected function validateWithShippingDays($minimumTimestamp, $timestamp, $ship
}

$currentDateTime = $this->timezone->date();
$currentDateTime->setTime(0, 0);
$timestampTodayCheck = $currentDateTime->getTimestamp() - 1;
$timestampDifference = $timestamp - $timestampTodayCheck;
if ($timestampDifference < 0) {
Expand All @@ -561,7 +564,9 @@ protected function validateWithShippingDays($minimumTimestamp, $timestamp, $ship
}

$additionalDays = 0;
for ($dayCheck = 0; $dayCheck < $daysBetween; $dayCheck++) {
// If the day before the delivery day is sunday, add 1 extra day
// TODO Note, See previous note about hardcoded check for Sundays
for ($dayCheck = $dateBeforeCode === 7 ? 0 : 1; $dayCheck < $daysBetween; $dayCheck++) {
$currentDateTime = $this->timezone->date();
$theDay = intval($currentDateTime->modify('+' . $dayCheck . ' day')->format('N'));
if ($shippingDays[$theDay] !== true) {
Expand Down
4 changes: 2 additions & 2 deletions Model/Service/Preset.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function getDefaultOptions($order, $requiredOnly = false)
if ($this->helper->getConfigData('label/default_extra_assured', $order->getStoreId()) == ServiceOptionDefault::OPTION_SKIP_NOT_AVAILABLE
|| $this->helper->getConfigData('label/default_extra_assured', $order->getStoreId()) == ServiceOptionDefault::OPTION_IF_AVAILABLE
&& !$requiredOnly) {
$minimumOrderAmount = str_replace(',', '.', $this->helper->getConfigData('label/default_extra_assured_min'));
$minimumOrderAmount = str_replace(',', '.', $this->helper->getConfigData('label/default_extra_assured_min') ?? '0');
if (!is_numeric($minimumOrderAmount) || $order->getSubtotal() >= floatval($minimumOrderAmount)) {
$options['EA'] = '';
}
Expand All @@ -98,7 +98,7 @@ public function getDefaultOptions($order, $requiredOnly = false)
}

if (is_numeric($insuranceValue)) {
$minimumOrderAmount = str_replace(',', '.', $this->helper->getConfigData('label/default_shipment_insurance_min'));
$minimumOrderAmount = str_replace(',', '.', $this->helper->getConfigData('label/default_shipment_insurance_min') ?? '0');
if (!is_numeric($minimumOrderAmount) || $order->getSubtotal() >= floatval($minimumOrderAmount)) {
$options['INS'] = $insuranceValue;
}
Expand Down
2 changes: 1 addition & 1 deletion Observer/Shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ protected function shouldSkipSize($key, $sizes)
return false;
}

$ignoredSizes = explode(',', $this->helper->getConfigData('label/ignored_sizes'));
$ignoredSizes = explode(',', $this->helper->getConfigData('label/ignored_sizes') ?? '');

// Passing this statement would mean there wouldn't be any size left, in this unlikely case we skip the checks
if (empty(array_diff_key($sizes, array_flip($ignoredSizes)))) {
Expand Down
2 changes: 1 addition & 1 deletion Ui/Column/Labels.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected function getLabelLinks($shipment)
$serviceOptions = [];
$serviceCounter = 0;
if ($piece->getServiceOptions() !== null) {
foreach (explode(',', $piece->getServiceOptions()) as $serviceOption) {
foreach (explode(',', $piece->getServiceOptions() ?? '') as $serviceOption) {
if ($this->presetService->getTranslation($serviceOption) !== null) {
$serviceOptions[] = sprintf('<span data-key="%s" class="dhlparcel-shipping-service-option-chip">%s</span>', strtoupper($serviceOption), $this->presetService->getTranslation($serviceOption)) . (++$serviceCounter % 4 ? '' : '<br/>');
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dhlparcel/magento2-plugin",
"description": "DHL Parcel plugin for Magento 2",
"type": "magento2-module",
"version": "1.0.42",
"version": "1.0.43",
"license": [
"OSL-3.0"
],
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="DHLParcel_Shipping" setup_version="1.0.42">
<module name="DHLParcel_Shipping" setup_version="1.0.43">
<sequence>
<module name="Magento_Shipping"/>
<module name="Magento_Checkout"/>
Expand Down

0 comments on commit 436819f

Please sign in to comment.