From a7fbe5a7d9710b390aa372e329827461ca115226 Mon Sep 17 00:00:00 2001 From: kGablo Date: Wed, 11 Sep 2024 15:26:07 +0200 Subject: [PATCH] Fix admin notification --- src/Hook/Installment.php | 23 ++++++++++++++++--- tpay.php | 19 ++------------- .../templates/hook/checkout_installments.tpl | 6 +++++ 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/Hook/Installment.php b/src/Hook/Installment.php index ed979c7..20e92db 100755 --- a/src/Hook/Installment.php +++ b/src/Hook/Installment.php @@ -24,9 +24,26 @@ class Installment extends AbstractHook { public const AVAILABLE_HOOKS = [ 'displayShoppingCart', - 'displayPaymentTop' + 'displayProductPriceBlock', + 'displayCheckoutSummaryTop', ]; + public function displayProductPriceBlock($params): string + { + if (Helper::getMultistoreConfigurationValue('TPAY_PEKAO_INSTALLMENTS_ACTIVE') && Helper::getMultistoreConfigurationValue('TPAY_PEKAO_INSTALLMENTS_PRODUCT_PAGE')) { + $this->context->smarty->assign(array( + 'installmentText' => $this->module->l('Calculate installment!'), + 'merchantId' => Helper::getMultistoreConfigurationValue('TPAY_MERCHANT_ID'), + 'minAmount' => Config::PEKAO_INSTALLMENT_MIN, + 'maxAmount' => Config::PEKAO_INSTALLMENT_MAX, + )); + + return $this->module->fetch('module:tpay/views/templates/hook/product_installment.tpl'); + } + + return ''; + } + public function displayShoppingCart($params) { if (Helper::getMultistoreConfigurationValue('TPAY_PEKAO_INSTALLMENTS_ACTIVE') && Helper::getMultistoreConfigurationValue('TPAY_PEKAO_INSTALLMENTS_SHOPPING_CART')) { @@ -44,7 +61,7 @@ public function displayShoppingCart($params) return ''; } - public function displayPaymentTop($params) + public function displayCheckoutSummaryTop($params) { if (Helper::getMultistoreConfigurationValue('TPAY_PEKAO_INSTALLMENTS_ACTIVE') && Helper::getMultistoreConfigurationValue('TPAY_PEKAO_INSTALLMENTS_CHECKOUT')) { $cart = $params['cart']; @@ -63,4 +80,4 @@ public function displayPaymentTop($params) return ''; } -} \ No newline at end of file +} diff --git a/tpay.php b/tpay.php index d7be194..c1fb183 100644 --- a/tpay.php +++ b/tpay.php @@ -237,7 +237,8 @@ public function install(): bool $this->registerHook('displayOrderDetail'); $this->registerHook('displayProductAdditionalInfo'); $this->registerHook('displayShoppingCart'); - $this->registerHook('displayPaymentTop'); + $this->registerHook('displayProductPriceBlock'); + $this->registerHook('displayCheckoutSummaryTop'); $this->registerHook($this->getHookDispatcher()->getAvailableHooks()); @@ -383,22 +384,6 @@ public function fetch($templatePath, $cache_id = null, $compile_id = null) return parent::fetch($templatePath, $cache_id, $compile_id); } - public function hookDisplayProductAdditionalInfo($params): string - { - if (Helper::getMultistoreConfigurationValue('TPAY_PEKAO_INSTALLMENTS_ACTIVE') && Helper::getMultistoreConfigurationValue('TPAY_PEKAO_INSTALLMENTS_PRODUCT_PAGE')) { - $this->context->smarty->assign(array( - 'installmentText' => $this->l('Calculate installment!'), - 'merchantId' => Helper::getMultistoreConfigurationValue('TPAY_MERCHANT_ID'), - 'minAmount' => Config::PEKAO_INSTALLMENT_MIN, - 'maxAmount' => Config::PEKAO_INSTALLMENT_MAX, - )); - - return $this->fetch('module:tpay/views/templates/hook/product_installment.tpl'); - } - - return ''; - } - /** Module call API. */ private function initAPI() { diff --git a/views/templates/hook/checkout_installments.tpl b/views/templates/hook/checkout_installments.tpl index 5bf0cc5..03ec9ca 100755 --- a/views/templates/hook/checkout_installments.tpl +++ b/views/templates/hook/checkout_installments.tpl @@ -5,7 +5,12 @@ let minAmount = {$minAmount}; let maxAmount = {$maxAmount}; + console.log(minAmount) + console.log(amount) + console.log() if (amount >= minAmount && amount <= maxAmount) { + console.log('dziaƂa') + createInstallmentContainer(amount); } } @@ -15,6 +20,7 @@ url = url.replace('__merchantId__', {$merchantId}).replace('__amount__', amount); let summaryTotalElement = document.querySelector('.cart-summary-products'); + console.log(summaryTotalElement) if (summaryTotalElement) { let installmentsButton = document.createElement('button');