-
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.
14086: Guest cart API ignoring cartId in url for some methods
- Loading branch information
1 parent
5a9fcab
commit 2bdcc11
Showing
3 changed files
with
81 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,49 @@ | ||
<?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 { | ||
if ($cartId = $this->request->getParam('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