Skip to content

Commit 4490b1a

Browse files
author
Stanislav Idolov
committed
MAGETWO-53501: Coupon can not be cancelled when total is less then minimum order amount
1 parent 4c87bc7 commit 4490b1a

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

app/code/Magento/Checkout/Block/Cart/ValidationMessages.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ValidationMessages extends \Magento\Framework\View\Element\Messages
2222
/**
2323
* @var \Magento\Quote\Model\Quote\Validator\MinimumOrderAmount\ValidationMessage
2424
*/
25-
private $validationMessages;
25+
private $minimumAmountErrorMessage;
2626

2727
/**
2828
* @param \Magento\Framework\View\Element\Template\Context $context
@@ -78,22 +78,23 @@ protected function _prepareLayout()
7878
protected function validateMinimumAmount()
7979
{
8080
if (!$this->cartHelper->getQuote()->validateMinimumAmount()) {
81-
$this->messageManager->addNotice($this->getMinimumAmountErrorMessageDependency()->getMessage());
81+
$this->messageManager->addNotice($this->getMinimumAmountErrorMessage()->getMessage());
8282
}
8383
}
8484

8585
/**
8686
* @return \Magento\Quote\Model\Quote\Validator\MinimumOrderAmount\ValidationMessage
87+
* @deprecated
8788
*/
88-
private function getMinimumAmountErrorMessageDependency()
89+
private function getMinimumAmountErrorMessage()
8990
{
90-
if ($this->validationMessages === null) {
91+
if ($this->minimumAmountErrorMessage === null) {
9192
$objectManager = ObjectManager::getInstance();
92-
$this->validationMessages = $objectManager->get(
93+
$this->minimumAmountErrorMessage = $objectManager->get(
9394
\Magento\Quote\Model\Quote\Validator\MinimumOrderAmount\ValidationMessage::class
9495
);
9596
}
96-
return $this->validationMessages;
97+
return $this->minimumAmountErrorMessage;
9798
}
9899

99100
/**

app/code/Magento/Quote/Model/Quote/Validator/MinimumOrderAmount/ValidationMessage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(
3838
}
3939

4040
/**
41-
* @return \Magento\Framework\Phrase
41+
* @return \Magento\Framework\Phrase|mixed
4242
* @throws \Zend_Currency_Exception
4343
*/
4444
public function getMessage()

app/code/Magento/Quote/Model/ShippingAddressManagement.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class ShippingAddressManagement implements \Magento\Quote\Model\ShippingAddressM
5555
/**
5656
* @var \Magento\Quote\Model\Quote\Validator\MinimumOrderAmount\ValidationMessage
5757
*/
58-
private $validationMessages;
58+
private $minimumAmountErrorMessage;
5959

6060
/**
6161
* @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
@@ -114,7 +114,7 @@ public function assign($cartId, \Magento\Quote\Api\Data\AddressInterface $addres
114114
$address->setCollectShippingRates(true);
115115

116116
if (!$quote->validateMinimumAmount($quote->getIsMultiShipping())) {
117-
throw new InputException($this->getMinimumAmountErrorMessageDependency()->getMessage());
117+
throw new InputException($this->getMinimumAmountErrorMessage()->getMessage());
118118
}
119119

120120
try {
@@ -144,15 +144,16 @@ public function get($cartId)
144144

145145
/**
146146
* @return \Magento\Quote\Model\Quote\Validator\MinimumOrderAmount\ValidationMessage
147+
* @deprecated
147148
*/
148-
private function getMinimumAmountErrorMessageDependency()
149+
private function getMinimumAmountErrorMessage()
149150
{
150-
if ($this->validationMessages === null) {
151+
if ($this->minimumAmountErrorMessage === null) {
151152
$objectManager = ObjectManager::getInstance();
152-
$this->validationMessages = $objectManager->get(
153+
$this->minimumAmountErrorMessage = $objectManager->get(
153154
\Magento\Quote\Model\Quote\Validator\MinimumOrderAmount\ValidationMessage::class
154155
);
155156
}
156-
return $this->validationMessages;
157+
return $this->minimumAmountErrorMessage;
157158
}
158159
}

app/code/Magento/Quote/Test/Unit/Model/Quote/Validator/MinimumOrderAmount/ValidationMessageTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,15 @@ public function testGetMessage()
7777
$this->model->getMessage()
7878
);
7979
}
80+
81+
public function testGetConfigMessage()
82+
{
83+
$configMessage = 'config_message';
84+
$this->scopeConfigMock->expects($this->once())
85+
->method('getValue')
86+
->with('sales/minimum_order/description', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)
87+
->willReturn($configMessage);
88+
89+
$this->assertEquals($configMessage, $this->model->getMessage());
90+
}
8091
}

0 commit comments

Comments
 (0)