Skip to content

Commit 368cebf

Browse files
Merge pull request #110 from Paazl/release/1.17.0
Release/1.17.0
2 parents c7d41d1 + 039c662 commit 368cebf

File tree

9 files changed

+79
-13
lines changed

9 files changed

+79
-13
lines changed

Model/Api/Builder/Order.php

+20-7
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ public function parseAddress(Address $shippingAddress)
185185
$street = $shippingAddress->getStreet();
186186
if ($this->config->housenumberExtensionOnThirdStreet()) {
187187
return [
188-
'street' => trim($street[0] ?? null),
189-
'houseNumber' => trim(isset($street[1]) ? $street[1] : null),
190-
'houseNumberExtension' => trim(isset($street[2]) ? $street[2] : null),
188+
'street' => trim($street[0] ?? ''),
189+
'houseNumber' => trim($street[1] ?? ''),
190+
'houseNumberExtension' => trim($street[2] ?? ''),
191191
];
192192
}
193193
$street = implode(' ', $street);
@@ -403,26 +403,39 @@ private function getProductDimemension(Item $item)
403403
}
404404

405405
if ($widthAttribute = $this->config->getProductAttributeWidth()) {
406-
if ($width = $product->getData($widthAttribute) * $k) {
406+
if ($width = $this->reformatVolumeData($product->getData($widthAttribute)) * $k) {
407407
$dimensionArray['width'] = (int)$width;
408408
}
409409
}
410410

411411
if ($heightAttribute = $this->config->getProductAttributeHeight()) {
412-
if ($height = $product->getData($heightAttribute) * $k) {
412+
if ($height = $this->reformatVolumeData($product->getData($heightAttribute)) * $k) {
413413
$dimensionArray['height'] = (int)$height;
414414
}
415415
}
416416

417-
if ($lengthAttribute = $this->config->getProductAttributeLength() * $k) {
418-
if ($length = $product->getData($lengthAttribute)) {
417+
if ($lengthAttribute = $this->config->getProductAttributeLength()) {
418+
if ($length = $this->reformatVolumeData($product->getData($lengthAttribute)) * $k) {
419419
$dimensionArray['length'] = (int)$length;
420420
}
421421
}
422422

423423
return $dimensionArray;
424424
}
425425

426+
/**
427+
* @param $value
428+
* @return float
429+
*/
430+
private function reformatVolumeData($value): float
431+
{
432+
if ($value == null) {
433+
return 0.00;
434+
}
435+
436+
return (float)str_replace(',', '.', $value);
437+
}
438+
426439
/**
427440
* Check if parent item is bundle
428441
*

Model/Api/Converter/Checkout/ToShippingInfo.php

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public function convert($response)
7373
$info->setIdenfifier($this->arrayManager->get('shippingOption/identifier', $result));
7474
$info->setPrice(floatval($this->arrayManager->get('shippingOption/rate', $result)));
7575
$info->setOptionTitle($this->arrayManager->get('shippingOption/name', $result));
76+
$info->setCarrierDescription($this->arrayManager->get('shippingOption/carrier/description', $result));
7677

7778
if (!$prefferedDeliveryDate = $this->arrayManager->get('preferredDeliveryDate', $result)) {
7879
$prefferedDeliveryDate = $this->arrayManager->get('shippingOption/deliveryDates/0/deliveryDate', $result);

Model/Checkout/WidgetConfigProvider.php

+18-3
Original file line numberDiff line numberDiff line change
@@ -570,12 +570,27 @@ private function calculateVolumeByDimensions($product): float
570570
default:
571571
$k = 0.000001;
572572
}
573+
573574
$widthAttribute = $this->scopeConfig->getProductAttributeWidth();
574575
$heightAttribute = $this->scopeConfig->getProductAttributeHeight();
575576
$lengthAttribute = $this->scopeConfig->getProductAttributeLength();
576-
return (float)str_replace(',', '.', $product->getData($widthAttribute)) *
577-
(float)str_replace(',', '.', $product->getData($heightAttribute)) *
578-
(float)str_replace(',', '.', $product->getData($lengthAttribute)) *
577+
578+
return $this->reformatVolumeData($product->getData($widthAttribute)) *
579+
$this->reformatVolumeData($product->getData($heightAttribute)) *
580+
$this->reformatVolumeData($product->getData($lengthAttribute)) *
579581
$k;
580582
}
583+
584+
/**
585+
* @param $value
586+
* @return float
587+
*/
588+
private function reformatVolumeData($value): float
589+
{
590+
if ($value == null) {
591+
return 0.00;
592+
}
593+
594+
return (float)str_replace(',', '.', $value);
595+
}
581596
}

Model/ShippingInfo.php

+18
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class ShippingInfo extends DataObject
3333
public const PREFERRED_DELIVERY_DATE = 'preferred_delivery_date';
3434
public const ESTIMATED_DELIVERY_RANGE = 'estimated_delivery_range';
3535
public const CARRIER_PICKUP_DATE = 'carrier_pickup_date';
36+
public const CARRIER_DESCRIPTION = 'carrier_description';
3637
/**#@- */
3738

3839
/**
@@ -274,4 +275,21 @@ public function getCarrierPickupDate()
274275
{
275276
return $this->getData(self::CARRIER_PICKUP_DATE);
276277
}
278+
279+
/**
280+
* @param string $value
281+
* @return $this
282+
*/
283+
public function setCarrierDescription($value)
284+
{
285+
return $this->setData(self::CARRIER_DESCRIPTION, $value);
286+
}
287+
288+
/**
289+
* @return string|null
290+
*/
291+
public function getCarrierDescription()
292+
{
293+
return $this->getData(self::CARRIER_DESCRIPTION);
294+
}
277295
}

Plugin/Checkout/ShippingInformationManagementPlugin.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ public function beforeSaveAddressInformation(
136136
->setStreet($this->arrayManager->get('street', $pickupLocationAddress))
137137
->setCity($this->arrayManager->get('city', $pickupLocationAddress))
138138
->setCountryId($this->arrayManager->get('country', $pickupLocationAddress))
139-
->setCompany($this->arrayManager->get('name', $pickupLocation));
139+
->setCompany($this->arrayManager->get('name', $pickupLocation))
140+
->setSaveInAddressBook(0);
140141

141142
// ... also set to quote shipping address if exists
142143
if (($quoteShippingAddress = $quote->getShippingAddress())

ViewModel/Pickup/Info.php

+12
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,16 @@ public function getLocationCode()
224224
return '';
225225
}
226226
}
227+
228+
/**
229+
* @return string
230+
*/
231+
public function getCarrierDescription()
232+
{
233+
try {
234+
return (string)$this->getOrderInfo()->getCarrierDescription();
235+
} catch (NoSuchEntityException $e) {
236+
return '';
237+
}
238+
}
227239
}

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "paazl/magento2-checkout-widget",
33
"description": "Paazl checkoutWidget for Magento 2",
44
"type": "magento2-module",
5-
"version": "1.16.1",
5+
"version": "1.17.0",
66
"keywords": [
77
"Paazl",
88
"Magento 2",

etc/config.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<default>
99
<carriers>
1010
<paazlshipping>
11-
<version>v1.16.1</version>
11+
<version>v1.17.0</version>
1212
<active>0</active>
1313
<sallowspecific>0</sallowspecific>
1414
<price>0</price>

view/adminhtml/templates/order/view/pickup/info.phtml

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ $viewModel = $block->getData('pickupViewModel');
2323
<?= $block->escapeHtml($viewModel->getLocationCode())?>
2424
</div>
2525
<?php endif; ?>
26+
<?php if ($description = $viewModel->getCarrierDescription()): ?>
27+
<div class="store-code-wrapper">
28+
<strong><?= /* @noEscape */ __('Carrier Description') ?>:</strong><br/>
29+
<?= $block->escapeHtml($description)?>
30+
</div>
31+
<?php endif; ?>
2632
</div>
2733
<?php endif;?>
2834

0 commit comments

Comments
 (0)