Skip to content

Commit 38484c5

Browse files
committed
Merge remote-tracking branch 'origin/imported-magento-magento2-31422' into 2.4-develop-pr118
2 parents 1a00791 + 275e42e commit 38484c5

File tree

2 files changed

+37
-4
lines changed
  • app/code/Magento/Sales/Model/AdminOrder
  • dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create

2 files changed

+37
-4
lines changed

app/code/Magento/Sales/Model/AdminOrder/Create.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,10 +1755,9 @@ public function importPostData($data)
17551755

17561756
if (isset($data['comment'])) {
17571757
$this->getQuote()->addData($data['comment']);
1758-
if (empty($data['comment']['customer_note_notify'])) {
1759-
$this->getQuote()->setCustomerNoteNotify(false);
1760-
} else {
1761-
$this->getQuote()->setCustomerNoteNotify(true);
1758+
if ($this->getIsValidate()) {
1759+
$notify = !empty($data['comment']['customer_note_notify']);
1760+
$this->getQuote()->setCustomerNoteNotify($notify);
17621761
}
17631762
}
17641763

dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create/LoadBlockTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,40 @@ public function testAddProductToOrderFromWishList(): void
231231
$this->assertCount(1, $quoteItems);
232232
}
233233

234+
/**
235+
* Check that customer notification is NOT disabled after comment is updated.
236+
*
237+
* @return void
238+
* @magentoDataFixture Magento/Checkout/_files/quote_with_customer_without_address.php
239+
*/
240+
public function testUpdateCustomerNote(): void
241+
{
242+
$customerNote = 'Example Comment';
243+
$quoteId = $this->getQuoteByReservedOrderId->execute('test_order_with_customer_without_address')->getId();
244+
$this->session->setQuoteId($quoteId);
245+
$params = [
246+
'json' => false,
247+
'block' => 'totals',
248+
'as_js_varname' => false,
249+
];
250+
$post = $this->hydratePost([
251+
'order' => [
252+
'comment' => [
253+
CartInterface::KEY_CUSTOMER_NOTE => $customerNote
254+
],
255+
],
256+
]);
257+
$this->dispatchWitParams($params, $post);
258+
259+
$quote = $this->session->getQuote();
260+
$this->assertEquals($customerNote, $quote->getCustomerNote());
261+
$this->assertTrue((bool)$quote->getCustomerNoteNotify());
262+
263+
preg_match('/id="notify_customer"(?<attributes>.*?)\/>/s', $this->getResponse()->getBody(), $matches);
264+
$this->assertArrayHasKey('attributes', $matches);
265+
$this->assertStringContainsString('checked="checked"', $matches['attributes']);
266+
}
267+
234268
/**
235269
* Check customer quotes
236270
*

0 commit comments

Comments
 (0)