Skip to content

Commit 6a27053

Browse files
authored
ENGCOM-5791: Fix issue with "Apply Discount Code" input hidden, when code is applied #24467
2 parents 96443a6 + 71b6491 commit 6a27053

File tree

1 file changed

+8
-5
lines changed
  • app/code/Magento/Checkout/view/frontend/templates/cart

1 file changed

+8
-5
lines changed

app/code/Magento/Checkout/view/frontend/templates/cart/coupon.phtml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
/**
88
* @var \Magento\Framework\View\Element\AbstractBlock $block
99
*/
10+
11+
// We should use strlen function because coupon code could be "0", converted to bool will lead to false
12+
$hasCouponCode = (bool) strlen($block->getCouponCode());
1013
?>
1114
<div class="block discount"
1215
id="block-discount"
13-
data-mage-init='{"collapsible":{"openedState": "active", "saveState": false}}'
16+
data-mage-init='{"collapsible":{"active": <?= $hasCouponCode ? 'true' : 'false' ?>, "openedState": "active", "saveState": false}}'
1417
>
1518
<div class="title" data-role="title">
1619
<strong id="block-discount-heading" role="heading" aria-level="2"><?= $block->escapeHtml(__('Apply Discount Code')) ?></strong>
@@ -23,7 +26,7 @@
2326
"removeCouponSelector": "#remove-coupon",
2427
"applyButton": "button.action.apply",
2528
"cancelButton": "button.action.cancel"}}'>
26-
<div class="fieldset coupon<?= strlen($block->getCouponCode()) ? ' applied' : '' ?>">
29+
<div class="fieldset coupon<?= $hasCouponCode ? ' applied' : '' ?>">
2730
<input type="hidden" name="remove" id="remove-coupon" value="0" />
2831
<div class="field">
2932
<label for="coupon_code" class="label"><span><?= $block->escapeHtml(__('Enter discount code')) ?></span></label>
@@ -34,14 +37,14 @@
3437
name="coupon_code"
3538
value="<?= $block->escapeHtmlAttr($block->getCouponCode()) ?>"
3639
placeholder="<?= $block->escapeHtmlAttr(__('Enter discount code')) ?>"
37-
<?php if (strlen($block->getCouponCode())) :?>
40+
<?php if ($hasCouponCode) :?>
3841
disabled="disabled"
3942
<?php endif; ?>
4043
/>
4144
</div>
4245
</div>
4346
<div class="actions-toolbar">
44-
<?php if (!strlen($block->getCouponCode())) :?>
47+
<?php if (!$hasCouponCode) :?>
4548
<div class="primary">
4649
<button class="action apply primary" type="button" value="<?= $block->escapeHtmlAttr(__('Apply Discount')) ?>">
4750
<span><?= $block->escapeHtml(__('Apply Discount')) ?></span>
@@ -54,7 +57,7 @@
5457
<?php endif; ?>
5558
</div>
5659
</div>
57-
<?php if (!strlen($block->getCouponCode())) : ?>
60+
<?php if (!$hasCouponCode) : ?>
5861
<?= /* @noEscape */ $block->getChildHtml('captcha') ?>
5962
<?php endif; ?>
6063
</form>

0 commit comments

Comments
 (0)