Skip to content

Commit 949aa6b

Browse files
committed
MAGETWO-67269: Gift Options set to no still show up as choices on front end order page
- Fixes according to code review.
1 parent 4d1a6c7 commit 949aa6b

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

app/code/Magento/GiftMessage/Block/Message/Inline.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,11 @@ public function getEscaped($value, $defaultValue = '')
330330
*
331331
* @return bool
332332
*/
333-
public function isOrderLevelAvailable()
333+
public function isMessagesOrderAvailable()
334334
{
335335
$entity = $this->getEntity();
336336
if (!$entity->hasIsGiftOptionsAvailable()) {
337337
$this->_eventManager->dispatch('gift_options_prepare', ['entity' => $entity]);
338-
if (!$entity->getIsGiftOptionsAvailable()) {
339-
$entity->setIsGiftOptionsAvailable($this->isMessagesAvailable());
340-
}
341338
}
342339
return $entity->getIsGiftOptionsAvailable();
343340
}
@@ -372,7 +369,7 @@ public function isItemMessagesAvailable($item)
372369
protected function _toHtml()
373370
{
374371
// render HTML when messages are allowed for order or for items only
375-
if ($this->isItemsAvailable() || $this->isOrderLevelAvailable()) {
372+
if ($this->isItemsAvailable() || $this->isMessagesAvailable() || $this->isMessagesOrderAvailable()) {
376373
return parent::_toHtml();
377374
}
378375
return '';

app/code/Magento/GiftMessage/view/frontend/templates/inline.phtml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</div>
1919

2020
<dl class="options-items" id="allow-gift-options-container">
21-
<?php if ($block->isOrderLevelAvailable()): ?>
21+
<?php if ($block->isMessagesAvailable()): ?>
2222
<dt id="add-gift-options-for-order-<?= /* @escapeNotVerified */ $block->getEntity()->getId() ?>" class="order-title">
2323
<div class="field choice">
2424
<input type="checkbox" name="allow_gift_messages_for_order" id="allow_gift_options_for_order" data-mage-init='{"giftOptions":{}}' value="1" data-selector='{"id":"#allow-gift-options-for-order-container"}'<?php if ($block->getEntityHasMessage()): ?> checked="checked"<?php endif; ?> class="checkbox" />
@@ -28,7 +28,6 @@
2828

2929
<dd id="allow-gift-options-for-order-container" class="order-options">
3030
<div class="options-order-container" id="options-order-container-<?= /* @escapeNotVerified */ $block->getEntity()->getId() ?>"></div>
31-
<?php if ($block->isMessagesAvailable()): ?>
3231
<button class="action action-gift"
3332
data-mage-init='{"toggleAdvanced": {"selectorsToggleClass":"hidden", "toggleContainers":"#allow-gift-messages-for-order-container"}}'>
3433
<span><?= /* @escapeNotVerified */ __('Gift Message') ?></span>
@@ -63,9 +62,8 @@
6362
});
6463
</script>
6564
</div>
66-
<?php endif; ?>
6765
</dd>
68-
<?php endif; ?>
66+
<?php endif ?>
6967
<?php if ($block->isItemsAvailable()): ?>
7068
<dt id="add-gift-options-for-items-<?= /* @escapeNotVerified */ $block->getEntity()->getId() ?>" class="order-title individual">
7169
<div class="field choice">
@@ -154,7 +152,7 @@
154152
</div>
155153

156154
<dl class="options-items" id="allow-gift-options-container-<?= /* @escapeNotVerified */ $block->getEntity()->getId() ?>">
157-
<?php if ($block->isOrderLevelAvailable()): ?>
155+
<?php if ($block->isMessagesOrderAvailable() || $block->isMessagesAvailable()): ?>
158156
<dt id="add-gift-options-for-order-<?= /* @escapeNotVerified */ $block->getEntity()->getId() ?>" class="order-title">
159157
<div class="field choice">
160158
<input type="checkbox" name="allow_gift_options_for_order_<?= /* @escapeNotVerified */ $block->getEntity()->getId() ?>" id="allow_gift_options_for_order_<?= /* @escapeNotVerified */ $block->getEntity()->getId() ?>" data-mage-init='{"giftOptions":{}}' value="1" data-selector='{"id":"#allow-gift-options-for-order-container-<?= /* @escapeNotVerified */ $block->getEntity()->getId() ?>"}'<?php if ($block->getEntityHasMessage()): ?> checked="checked"<?php endif; ?> class="checkbox" />

0 commit comments

Comments
 (0)