-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CHK-4614] Adding Express Pay modal to the PDP
Adding before cart add event to clear cart for quick purchase Adding support for SDK onClick event to add item to cart on pdp Adding page source argument to express pay xml to facilitate above add Adding functionality to checkout without a quote active Adding Endpoint to fetch Quote Mask Id for guest shipping estimate endpoints
- Loading branch information
1 parent
cac0be2
commit 1723340
Showing
19 changed files
with
393 additions
and
47 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,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bold\CheckoutPaymentBooster\Api\Quote; | ||
|
||
/** | ||
* Hydrate Bold order from Magento quote. | ||
*/ | ||
interface GetQuoteInterface | ||
{ | ||
/** | ||
* Gets Current Session Quote ID | ||
* | ||
* @return string | ||
* @throws \Magento\Framework\Exception\LocalizedException | ||
*/ | ||
public function getQuoteId(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
|
||
namespace Bold\CheckoutPaymentBooster\Observer\Product; | ||
|
||
use Magento\Framework\Event\Observer; | ||
use Magento\Framework\Event\ObserverInterface; | ||
use Magento\Checkout\Model\Session; | ||
use Magento\Quote\Api\CartRepositoryInterface; | ||
|
||
/** | ||
* Observer for `controller_action_predispatch_checkout_cart_add` event | ||
* | ||
* @see \Magento\Framework\App\FrontController::dispatchPreDispatchEvents | ||
* @see \Magento\Checkout\Controller\Cart\Add::execute | ||
*/ | ||
class ExpressPayBeforeAddToCartObserver implements ObserverInterface | ||
{ | ||
/** | ||
* @var Session | ||
*/ | ||
protected $checkoutSession; | ||
|
||
/** | ||
* @var CartRepositoryInterface | ||
*/ | ||
protected $cartRepository; | ||
|
||
public function __construct(Session $checkoutSession, CartRepositoryInterface $cartRepository) | ||
{ | ||
$this->checkoutSession = $checkoutSession; | ||
$this->cartRepository = $cartRepository; | ||
} | ||
|
||
/** | ||
* Clear the cart before checking out with Express Pay from the product detail page | ||
* | ||
* @param Observer $observer | ||
* @return void | ||
*/ | ||
public function execute(Observer $observer): void | ||
{ | ||
$request = $observer->getEvent()->getRequest(); | ||
$isExpressPayOrder = $request->getParam('source') === 'expresspay'; | ||
|
||
$quote = $this->checkoutSession->getQuote(); | ||
|
||
if (!$isExpressPayOrder) { | ||
return; | ||
} | ||
$this->checkoutSession->setCheckoutState(true); | ||
$quote->removeAllItems(); | ||
$quote->setTotalsCollectedFlag(false); | ||
$this->checkoutSession->clearQuote(); | ||
|
||
$this->cartRepository->save($quote); | ||
$this->checkoutSession->setQuoteId($quote->getId()); | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bold\CheckoutPaymentBooster\Service\Quote; | ||
|
||
use Bold\CheckoutPaymentBooster\Api\Quote\GetQuoteInterface; | ||
use Magento\Checkout\Model\Session; | ||
use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface; | ||
|
||
/** | ||
* Get Current Quote ID from Magento quote. | ||
*/ | ||
class GetQuote implements GetQuoteInterface | ||
{ | ||
/** | ||
* @var Session | ||
*/ | ||
private $checkoutSession; | ||
|
||
/** | ||
* @var QuoteIdToMaskedQuoteId | ||
*/ | ||
private $quoteIdToMaskedQuoteId; | ||
|
||
public function __construct(Session $checkoutSession, QuoteIdToMaskedQuoteIdInterface $quoteIdToMaskedQuoteId) | ||
{ | ||
$this->checkoutSession = $checkoutSession; | ||
$this->quoteIdToMaskedQuoteId = $quoteIdToMaskedQuoteId; | ||
} | ||
|
||
/** | ||
* Gets Current Session Quote ID | ||
* | ||
* @return string | ||
* @throws \Magento\Framework\Exception\LocalizedException | ||
*/ | ||
public function getQuoteId() | ||
{ | ||
$quoteId = (int)$this->checkoutSession->getQuote()->getId(); | ||
$quoteIdMask = $this->quoteIdToMaskedQuoteId->execute($quoteId); | ||
|
||
return $quoteIdMask; | ||
} | ||
} |
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
Oops, something went wrong.