Skip to content

Commit 364b51a

Browse files
committed
Issue #26332 BeforeOrderPaymentSaveObserver override payment insructions
1 parent 49477e9 commit 364b51a

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

app/code/Magento/OfflinePayments/Observer/BeforeOrderPaymentSaveObserver.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public function execute(\Magento\Framework\Event\Observer $observer)
3030
Banktransfer::PAYMENT_METHOD_BANKTRANSFER_CODE,
3131
Cashondelivery::PAYMENT_METHOD_CASHONDELIVERY_CODE
3232
];
33-
if (in_array($payment->getMethod(), $instructionMethods)) {
33+
if (in_array($payment->getMethod(), $instructionMethods)
34+
&& empty($payment->getAdditionalInformation('instructions'))) {
3435
$payment->setAdditionalInformation(
3536
'instructions',
3637
$payment->getMethodInstance()->getInstructions()

app/code/Magento/OfflinePayments/Test/Unit/Observer/BeforeOrderPaymentSaveObserverTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,24 @@ public function testBeforeOrderPaymentSaveWithOthers()
172172

173173
$this->_model->execute($this->observer);
174174
}
175+
176+
/**
177+
* @param string $methodCode
178+
* @dataProvider dataProviderBeforeOrderPaymentSaveWithInstructions
179+
*/
180+
public function testBeforeOrderPaymentSaveWithInstructionsAlreadySet($methodCode)
181+
{
182+
$this->payment
183+
->method('getMethod')
184+
->willReturn($methodCode);
185+
186+
$this->payment->expects(self::once())
187+
->method('getAdditionalInformation')
188+
->willReturn('Test');
189+
190+
$this->payment->expects(self::never())
191+
->method('setAdditionalInformation');
192+
193+
$this->_model->execute($this->observer);
194+
}
175195
}

0 commit comments

Comments
 (0)