Skip to content

Commit 378065c

Browse files
faraz-glsreenia806
authored andcommitted
AC-8753: Coupon quantity generation checks
* Code refinements
1 parent a72498d commit 378065c

File tree

1 file changed

+5
-4
lines changed
  • app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote

1 file changed

+5
-4
lines changed

app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Generate.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,19 @@ public function execute(): void
161161
$data = $inputFilter->getUnescaped();
162162
}
163163

164-
$data['quantity'] = $data['qty'] ?? null;
165-
$couponQuantity = (int)$this->scopeConfig->getValue(
164+
$data['quantity'] = $data['qty'] ?? 0;
165+
$couponQuantityLimit = (int)$this->scopeConfig->getValue(
166166
self::XML_CONFIG_COUPON_QUANTITY_LIMIT,
167167
ScopeInterface::SCOPE_STORE
168168
);
169-
// @codingStandardsIgnoreStart
170-
if ($data['quantity'] && $data['quantity'] > 0 && $couponQuantity && $data['quantity'] > $couponQuantity) {
169+
if ($data['quantity'] > 0 && $data['quantity'] > $couponQuantityLimit) {
170+
// @codingStandardsIgnoreStart
171171
$this->messageManager->addErrorMessage(
172172
__(
173173
'Coupon quantity should be less than or equal to the coupon quantity in the store configuration.'
174174
)
175175
);
176+
// @codingStandardsIgnoreEnd
176177
} else {
177178
$couponSpec = $this->generationSpecFactory->create(['data' => $data]);
178179

0 commit comments

Comments
 (0)