Skip to content

Commit

Permalink
🔃 [EngCom] Public Pull Requests - 2.1-develop
Browse files Browse the repository at this point in the history
Accepted Public Pull Requests:
 - #16782: [Backport] issue/14056 - Coupon API not working for guest user (by @gelanivishal)


Fixed GitHub Issues:
 - #14056: Coupon API not working for guest user (reported by @gnanasekaranl) has been fixed in #16782 by @gelanivishal in 2.1-develop branch
   Related commits:
     1. 03b7b5e
     2. bc749b0
  • Loading branch information
Stanislav Idolov authored Aug 14, 2018
2 parents 1a76d86 + 3b97114 commit 1eb2698
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/code/Magento/Quote/Model/CouponManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public function set($cartId, $couponCode)
if (!$quote->getItemsCount()) {
throw new NoSuchEntityException(__('Cart %1 doesn\'t contain products', $cartId));
}
if (!$quote->getStoreId()) {
throw new NoSuchEntityException(__('Cart isn\'t assigned to correct store'));
}
$quote->getShippingAddress()->setCollectShippingRates(true);

try {
Expand Down
10 changes: 10 additions & 0 deletions app/code/Magento/Quote/Test/Unit/Model/CouponManagementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ protected function setUp()
'save',
'getShippingAddress',
'getCouponCode',
'getStoreId',
'__wakeup'
],
[],
Expand Down Expand Up @@ -112,6 +113,9 @@ public function testSetWhenCouldNotApplyCoupon()
$cartId = 33;
$couponCode = '153a-ABC';

$this->storeMock->expects($this->any())->method('getId')->will($this->returnValue(1));
$this->quoteMock->expects($this->once())->method('getStoreId')->willReturn($this->returnValue(1));

$this->quoteRepositoryMock->expects($this->once())
->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock));
$this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(12));
Expand Down Expand Up @@ -139,6 +143,9 @@ public function testSetWhenCouponCodeIsInvalid()
$cartId = 33;
$couponCode = '153a-ABC';

$this->storeMock->expects($this->any())->method('getId')->will($this->returnValue(1));
$this->quoteMock->expects($this->once())->method('getStoreId')->willReturn($this->returnValue(1));

$this->quoteRepositoryMock->expects($this->once())
->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock));
$this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(12));
Expand All @@ -158,6 +165,9 @@ public function testSet()
$cartId = 33;
$couponCode = '153a-ABC';

$this->storeMock->expects($this->any())->method('getId')->will($this->returnValue(1));
$this->quoteMock->expects($this->once())->method('getStoreId')->willReturn($this->returnValue(1));

$this->quoteRepositoryMock->expects($this->once())
->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock));
$this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(12));
Expand Down

0 comments on commit 1eb2698

Please sign in to comment.