File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 2 files changed +37
-4
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 *
You can’t perform that action at this time.
0 commit comments