Skip to content

Commit

Permalink
Fix admin notification
Browse files Browse the repository at this point in the history
  • Loading branch information
krzGablo committed Sep 11, 2024
1 parent 73d90a8 commit a7fbe5a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
23 changes: 20 additions & 3 deletions src/Hook/Installment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand All @@ -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'];
Expand All @@ -63,4 +80,4 @@ public function displayPaymentTop($params)

return '';
}
}
}
19 changes: 2 additions & 17 deletions tpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down Expand Up @@ -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()
{
Expand Down
6 changes: 6 additions & 0 deletions views/templates/hook/checkout_installments.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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');
Expand Down

0 comments on commit a7fbe5a

Please sign in to comment.