diff --git a/Observer/ShortcutButtons/AddExpressPayButtonsObserver.php b/Observer/ShortcutButtons/AddExpressPayButtonsObserver.php index 4d920787..8d1a8c5c 100644 --- a/Observer/ShortcutButtons/AddExpressPayButtonsObserver.php +++ b/Observer/ShortcutButtons/AddExpressPayButtonsObserver.php @@ -43,15 +43,30 @@ public function execute(Observer $observer): void /** @var ExpressPayShortcutButtons $expressPayShortcutButtons */ $expressPayShortcutButtons = $layout->createBlock( ExpressPayShortcutButtons::class, - ExpressPayShortcutButtons::BLOCK_ALIAS, + '', [ 'data' => [ 'express_pay_view_model' => $this->expressPayFactory->create(), - 'render_page_source' => PaymentBoosterConfigProvider::PAGE_SOURCE_MINICART + 'render_page_source' => $this->getPageType($observer->getEvent()) ] ] ); $container->addShortcut($expressPayShortcutButtons); } + + /** + * @param $event + * @return string + */ + private function getPageType($event) : string + { + if ($event->getIsCatalogProduct()) { + return PaymentBoosterConfigProvider::PAGE_SOURCE_PRODUCT; + } + if ($event->getIsShoppingCart()) { + return PaymentBoosterConfigProvider::PAGE_SOURCE_CART; + } + return PaymentBoosterConfigProvider::PAGE_SOURCE_MINICART; + } } diff --git a/UI/PaymentBoosterConfigProvider.php b/UI/PaymentBoosterConfigProvider.php index 498aa4b7..3086b20e 100644 --- a/UI/PaymentBoosterConfigProvider.php +++ b/UI/PaymentBoosterConfigProvider.php @@ -20,9 +20,10 @@ class PaymentBoosterConfigProvider implements ConfigProviderInterface { - public const PAGE_SOURCE_PRODUCT = 'product'; + public const PAGE_SOURCE_PRODUCT = 'product-details'; public const PAGE_SOURCE_CART = 'cart'; public const PAGE_SOURCE_MINICART = 'mini-cart'; + public const PAGE_SOURCE_CHECKOUT = 'checkout'; /** * @var CheckoutData @@ -113,7 +114,7 @@ public function getConfig(): array if ($epsGatewayId === null) { $errorMsgs[] = '$epsGatewayId is null.'; } - + $this->logger->critical('Error in PaymentBoosterConfigProvider->getConfig(): '.implode(', ', $errorMsgs)); return []; } diff --git a/view/frontend/layout/checkout_index_index.xml b/view/frontend/layout/checkout_index_index.xml index 57890d61..b04ee1cb 100644 --- a/view/frontend/layout/checkout_index_index.xml +++ b/view/frontend/layout/checkout_index_index.xml @@ -13,6 +13,9 @@ Bold_CheckoutPaymentBooster/js/view/bold-express-pay 0 + + Bold\CheckoutPaymentBooster\UI\PaymentBoosterConfigProvider::PAGE_SOURCE_CHECKOUT + diff --git a/view/frontend/templates/express-pay.phtml b/view/frontend/templates/express-pay.phtml index e0cbefb6..f9716484 100644 --- a/view/frontend/templates/express-pay.phtml +++ b/view/frontend/templates/express-pay.phtml @@ -11,6 +11,7 @@ use Bold\CheckoutPaymentBooster\ViewModel\ExpressPay; $expressPayViewModel = $block->getData('express_pay_view_model'); $pageSource = $block->getData('render_page_source'); $isEnabled = $expressPayViewModel->isEnabled($pageSource); +$containerId = 'express-pay-buttons-' . $pageSource; if (!$isEnabled): return; @@ -18,7 +19,7 @@ endif; ?>
-
+