From c20437358b25a66545832760c2dd46d4549654f0 Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 29 Sep 2021 20:42:49 +0000 Subject: [PATCH] adjust to add quty limits messages --- Block/Product/View.php | 9 ++- README.md | 0 composer.json | 2 +- etc/module.xml | 0 registration.php | 0 .../templates/product/view/quantity.phtml | 72 ++++++++++++------- 6 files changed, 54 insertions(+), 29 deletions(-) mode change 100644 => 100755 Block/Product/View.php mode change 100644 => 100755 README.md mode change 100644 => 100755 composer.json mode change 100644 => 100755 etc/module.xml mode change 100644 => 100755 registration.php diff --git a/Block/Product/View.php b/Block/Product/View.php old mode 100644 new mode 100755 index fbe6bdc..d3abbf9 --- a/Block/Product/View.php +++ b/Block/Product/View.php @@ -22,7 +22,12 @@ public function getMaxQty($product) { $stockItem = $this->stockRegistry->getStockItem($product->getId(), $product->getStore()->getWebsiteId()); $maxSaleQty = $stockItem->getMaxSaleQty(); - return $maxSaleQty > 0 ? $maxSaleQty : 10000000; + if ($maxSaleQty > 0 && $maxSaleQty < 100000) { + $product->addData(['max_sale_qty' => $maxSaleQty]); + } else { + $maxSaleQty = 100000; + } + return $maxSaleQty; } /** @@ -35,7 +40,7 @@ public function getQtyStep($product) { $stockItem = $this->stockRegistry->getStockItem($product->getId(), $product->getStore()->getWebsiteId()); $qtyStep = 1; - if($stockItem->getEnableQtyIncrements()) { + if ($stockItem->getEnableQtyIncrements()) { $qtyStep = $stockItem->getQtyIncrements(); } return $qtyStep; diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/composer.json b/composer.json old mode 100644 new mode 100755 index dcdc09e..801e66d --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "proxi-blue/hyva-qtyinput", - "version": "1.0.2", + "version": "1.0.3", "description": "Enhance QTY input to honour min/max and increment values", "type": "magento2-module", "require": { diff --git a/etc/module.xml b/etc/module.xml old mode 100644 new mode 100755 diff --git a/registration.php b/registration.php old mode 100644 new mode 100755 diff --git a/view/frontend/templates/product/view/quantity.phtml b/view/frontend/templates/product/view/quantity.phtml index 1c33a95..387d7d4 100755 --- a/view/frontend/templates/product/view/quantity.phtml +++ b/view/frontend/templates/product/view/quantity.phtml @@ -21,7 +21,16 @@ $product = $block->getProduct(); $minQty = $block->getMinimalQty($product) * 1; $maxQty = $block->getMaxQty($product) * 1; $qtyStep = $block->getQtyStep($product) * 1; - +$message = []; +if ($minQty > 0) { + $message[] = $escaper->escapeHtml(__('Minimum quantity of %1', $minQty)); +} +if ($qtyStep > 0) { + $message[] = $escaper->escapeHtml(__('Quantity increment of %1', $qtyStep)); +} +if ($product->getData('max_sale_qty') > 0) { + $message[] = $escaper->escapeHtml(__('Maximum quantity of %1', $maxQty)); +} ?> -
- isSaleable()): ?> -
- - -
+
+ 0): ?> +
    + + +
  • + +
- +
+
+ + +
+