Skip to content

Commit

Permalink
Merge pull request #110 from Paazl/release/1.17.0
Browse files Browse the repository at this point in the history
Release/1.17.0
  • Loading branch information
Marvin-Magmodules authored Jun 20, 2024
2 parents c7d41d1 + 039c662 commit 368cebf
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 13 deletions.
27 changes: 20 additions & 7 deletions Model/Api/Builder/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ public function parseAddress(Address $shippingAddress)
$street = $shippingAddress->getStreet();
if ($this->config->housenumberExtensionOnThirdStreet()) {
return [
'street' => trim($street[0] ?? null),
'houseNumber' => trim(isset($street[1]) ? $street[1] : null),
'houseNumberExtension' => trim(isset($street[2]) ? $street[2] : null),
'street' => trim($street[0] ?? ''),
'houseNumber' => trim($street[1] ?? ''),
'houseNumberExtension' => trim($street[2] ?? ''),
];
}
$street = implode(' ', $street);
Expand Down Expand Up @@ -403,26 +403,39 @@ private function getProductDimemension(Item $item)
}

if ($widthAttribute = $this->config->getProductAttributeWidth()) {
if ($width = $product->getData($widthAttribute) * $k) {
if ($width = $this->reformatVolumeData($product->getData($widthAttribute)) * $k) {
$dimensionArray['width'] = (int)$width;
}
}

if ($heightAttribute = $this->config->getProductAttributeHeight()) {
if ($height = $product->getData($heightAttribute) * $k) {
if ($height = $this->reformatVolumeData($product->getData($heightAttribute)) * $k) {
$dimensionArray['height'] = (int)$height;
}
}

if ($lengthAttribute = $this->config->getProductAttributeLength() * $k) {
if ($length = $product->getData($lengthAttribute)) {
if ($lengthAttribute = $this->config->getProductAttributeLength()) {
if ($length = $this->reformatVolumeData($product->getData($lengthAttribute)) * $k) {
$dimensionArray['length'] = (int)$length;
}
}

return $dimensionArray;
}

/**
* @param $value
* @return float
*/
private function reformatVolumeData($value): float
{
if ($value == null) {
return 0.00;
}

return (float)str_replace(',', '.', $value);
}

/**
* Check if parent item is bundle
*
Expand Down
1 change: 1 addition & 0 deletions Model/Api/Converter/Checkout/ToShippingInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public function convert($response)
$info->setIdenfifier($this->arrayManager->get('shippingOption/identifier', $result));
$info->setPrice(floatval($this->arrayManager->get('shippingOption/rate', $result)));
$info->setOptionTitle($this->arrayManager->get('shippingOption/name', $result));
$info->setCarrierDescription($this->arrayManager->get('shippingOption/carrier/description', $result));

if (!$prefferedDeliveryDate = $this->arrayManager->get('preferredDeliveryDate', $result)) {
$prefferedDeliveryDate = $this->arrayManager->get('shippingOption/deliveryDates/0/deliveryDate', $result);
Expand Down
21 changes: 18 additions & 3 deletions Model/Checkout/WidgetConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,12 +570,27 @@ private function calculateVolumeByDimensions($product): float
default:
$k = 0.000001;
}

$widthAttribute = $this->scopeConfig->getProductAttributeWidth();
$heightAttribute = $this->scopeConfig->getProductAttributeHeight();
$lengthAttribute = $this->scopeConfig->getProductAttributeLength();
return (float)str_replace(',', '.', $product->getData($widthAttribute)) *
(float)str_replace(',', '.', $product->getData($heightAttribute)) *
(float)str_replace(',', '.', $product->getData($lengthAttribute)) *

return $this->reformatVolumeData($product->getData($widthAttribute)) *
$this->reformatVolumeData($product->getData($heightAttribute)) *
$this->reformatVolumeData($product->getData($lengthAttribute)) *
$k;
}

/**
* @param $value
* @return float
*/
private function reformatVolumeData($value): float
{
if ($value == null) {
return 0.00;
}

return (float)str_replace(',', '.', $value);
}
}
18 changes: 18 additions & 0 deletions Model/ShippingInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ShippingInfo extends DataObject
public const PREFERRED_DELIVERY_DATE = 'preferred_delivery_date';
public const ESTIMATED_DELIVERY_RANGE = 'estimated_delivery_range';
public const CARRIER_PICKUP_DATE = 'carrier_pickup_date';
public const CARRIER_DESCRIPTION = 'carrier_description';
/**#@- */

/**
Expand Down Expand Up @@ -274,4 +275,21 @@ public function getCarrierPickupDate()
{
return $this->getData(self::CARRIER_PICKUP_DATE);
}

/**
* @param string $value
* @return $this
*/
public function setCarrierDescription($value)
{
return $this->setData(self::CARRIER_DESCRIPTION, $value);
}

/**
* @return string|null
*/
public function getCarrierDescription()
{
return $this->getData(self::CARRIER_DESCRIPTION);
}
}
3 changes: 2 additions & 1 deletion Plugin/Checkout/ShippingInformationManagementPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ public function beforeSaveAddressInformation(
->setStreet($this->arrayManager->get('street', $pickupLocationAddress))
->setCity($this->arrayManager->get('city', $pickupLocationAddress))
->setCountryId($this->arrayManager->get('country', $pickupLocationAddress))
->setCompany($this->arrayManager->get('name', $pickupLocation));
->setCompany($this->arrayManager->get('name', $pickupLocation))
->setSaveInAddressBook(0);

// ... also set to quote shipping address if exists
if (($quoteShippingAddress = $quote->getShippingAddress())
Expand Down
12 changes: 12 additions & 0 deletions ViewModel/Pickup/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,16 @@ public function getLocationCode()
return '';
}
}

/**
* @return string
*/
public function getCarrierDescription()
{
try {
return (string)$this->getOrderInfo()->getCarrierDescription();
} catch (NoSuchEntityException $e) {
return '';
}
}
}
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": "paazl/magento2-checkout-widget",
"description": "Paazl checkoutWidget for Magento 2",
"type": "magento2-module",
"version": "1.16.1",
"version": "1.17.0",
"keywords": [
"Paazl",
"Magento 2",
Expand Down
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<default>
<carriers>
<paazlshipping>
<version>v1.16.1</version>
<version>v1.17.0</version>
<active>0</active>
<sallowspecific>0</sallowspecific>
<price>0</price>
Expand Down
6 changes: 6 additions & 0 deletions view/adminhtml/templates/order/view/pickup/info.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ $viewModel = $block->getData('pickupViewModel');
<?= $block->escapeHtml($viewModel->getLocationCode())?>
</div>
<?php endif; ?>
<?php if ($description = $viewModel->getCarrierDescription()): ?>
<div class="store-code-wrapper">
<strong><?= /* @noEscape */ __('Carrier Description') ?>:</strong><br/>
<?= $block->escapeHtml($description)?>
</div>
<?php endif; ?>
</div>
<?php endif;?>

0 comments on commit 368cebf

Please sign in to comment.