Skip to content

Commit

Permalink
Merge pull request #81 from Paazl/release/1.9.2
Browse files Browse the repository at this point in the history
Release/1.9.2
  • Loading branch information
Marvin-Magmodules authored Nov 1, 2021
2 parents d75ca6e + 07f30dc commit e0f64da
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 23 deletions.
24 changes: 23 additions & 1 deletion Model/Api/Builder/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,15 @@ private function getProducts(OrderInterface $order)

/** @var Item $item */
foreach ($order->getItems() as $item) {
if ($item->getProductType() !== Type::TYPE_SIMPLE && $item->getProductType() !== Grouped::TYPE_CODE) {
if ($item->getProductType() !== Type::TYPE_SIMPLE
&& $item->getProductType() !== Type::TYPE_BUNDLE
&& $item->getProductType() !== Grouped::TYPE_CODE
) {
continue;
}

// Skip a simple product if the parent is a bundle
if ($this->hasBundleParent($item)) {
continue;
}

Expand Down Expand Up @@ -399,4 +407,18 @@ private function getProductDimemension(Item $item)

return $dimensionArray;
}

/**
* Check if parent item is bundle
*
* @param $item
* @return bool
*/
private function hasBundleParent($item): bool
{
if ($item->getParentItemId() > 0) {
return $item->getParentItem()->getProductType() === Type::TYPE_BUNDLE;
}
return false;
}
}
49 changes: 29 additions & 20 deletions Model/Checkout/WidgetConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,34 +126,43 @@ public function getConfig()
$postcode = $shippingAddress->getPostcode();
}

$numberOfProcessingDays = self::DEFAULT_NUMBER_OF_PROCESSING_DAYS;
$goods = [];
$widthAttribute = $this->scopeConfig->getProductAttributeWidth();
$heightAttribute = $this->scopeConfig->getProductAttributeHeight();
$lengthAttribute = $this->scopeConfig->getProductAttributeLength();
$useDimensions = $widthAttribute && $lengthAttribute && $heightAttribute;
foreach ($this->getQuote()->getAllVisibleItems() as $item) {
$goodsItem = [
"quantity" => (int)$item->getQty(),
"weight" => doubleval($item->getWeight()),
"price" => $this->itemHandler->getPriceValue($item)
];
if ($useDimensions) {
$product = $this->productRepository->getById($item->getProduct()->getId());
$goodsItem["length"] = $product->getData($lengthAttribute);
$goodsItem["width"] = $product->getData($widthAttribute);
$goodsItem["height"] = $product->getData($heightAttribute);
}
$useDimensions = $widthAttribute || $lengthAttribute || $heightAttribute;
foreach ($this->getQuote()->getAllItems() as $item) {
if ($item->getProductType() == 'simple') {
$goodsItem = [
"quantity" => (int)$item->getQty(),
"weight" => doubleval($item->getWeight()),
"price" => $this->itemHandler->getPriceValue($item)
];
if ($useDimensions) {
$product = $this->productRepository->getById($item->getProduct()->getId());
$goodsItem["length"] = (float)$product->getData($lengthAttribute);
$goodsItem["width"] = (float)$product->getData($widthAttribute);
$goodsItem["height"] = (float)$product->getData($heightAttribute);
}

if (($itemNumberOfProcessingDays = $this->getProductNumberOfProcessingDays($item))
&& $itemNumberOfProcessingDays > $numberOfProcessingDays) {
$numberOfProcessingDays = (int)$itemNumberOfProcessingDays;
if ($deliveryMatrixCode = $this->getProductDeliveryMatrix($item)) {
$goodsItem["startMatrix"] = $deliveryMatrixCode;
}
$goods[] = $goodsItem;
}
}

if ($deliveryMatrixCode = $this->getProductDeliveryMatrix($item)) {
$goodsItem["startMatrix"] = $deliveryMatrixCode;
$numberOfProcessingDays = self::DEFAULT_NUMBER_OF_PROCESSING_DAYS;
foreach ($this->getQuote()->getAllItems() as $item) {
if ($item->getProductType() == 'simple') {
$itemNumberOfProcessingDays = $this->getProductNumberOfProcessingDays($item);
if (!$itemNumberOfProcessingDays && $item->getParentItem()) {
$itemNumberOfProcessingDays = $this->getProductNumberOfProcessingDays($item->getParentItem());
}
if ($itemNumberOfProcessingDays && ($itemNumberOfProcessingDays > $numberOfProcessingDays)) {
$numberOfProcessingDays = (int)$itemNumberOfProcessingDays;
}
}
$goods[] = $goodsItem;
}

$config = [
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": "paazl/magento2-checkout-widget",
"description": "Paazl checkoutWidget for Magento 2",
"type": "magento2-module",
"version": "1.9.1",
"version": "1.9.2",
"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.9.1</version>
<version>v1.9.2</version>
<active>0</active>
<sallowspecific>0</sallowspecific>
<price>0</price>
Expand Down

0 comments on commit e0f64da

Please sign in to comment.