diff --git a/Model/Api/Builder/Order.php b/Model/Api/Builder/Order.php index 4d0ef45..718f733 100755 --- a/Model/Api/Builder/Order.php +++ b/Model/Api/Builder/Order.php @@ -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); @@ -403,19 +403,19 @@ 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; } } @@ -423,6 +423,19 @@ private function getProductDimemension(Item $item) 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 * diff --git a/Model/Api/Converter/Checkout/ToShippingInfo.php b/Model/Api/Converter/Checkout/ToShippingInfo.php index f3796b2..610249e 100644 --- a/Model/Api/Converter/Checkout/ToShippingInfo.php +++ b/Model/Api/Converter/Checkout/ToShippingInfo.php @@ -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); diff --git a/Model/Checkout/WidgetConfigProvider.php b/Model/Checkout/WidgetConfigProvider.php index c46fbe9..5385602 100755 --- a/Model/Checkout/WidgetConfigProvider.php +++ b/Model/Checkout/WidgetConfigProvider.php @@ -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); + } } diff --git a/Model/ShippingInfo.php b/Model/ShippingInfo.php index dd97e06..dcda2ac 100644 --- a/Model/ShippingInfo.php +++ b/Model/ShippingInfo.php @@ -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'; /**#@- */ /** @@ -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); + } } diff --git a/Plugin/Checkout/ShippingInformationManagementPlugin.php b/Plugin/Checkout/ShippingInformationManagementPlugin.php index 45df435..5ff812e 100755 --- a/Plugin/Checkout/ShippingInformationManagementPlugin.php +++ b/Plugin/Checkout/ShippingInformationManagementPlugin.php @@ -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()) diff --git a/ViewModel/Pickup/Info.php b/ViewModel/Pickup/Info.php index 7479723..3876e04 100755 --- a/ViewModel/Pickup/Info.php +++ b/ViewModel/Pickup/Info.php @@ -224,4 +224,16 @@ public function getLocationCode() return ''; } } + + /** + * @return string + */ + public function getCarrierDescription() + { + try { + return (string)$this->getOrderInfo()->getCarrierDescription(); + } catch (NoSuchEntityException $e) { + return ''; + } + } } diff --git a/composer.json b/composer.json index 77cd732..d18618c 100755 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/etc/config.xml b/etc/config.xml index 0ac17d8..1da38ad 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -8,7 +8,7 @@ - v1.16.1 + v1.17.0 0 0 0 diff --git a/view/adminhtml/templates/order/view/pickup/info.phtml b/view/adminhtml/templates/order/view/pickup/info.phtml index d999429..8e1a40b 100755 --- a/view/adminhtml/templates/order/view/pickup/info.phtml +++ b/view/adminhtml/templates/order/view/pickup/info.phtml @@ -23,6 +23,12 @@ $viewModel = $block->getData('pickupViewModel'); escapeHtml($viewModel->getLocationCode())?> + getCarrierDescription()): ?> +
+ :
+ escapeHtml($description)?> +
+