Skip to content

Commit

Permalink
Merge pull request #120 from sowbiba/feat/MBO-1499/3x-remove-paylater
Browse files Browse the repository at this point in the history
[MBO-1499] Remove paylater banner code + Bump to 3.0.4
  • Loading branch information
sowbiba authored Jan 17, 2024
2 parents 056be25 + 2bd6d0f commit 4350b9d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 167 deletions.
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>gamification</name>
<displayName><![CDATA[Merchant Expertise]]></displayName>
<version><![CDATA[3.0.3]]></version>
<version><![CDATA[3.0.4]]></version>
<description><![CDATA[Become an e-commerce expert within the blink of an eye!]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[administration]]></tab>
Expand Down
70 changes: 1 addition & 69 deletions gamification.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct()
{
$this->name = 'gamification';
$this->tab = 'administration';
$this->version = '3.0.3';
$this->version = '3.0.4';
$this->author = 'PrestaShop';
$this->module_key = 'c1187d1672d2a2d33fbd7d5c29f0d42e';
$this->ps_versions_compliancy = [
Expand Down Expand Up @@ -77,7 +77,6 @@ public function install()
&& parent::install()
&& $this->registerHook('actionAdminControllerSetMedia')
&& $this->registerHook('displayBackOfficeHeader')
&& $this->registerHook('displayAdminAfterHeader')
;
}

Expand Down Expand Up @@ -436,71 +435,4 @@ public function isFresh($file, $timeout = 86400000)

return $now < $lastFileUpdate;
}

/**
* Display PrestaShop Paylater with PayPlug & Oney
*
* @return string
*/
public function hookDisplayAdminAfterHeader()
{
// PrestaShop Paylater with PayPlug & Oney is available only from PrestaShop 1.7
if (version_compare(_PS_VERSION_, '1.7.0.0', '<') || version_compare(_PS_VERSION_, '8.0.0', '>=')) {
return '';
}

// Display PrestaShop Paylater with PayPlug & Oney only if PrestaShop Checkout is enabled and onboarded for FR & IT located merchant
if ('AdminPayment' === Tools::getValue('controller')
&& in_array($this->getShopCountryCode(), ['FR', 'IT', 'ES', 'BE'], true)
&& Module::isEnabled('ps_checkout')
&& Configuration::get('PS_CHECKOUT_PAYPAL_ID_MERCHANT')
) {
$this->context->smarty->assign([
'pspaylater_install_link' => $this->getModuleInstallUrl('pspaylater'),
'pspaylater_configure_link' => $this->context->link->getAdminLink('AdminModules', true) . '&configure=pspaylater',
'pspaylater_img_path' => $this->getPathUri() . 'views/img/pspaylater.png',
'pspaylater_enabled' => Module::isEnabled('pspaylater'),
]);

return $this->display(__FILE__, 'displayBackOfficeHeader.tpl');
}

return '';
}

/**
* @return string
*/
private function getShopCountryCode()
{
$defaultCountry = '';

if (empty($defaultCountry) && Configuration::hasKey('PS_COUNTRY_DEFAULT')) {
$defaultCountry = (new Country((int) Configuration::get('PS_COUNTRY_DEFAULT')))->iso_code;
}

return $defaultCountry ? strtoupper($defaultCountry) : '';
}

/**
* @param string $name
*
* @return string
*/
private function getModuleInstallUrl($name)
{
if (version_compare(_PS_VERSION_, '1.7.0.0', '>=')) {
return $this->context->link->getAdminLink(
'AdminModulesSf',
true,
[
'route' => 'admin_module_manage_action',
'action' => 'install',
'module_name' => $name,
]
);
}

return $this->context->link->getAdminLink('AdminModules') . '&install=' . $name . '&tab_module=payments_gateways&module_name=' . $name . '&anchor=' . ucfirst($name);
}
}
32 changes: 32 additions & 0 deletions upgrade/install-3.0.4.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
if (!defined('_PS_VERSION_')) {
exit;
}

/**
* @param Module $module
*
* @return bool
*/
function upgrade_module_3_0_4($module)
{
return (bool) $module->unregisterHook('displayAdminAfterHeader');
}
62 changes: 0 additions & 62 deletions views/templates/hook/displayBackOfficeHeader.tpl

This file was deleted.

35 changes: 0 additions & 35 deletions views/templates/hook/index.php

This file was deleted.

0 comments on commit 4350b9d

Please sign in to comment.