-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENGCOM-7075: #14086: Guest cart API ignoring cartId in url for some m…
…ethods #27172
- Loading branch information
Showing
3 changed files
with
83 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Magento\Quote\Plugin; | ||
|
||
use Magento\Framework\Webapi\Rest\Request as RestRequest; | ||
use Magento\Quote\Api\Data\CartItemInterface; | ||
use Magento\Quote\Api\GuestCartItemRepositoryInterface; | ||
|
||
/** | ||
* Update cart id from request param | ||
*/ | ||
class UpdateCartId | ||
{ | ||
/** | ||
* @var RestRequest $request | ||
*/ | ||
private $request; | ||
|
||
/** | ||
* @param RestRequest $request | ||
*/ | ||
public function __construct(RestRequest $request) | ||
{ | ||
$this->request = $request; | ||
} | ||
|
||
/** | ||
* Update id from request if param cartId exist | ||
* | ||
* @param GuestCartItemRepositoryInterface $guestCartItemRepository | ||
* @param CartItemInterface $cartItem | ||
* @return void | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function beforeSave( | ||
GuestCartItemRepositoryInterface $guestCartItemRepository, | ||
CartItemInterface $cartItem | ||
): void { | ||
$cartId = $this->request->getParam('cartId'); | ||
|
||
if ($cartId) { | ||
$cartItem->setQuoteId($cartId); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters