Skip to content

Commit 1a328c4

Browse files
ENGCOM-5598: Set isMultiShipping to 0 in database so it can be used correctly by rest api requests on checkout page #24072
- Merge Pull Request #24072 from websnap/magento2-1:disable-multishipping-on-regular-checkout-page - Merged commits: 1. 5f27338 2. b3b920d 3. b5353a0 4. eb9aa30 5. 9140fab
2 parents c6427d1 + 9140fab commit 1a328c4

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

app/code/Magento/Multishipping/Controller/Checkout/Plugin.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
6+
declare(strict_types=1);
7+
78
namespace Magento\Multishipping\Controller\Checkout;
89

10+
/**
11+
* Turns Off Multishipping mode for Quote.
12+
*/
913
class Plugin
1014
{
1115
/**
@@ -30,6 +34,10 @@ public function __construct(\Magento\Checkout\Model\Cart $cart)
3034
*/
3135
public function beforeExecute(\Magento\Framework\App\Action\Action $subject)
3236
{
33-
$this->cart->getQuote()->setIsMultiShipping(0);
37+
$quote = $this->cart->getQuote();
38+
if ($quote->getIsMultiShipping()) {
39+
$quote->setIsMultiShipping(0);
40+
$this->cart->saveQuote();
41+
}
3442
}
3543
}

app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/PluginTest.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
* Copyright © Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7+
8+
declare(strict_types=1);
9+
710
namespace Magento\Multishipping\Test\Unit\Controller\Checkout;
811

912
use Magento\Multishipping\Controller\Checkout\Plugin;
@@ -30,16 +33,27 @@ protected function setUp()
3033
$this->cartMock = $this->createMock(\Magento\Checkout\Model\Cart::class);
3134
$this->quoteMock = $this->createPartialMock(
3235
\Magento\Quote\Model\Quote::class,
33-
['__wakeUp', 'setIsMultiShipping']
36+
['__wakeUp', 'setIsMultiShipping', 'getIsMultiShipping']
3437
);
3538
$this->cartMock->expects($this->once())->method('getQuote')->will($this->returnValue($this->quoteMock));
3639
$this->object = new \Magento\Multishipping\Controller\Checkout\Plugin($this->cartMock);
3740
}
3841

39-
public function testExecuteTurnsOffMultishippingModeOnQuote()
42+
public function testExecuteTurnsOffMultishippingModeOnMultishippingQuote(): void
4043
{
4144
$subject = $this->createMock(\Magento\Checkout\Controller\Index\Index::class);
45+
$this->quoteMock->expects($this->once())->method('getIsMultiShipping')->willReturn(1);
4246
$this->quoteMock->expects($this->once())->method('setIsMultiShipping')->with(0);
47+
$this->cartMock->expects($this->once())->method('saveQuote');
48+
$this->object->beforeExecute($subject);
49+
}
50+
51+
public function testExecuteTurnsOffMultishippingModeOnNotMultishippingQuote(): void
52+
{
53+
$subject = $this->createMock(\Magento\Checkout\Controller\Index\Index::class);
54+
$this->quoteMock->expects($this->once())->method('getIsMultiShipping')->willReturn(0);
55+
$this->quoteMock->expects($this->never())->method('setIsMultiShipping');
56+
$this->cartMock->expects($this->never())->method('saveQuote');
4357
$this->object->beforeExecute($subject);
4458
}
4559
}

0 commit comments

Comments
 (0)