|
@@ -11,7 +11,7 @@ discard block |
|
|
block discarded – undo |
|
11
|
11
|
exit; |
|
12
|
12
|
} |
|
13
|
13
|
|
|
14
|
|
-define('_PS_PAGANTIS_DIR', _PS_MODULE_DIR_. '/pagantis'); |
|
|
14
|
+define('_PS_PAGANTIS_DIR', _PS_MODULE_DIR_.'/pagantis'); |
|
15
|
15
|
define('PROMOTIONS_CATEGORY', 'pagantis-promotion-product'); |
|
16
|
16
|
define('PROMOTIONS_CATEGORY_NAME', 'Pagantis Promoted Product'); |
|
17
|
17
|
|
|
@@ -162,14 +162,14 @@ discard block |
|
|
block discarded – undo |
|
162
|
162
|
foreach ($products as $product) { |
|
163
|
163
|
$code = Tools::strtolower(Pagantis::getExtraConfig('CODE', $product)); |
|
164
|
164
|
if ($code === 'p4x') { |
|
165
|
|
- Configuration::updateValue($code . '_simulator_is_enabled', 1); |
|
|
165
|
+ Configuration::updateValue($code.'_simulator_is_enabled', 1); |
|
166
|
166
|
} |
|
167
|
|
- Configuration::updateValue($code . '_is_enabled', 0); |
|
168
|
|
- Configuration::updateValue($code . '_public_key', ''); |
|
169
|
|
- Configuration::updateValue($code . '_private_key', ''); |
|
|
167
|
+ Configuration::updateValue($code.'_is_enabled', 0); |
|
|
168
|
+ Configuration::updateValue($code.'_public_key', ''); |
|
|
169
|
+ Configuration::updateValue($code.'_private_key', ''); |
|
170
|
170
|
} |
|
171
|
171
|
|
|
172
|
|
- $return = (parent::install() |
|
|
172
|
+ $return = (parent::install() |
|
173
|
173
|
&& $this->registerHook('displayShoppingCart') |
|
174
|
174
|
&& $this->registerHook('paymentOptions') |
|
175
|
175
|
&& $this->registerHook('displayProductButtons') |
|
@@ -219,34 +219,34 @@ discard block |
|
|
block discarded – undo |
|
219
|
219
|
public function checkHooks() |
|
220
|
220
|
{ |
|
221
|
221
|
try { |
|
222
|
|
- $sql_content = 'select * from ' . _DB_PREFIX_. 'hook_module where |
|
223
|
|
- id_module = \'' . Module::getModuleIdByName($this->name) . '\' and |
|
224
|
|
- id_shop = \'' . Shop::getContextShopID() . '\' and |
|
225
|
|
- id_hook = \'' . Hook::getIdByName('header') . '\''; |
|
|
222
|
+ $sql_content = 'select * from '._DB_PREFIX_.'hook_module where |
|
|
223
|
+ id_module = \'' . Module::getModuleIdByName($this->name).'\' and |
|
|
224
|
+ id_shop = \'' . Shop::getContextShopID().'\' and |
|
|
225
|
+ id_hook = \'' . Hook::getIdByName('header').'\''; |
|
226
|
226
|
$hook_exists = Db::getInstance()->ExecuteS($sql_content); |
|
227
|
227
|
if (empty($hook_exists)) { |
|
228
|
|
- $sql_insert = 'insert into ' . _DB_PREFIX_. 'hook_module |
|
|
228
|
+ $sql_insert = 'insert into '._DB_PREFIX_.'hook_module |
|
229
|
229
|
(id_module, id_shop, id_hook, position) |
|
230
|
230
|
values |
|
231
|
|
- (\''. Module::getModuleIdByName($this->name) . '\', |
|
232
|
|
- \''. Shop::getContextShopID() . '\', |
|
233
|
|
- \''. Hook::getIdByName('header') . '\', |
|
|
231
|
+ (\''. Module::getModuleIdByName($this->name).'\', |
|
|
232
|
+ \''. Shop::getContextShopID().'\', |
|
|
233
|
+ \''. Hook::getIdByName('header').'\', |
|
234
|
234
|
150)'; |
|
235
|
235
|
Db::getInstance()->execute($sql_insert); |
|
236
|
236
|
} |
|
237
|
237
|
|
|
238
|
|
- $sql_content = 'select * from ' . _DB_PREFIX_. 'hook_module where |
|
239
|
|
- id_module = \'' . Module::getModuleIdByName($this->name) . '\' and |
|
240
|
|
- id_shop = \'' . Shop::getContextShopID() . '\' and |
|
241
|
|
- id_hook = \'' . Hook::getIdByName('displayProductPriceBlock') . '\''; |
|
|
238
|
+ $sql_content = 'select * from '._DB_PREFIX_.'hook_module where |
|
|
239
|
+ id_module = \'' . Module::getModuleIdByName($this->name).'\' and |
|
|
240
|
+ id_shop = \'' . Shop::getContextShopID().'\' and |
|
|
241
|
+ id_hook = \'' . Hook::getIdByName('displayProductPriceBlock').'\''; |
|
242
|
242
|
$hook_exists = Db::getInstance()->ExecuteS($sql_content); |
|
243
|
243
|
if (empty($hook_exists)) { |
|
244
|
|
- $sql_insert = 'insert into ' . _DB_PREFIX_. 'hook_module |
|
|
244
|
+ $sql_insert = 'insert into '._DB_PREFIX_.'hook_module |
|
245
|
245
|
(id_module, id_shop, id_hook, position) |
|
246
|
246
|
values |
|
247
|
|
- (\''. Module::getModuleIdByName($this->name) . '\', |
|
248
|
|
- \''. Shop::getContextShopID() . '\', |
|
249
|
|
- \''. Hook::getIdByName('displayProductPriceBlock') . '\', |
|
|
247
|
+ (\''. Module::getModuleIdByName($this->name).'\', |
|
|
248
|
+ \''. Shop::getContextShopID().'\', |
|
|
249
|
+ \''. Hook::getIdByName('displayProductPriceBlock').'\', |
|
250
|
250
|
160)'; |
|
251
|
251
|
Db::getInstance()->execute($sql_insert); |
|
252
|
252
|
} |
|
@@ -260,7 +260,7 @@ discard block |
|
|
block discarded – undo |
|
260
|
260
|
*/ |
|
261
|
261
|
public function checkEnvVariables() |
|
262
|
262
|
{ |
|
263
|
|
- $sql_content = 'select * from ' . _DB_PREFIX_. 'pagantis_config'; |
|
|
263
|
+ $sql_content = 'select * from '._DB_PREFIX_.'pagantis_config'; |
|
264
|
264
|
$dbConfigs = Db::getInstance()->executeS($sql_content); |
|
265
|
265
|
|
|
266
|
266
|
// Convert a multimple dimension array for SQL insert statements into a simple key/value |
|
@@ -308,10 +308,10 @@ discard block |
|
|
block discarded – undo |
|
308
|
308
|
{ |
|
309
|
309
|
try { |
|
310
|
310
|
$tableName = _DB_PREFIX_.'pagantis_order'; |
|
311
|
|
- $sql = "show tables like '" . $tableName . "'"; |
|
|
311
|
+ $sql = "show tables like '".$tableName."'"; |
|
312
|
312
|
$data = Db::getInstance()->ExecuteS($sql); |
|
313
|
313
|
if (count($data) > 0) { |
|
314
|
|
- $sql = "desc " . $tableName; |
|
|
314
|
+ $sql = "desc ".$tableName; |
|
315
|
315
|
$data = Db::getInstance()->ExecuteS($sql); |
|
316
|
316
|
if (count($data) == 2) { |
|
317
|
317
|
$sql = "ALTER TABLE $tableName ADD COLUMN ps_order_id VARCHAR(60) AFTER order_id"; |
|
@@ -328,10 +328,10 @@ discard block |
|
|
block discarded – undo |
|
328
|
328
|
$this->loadSQLFile($sql_file); |
|
329
|
329
|
} |
|
330
|
330
|
$tableName = _DB_PREFIX_.'pagantis_config'; |
|
331
|
|
- $sql = "show tables like '" . $tableName . "'"; |
|
|
331
|
+ $sql = "show tables like '".$tableName."'"; |
|
332
|
332
|
$data = Db::getInstance()->ExecuteS($sql); |
|
333
|
333
|
if (count($data) > 0) { |
|
334
|
|
- $sql = "desc " . $tableName; |
|
|
334
|
+ $sql = "desc ".$tableName; |
|
335
|
335
|
$data = Db::getInstance()->ExecuteS($sql); |
|
336
|
336
|
if (count($data) === 3 && $data[2]['Type'] !== 'varchar(5000)') { |
|
337
|
337
|
$sql = "ALTER TABLE $tableName MODIFY `value` VARCHAR(5000)"; |
|
@@ -360,8 +360,8 @@ discard block |
|
|
block discarded – undo |
|
360
|
360
|
$availableCurrencies = array('EUR'); |
|
361
|
361
|
$pagantisDisplayMinAmount = $configs['DISPLAY_MIN_AMOUNT']; |
|
362
|
362
|
$pagantisDisplayMaxAmount = $configs['DISPLAY_MAX_AMOUNT']; |
|
363
|
|
- $pagantisPublicKey = Configuration::get(Tools::strtolower($configs['CODE']) . '_public_key'); |
|
364
|
|
- $pagantisPrivateKey = Configuration::get(Tools::strtolower($configs['CODE']) . '_private_key'); |
|
|
363
|
+ $pagantisPublicKey = Configuration::get(Tools::strtolower($configs['CODE']).'_public_key'); |
|
|
364
|
+ $pagantisPrivateKey = Configuration::get(Tools::strtolower($configs['CODE']).'_private_key'); |
|
365
|
365
|
$this->allowedCountries = unserialize(Pagantis::getExtraConfig('ALLOWED_COUNTRIES', null)); |
|
366
|
366
|
$this->getUserLanguage(); |
|
367
|
367
|
return ( |
|
@@ -440,42 +440,42 @@ discard block |
|
|
block discarded – undo |
|
440
|
440
|
if ($this->isPaymentMethodAvailable($product)) { |
|
441
|
441
|
$productConfigs = Pagantis::getExtraConfig($product, null); |
|
442
|
442
|
$productConfigs = json_decode($productConfigs, true); |
|
443
|
|
- $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_public_key'); |
|
444
|
|
- $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_simulator_is_enabled'); |
|
445
|
|
- $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_is_enabled'); |
|
|
443
|
+ $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_public_key'); |
|
|
444
|
+ $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_simulator_is_enabled'); |
|
|
445
|
+ $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_is_enabled'); |
|
446
|
446
|
|
|
447
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_TITLE'] = $this->l($productConfigs['TITLE']); |
|
|
447
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_TITLE'] = $this->l($productConfigs['TITLE']); |
|
448
|
448
|
unset($productConfigs['TITLE']); |
|
449
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_AMOUNT'] = $orderTotal; |
|
450
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PROMOTED_AMOUNT'] = $promotedAmount; |
|
451
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOCALE'] = $this->language; |
|
452
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_COUNTRY'] = $this->language; |
|
453
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PUBLIC_KEY'] = $publicKey; |
|
454
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled; |
|
455
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_IS_ENABLED'] = $isEnabled; |
|
456
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png'; |
|
457
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PAYMENT_URL'] = $link->getModuleLink('pagantis', 'payment') . '&product=' . $productConfigs['CODE']; |
|
458
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3)); |
|
|
449
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_AMOUNT'] = $orderTotal; |
|
|
450
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PROMOTED_AMOUNT'] = $promotedAmount; |
|
|
451
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOCALE'] = $this->language; |
|
|
452
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_COUNTRY'] = $this->language; |
|
|
453
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PUBLIC_KEY'] = $publicKey; |
|
|
454
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled; |
|
|
455
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_IS_ENABLED'] = $isEnabled; |
|
|
456
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png'; |
|
|
457
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PAYMENT_URL'] = $link->getModuleLink('pagantis', 'payment').'&product='.$productConfigs['CODE']; |
|
|
458
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3)); |
|
459
|
459
|
|
|
460
|
460
|
foreach ($productConfigs as $productConfigKey => $productConfigValue) { |
|
461
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . "_" . $productConfigKey] = $productConfigValue; |
|
|
461
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE']))."_".$productConfigKey] = $productConfigValue; |
|
462
|
462
|
} |
|
463
|
463
|
$this->context->smarty->assign($templateConfigs); |
|
464
|
464
|
|
|
465
|
465
|
$paymentOption = new PrestaShop\PrestaShop\Core\Payment\PaymentOption(); |
|
466
|
466
|
$uri = $link->getModuleLink('pagantis', 'payment'); |
|
467
|
467
|
if (strpos($uri, '?') !== false) { |
|
468
|
|
- $uri .= '&product=' . $productConfigs['CODE']; |
|
|
468
|
+ $uri .= '&product='.$productConfigs['CODE']; |
|
469
|
469
|
} else { |
|
470
|
|
- $uri .= '?product=' . $productConfigs['CODE']; |
|
|
470
|
+ $uri .= '?product='.$productConfigs['CODE']; |
|
471
|
471
|
} |
|
472
|
472
|
$paymentOption |
|
473
|
|
- ->setCallToActionText($templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_TITLE']) |
|
|
473
|
+ ->setCallToActionText($templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_TITLE']) |
|
474
|
474
|
->setAction($uri) |
|
475
|
|
- ->setLogo($templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOGO']) |
|
|
475
|
+ ->setLogo($templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOGO']) |
|
476
|
476
|
->setModuleName(__CLASS__) |
|
477
|
477
|
->setAdditionalInformation( |
|
478
|
|
- $this->fetch('module:pagantis/views/templates/hook/checkout-' . Tools::strtolower($productConfigs['CODE']) . '.tpl') |
|
|
478
|
+ $this->fetch('module:pagantis/views/templates/hook/checkout-'.Tools::strtolower($productConfigs['CODE']).'.tpl') |
|
479
|
479
|
) |
|
480
|
480
|
; |
|
481
|
481
|
$return[] = $paymentOption; |
|
@@ -499,61 +499,61 @@ discard block |
|
|
block discarded – undo |
|
499
|
499
|
foreach ($products as $product) { |
|
500
|
500
|
$code = Tools::strtolower(Pagantis::getExtraConfig('CODE', $product)); |
|
501
|
501
|
$inputs[] = array( |
|
502
|
|
- 'name' => $code .'_is_enabled', |
|
503
|
|
- 'type' => (version_compare(_PS_VERSION_, '1.6')<0) ?'radio' :'switch', |
|
504
|
|
- 'label' => $this->l('Module is enabled ' . $code), |
|
|
502
|
+ 'name' => $code.'_is_enabled', |
|
|
503
|
+ 'type' => (version_compare(_PS_VERSION_, '1.6') < 0) ? 'radio' : 'switch', |
|
|
504
|
+ 'label' => $this->l('Module is enabled '.$code), |
|
505
|
505
|
'prefix' => '<i class="icon icon-key"></i>', |
|
506
|
506
|
'class' => 't', |
|
507
|
507
|
'required' => true, |
|
508
|
508
|
'values'=> array( |
|
509
|
509
|
array( |
|
510
|
|
- 'id' => $code .'_is_enabled_true', |
|
|
510
|
+ 'id' => $code.'_is_enabled_true', |
|
511
|
511
|
'value' => 1, |
|
512
|
512
|
'label' => $this->l('Yes', get_class($this), null, false), |
|
513
|
513
|
), |
|
514
|
514
|
array( |
|
515
|
|
- 'id' => $code . '_is_enabled_false', |
|
|
515
|
+ 'id' => $code.'_is_enabled_false', |
|
516
|
516
|
'value' => 0, |
|
517
|
517
|
'label' => $this->l('No', get_class($this), null, false), |
|
518
|
518
|
), |
|
519
|
519
|
) |
|
520
|
520
|
); |
|
521
|
521
|
$inputs[] = array( |
|
522
|
|
- 'name' => $code . '_public_key', |
|
|
522
|
+ 'name' => $code.'_public_key', |
|
523
|
523
|
'suffix' => $this->l('ex: pk_fd53cd467ba49022e4gf215e'), |
|
524
|
524
|
'type' => 'text', |
|
525
|
525
|
'size' => 60, |
|
526
|
|
- 'label' => $this->l('Public Key ' . $code), |
|
|
526
|
+ 'label' => $this->l('Public Key '.$code), |
|
527
|
527
|
'prefix' => '<i class="icon icon-key"></i>', |
|
528
|
528
|
'col' => 6, |
|
529
|
529
|
'required' => true, |
|
530
|
530
|
); |
|
531
|
531
|
$inputs[] = array( |
|
532
|
|
- 'name' => $code . '_private_key', |
|
|
532
|
+ 'name' => $code.'_private_key', |
|
533
|
533
|
'suffix' => $this->l('ex: 21e5723a97459f6a'), |
|
534
|
534
|
'type' => 'text', |
|
535
|
535
|
'size' => 60, |
|
536
|
|
- 'label' => $this->l('Private Key ' . $code), |
|
|
536
|
+ 'label' => $this->l('Private Key '.$code), |
|
537
|
537
|
'prefix' => '<i class="icon icon-key"></i>', |
|
538
|
538
|
'col' => 6, |
|
539
|
539
|
'required' => true, |
|
540
|
540
|
); |
|
541
|
541
|
if ($code !== "p4x") { |
|
542
|
542
|
$inputs[] = array( |
|
543
|
|
- 'name' => $code . '_simulator_is_enabled', |
|
544
|
|
- 'type' => (version_compare(_PS_VERSION_, '1.6')<0) ?'radio' :'switch', |
|
545
|
|
- 'label' => $this->l('Simulator is enabled ' . $code), |
|
|
543
|
+ 'name' => $code.'_simulator_is_enabled', |
|
|
544
|
+ 'type' => (version_compare(_PS_VERSION_, '1.6') < 0) ? 'radio' : 'switch', |
|
|
545
|
+ 'label' => $this->l('Simulator is enabled '.$code), |
|
546
|
546
|
'prefix' => '<i class="icon icon-key"></i>', |
|
547
|
547
|
'class' => 't', |
|
548
|
548
|
'required' => true, |
|
549
|
549
|
'values'=> array( |
|
550
|
550
|
array( |
|
551
|
|
- 'id' => $code . '_simulator_is_enabled_on', |
|
|
551
|
+ 'id' => $code.'_simulator_is_enabled_on', |
|
552
|
552
|
'value' => 1, |
|
553
|
553
|
'label' => $this->l('Yes'), |
|
554
|
554
|
), |
|
555
|
555
|
array( |
|
556
|
|
- 'id' => $code . '_simulator_is_enabled_off', |
|
|
556
|
+ 'id' => $code.'_simulator_is_enabled_off', |
|
557
|
557
|
'value' => 0, |
|
558
|
558
|
'label' => $this->l('No'), |
|
559
|
559
|
), |
|
@@ -621,17 +621,17 @@ discard block |
|
|
block discarded – undo |
|
621
|
621
|
$products = explode(',', Pagantis::getExtraConfig('PRODUCTS', null)); |
|
622
|
622
|
foreach ($products as $product) { |
|
623
|
623
|
$code = Tools::strtolower(Pagantis::getExtraConfig('CODE', $product)); |
|
624
|
|
- $settings[$code . '_public_key'] = Configuration::get($code . '_public_key'); |
|
625
|
|
- $settings[$code . '_private_key'] = Configuration::get($code . '_private_key'); |
|
626
|
|
- $settings[$code . '_is_enabled'] = Configuration::get($code . '_is_enabled'); |
|
|
624
|
+ $settings[$code.'_public_key'] = Configuration::get($code.'_public_key'); |
|
|
625
|
+ $settings[$code.'_private_key'] = Configuration::get($code.'_private_key'); |
|
|
626
|
+ $settings[$code.'_is_enabled'] = Configuration::get($code.'_is_enabled'); |
|
627
|
627
|
if ($code !== 'p4x') { |
|
628
|
|
- $settings[$code . '_simulator_is_enabled'] = Configuration::get($code . '_simulator_is_enabled'); |
|
|
628
|
+ $settings[$code.'_simulator_is_enabled'] = Configuration::get($code.'_simulator_is_enabled'); |
|
629
|
629
|
} |
|
630
|
|
- $settingsKeys[] = $code . '_is_enabled'; |
|
631
|
|
- $settingsKeys[] = $code . '_public_key'; |
|
632
|
|
- $settingsKeys[] = $code . '_private_key'; |
|
|
630
|
+ $settingsKeys[] = $code.'_is_enabled'; |
|
|
631
|
+ $settingsKeys[] = $code.'_public_key'; |
|
|
632
|
+ $settingsKeys[] = $code.'_private_key'; |
|
633
|
633
|
if ($code !== 'p4x') { |
|
634
|
|
- $settingsKeys[] = $code . '_simulator_is_enabled'; |
|
|
634
|
+ $settingsKeys[] = $code.'_simulator_is_enabled'; |
|
635
|
635
|
} |
|
636
|
636
|
} |
|
637
|
637
|
|
|
@@ -702,43 +702,43 @@ discard block |
|
|
block discarded – undo |
|
702
|
702
|
if ($this->isPaymentMethodAvailable($product)) { |
|
703
|
703
|
$productConfigs = Pagantis::getExtraConfig($product, null); |
|
704
|
704
|
$productConfigs = json_decode($productConfigs, true); |
|
705
|
|
- $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_public_key'); |
|
706
|
|
- $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_simulator_is_enabled'); |
|
707
|
|
- $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_is_enabled'); |
|
|
705
|
+ $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_public_key'); |
|
|
706
|
+ $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_simulator_is_enabled'); |
|
|
707
|
+ $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_is_enabled'); |
|
708
|
708
|
|
|
709
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_TITLE'] = $this->l($productConfigs['TITLE']); |
|
|
709
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_TITLE'] = $this->l($productConfigs['TITLE']); |
|
710
|
710
|
unset($productConfigs['TITLE']); |
|
711
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_AMOUNT'] = $orderTotal; |
|
712
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PROMOTED_AMOUNT'] = $promotedAmount; |
|
713
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOCALE'] = $this->language; |
|
714
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_COUNTRY'] = $this->language; |
|
715
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PUBLIC_KEY'] = $publicKey; |
|
716
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled; |
|
717
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_IS_ENABLED'] = $isEnabled; |
|
718
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png'; |
|
|
711
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_AMOUNT'] = $orderTotal; |
|
|
712
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PROMOTED_AMOUNT'] = $promotedAmount; |
|
|
713
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOCALE'] = $this->language; |
|
|
714
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_COUNTRY'] = $this->language; |
|
|
715
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PUBLIC_KEY'] = $publicKey; |
|
|
716
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled; |
|
|
717
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_IS_ENABLED'] = $isEnabled; |
|
|
718
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png'; |
|
719
|
719
|
$uri = $link->getModuleLink('pagantis', 'payment'); |
|
720
|
720
|
if (strpos($uri, '?') !== false) { |
|
721
|
|
- $uri .= '&product=' . $productConfigs['CODE']; |
|
|
721
|
+ $uri .= '&product='.$productConfigs['CODE']; |
|
722
|
722
|
} else { |
|
723
|
|
- $uri .= '?product=' . $productConfigs['CODE']; |
|
|
723
|
+ $uri .= '?product='.$productConfigs['CODE']; |
|
724
|
724
|
} |
|
725
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PAYMENT_URL'] = $uri; |
|
726
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3)); |
|
|
725
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PAYMENT_URL'] = $uri; |
|
|
726
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3)); |
|
727
|
727
|
|
|
728
|
728
|
foreach ($productConfigs as $productConfigKey => $productConfigValue) { |
|
729
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . "_" . $productConfigKey] = $productConfigValue; |
|
|
729
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE']))."_".$productConfigKey] = $productConfigValue; |
|
730
|
730
|
} |
|
731
|
731
|
$this->context->smarty->assign($templateConfigs); |
|
732
|
732
|
if ($supercheckout_enabled || $onepagecheckout_enabled || $onepagecheckoutps_enabled) { |
|
733
|
733
|
$this->checkLogoExists(); |
|
734
|
734
|
$return .= $this->display( |
|
735
|
735
|
__FILE__, |
|
736
|
|
- 'views/templates/hook/onepagecheckout-' . Tools::strtolower($productConfigs['CODE']) . '.tpl' |
|
|
736
|
+ 'views/templates/hook/onepagecheckout-'.Tools::strtolower($productConfigs['CODE']).'.tpl' |
|
737
|
737
|
); |
|
738
|
738
|
} elseif (_PS_VERSION_ < 1.7) { |
|
739
|
739
|
$return .= $this->display( |
|
740
|
740
|
__FILE__, |
|
741
|
|
- 'views/templates/hook/checkout-' . Tools::strtolower($productConfigs['CODE']) . '.tpl' |
|
|
741
|
+ 'views/templates/hook/checkout-'.Tools::strtolower($productConfigs['CODE']).'.tpl' |
|
742
|
742
|
); |
|
743
|
743
|
} |
|
744
|
744
|
} |
|
@@ -771,12 +771,12 @@ discard block |
|
|
block discarded – undo |
|
771
|
771
|
$productConfigs = Pagantis::getExtraConfig($product, null); |
|
772
|
772
|
$productConfigs = json_decode($productConfigs, true); |
|
773
|
773
|
|
|
774
|
|
- $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_public_key'); |
|
775
|
|
- $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_simulator_is_enabled'); |
|
|
774
|
+ $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_public_key'); |
|
|
775
|
+ $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_simulator_is_enabled'); |
|
776
|
776
|
if (Tools::strtolower($productConfigs['CODE']) === 'p4x') { |
|
777
|
777
|
$simulatorIsEnabled = true; |
|
778
|
778
|
} |
|
779
|
|
- $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_is_enabled'); |
|
|
779
|
+ $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_is_enabled'); |
|
780
|
780
|
$availableSimulators = array( |
|
781
|
781
|
'hookDisplayProductButtons' => array( |
|
782
|
782
|
'sdk.simulator.types.SIMPLE', |
|
@@ -799,30 +799,30 @@ discard block |
|
|
block discarded – undo |
|
799
|
799
|
in_array(Tools::strtolower($this->language), $allowedCountries) && |
|
800
|
800
|
(in_array($productConfigs['SIMULATOR_DISPLAY_TYPE'], $availableSimulators[$hookName]) || _PS_VERSION_ < 1.6) |
|
801
|
801
|
) { |
|
802
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_TITLE'] = $this->l($productConfigs['TITLE']); |
|
803
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_SIMULATOR_TITLE'] = $this->l($productConfigs['SIMULATOR_TITLE']); |
|
804
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_SIMULATOR_SUBTITLE'] = $this->l($productConfigs['SIMULATOR_SUBTITLE']); |
|
|
802
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_TITLE'] = $this->l($productConfigs['TITLE']); |
|
|
803
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_SIMULATOR_TITLE'] = $this->l($productConfigs['SIMULATOR_TITLE']); |
|
|
804
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_SIMULATOR_SUBTITLE'] = $this->l($productConfigs['SIMULATOR_SUBTITLE']); |
|
805
|
805
|
unset($productConfigs['TITLE']); |
|
806
|
806
|
unset($productConfigs['SIMULATOR_TITLE']); |
|
807
|
807
|
unset($productConfigs['SIMULATOR_SUBTITLE']); |
|
808
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_AMOUNT'] = $amount; |
|
809
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_AMOUNT4X'] = number_format(($amount / 4), 2, '.', ''); |
|
810
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_IS_PROMOTED_PRODUCT'] = $isPromotedProduct; |
|
811
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOCALE'] = $this->language; |
|
812
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_COUNTRY'] = $this->language; |
|
813
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PUBLIC_KEY'] = $publicKey; |
|
814
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled; |
|
815
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_IS_ENABLED'] = $isEnabled; |
|
816
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png'; |
|
817
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3)); |
|
|
808
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_AMOUNT'] = $amount; |
|
|
809
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_AMOUNT4X'] = number_format(($amount / 4), 2, '.', ''); |
|
|
810
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_IS_PROMOTED_PRODUCT'] = $isPromotedProduct; |
|
|
811
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOCALE'] = $this->language; |
|
|
812
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_COUNTRY'] = $this->language; |
|
|
813
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PUBLIC_KEY'] = $publicKey; |
|
|
814
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled; |
|
|
815
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_IS_ENABLED'] = $isEnabled; |
|
|
816
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png'; |
|
|
817
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3)); |
|
818
|
818
|
foreach ($productConfigs as $productConfigKey => $productConfigValue) { |
|
819
|
|
- $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . "_" . $productConfigKey] = $productConfigValue; |
|
|
819
|
+ $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE']))."_".$productConfigKey] = $productConfigValue; |
|
820
|
820
|
} |
|
821
|
821
|
|
|
822
|
822
|
$this->context->smarty->assign($templateConfigs); |
|
823
|
823
|
$return .= $this->display( |
|
824
|
824
|
__FILE__, |
|
825
|
|
- 'views/templates/hook/product-simulator-' . Tools::strtolower($productConfigs['CODE']) . '.tpl' |
|
|
825
|
+ 'views/templates/hook/product-simulator-'.Tools::strtolower($productConfigs['CODE']).'.tpl' |
|
826
|
826
|
); |
|
827
|
827
|
} |
|
828
|
828
|
} |
|
@@ -851,7 +851,7 @@ discard block |
|
|
block discarded – undo |
|
851
|
851
|
// $params['type'] = weight | price | after_price |
|
852
|
852
|
if (isset($params['type']) && $params['type'] === 'price' && |
|
853
|
853
|
isset($params['smarty']) && isset($params['smarty']->template_resource) && |
|
854
|
|
- (strpos($params['smarty']->template_resource, 'product.tpl') !== false || |
|
|
854
|
+ (strpos($params['smarty']->template_resource, 'product.tpl') !== false || |
|
855
|
855
|
strpos($params['smarty']->template_resource, 'product-prices.tpl') !== false) |
|
856
|
856
|
) { |
|
857
|
857
|
return $this->productPageSimulatorDisplay("hookDisplayProductPriceBlock"); |
|
@@ -884,16 +884,16 @@ discard block |
|
|
block discarded – undo |
|
884
|
884
|
if (!in_array(PROMOTIONS_CATEGORY_NAME, $categories)) { |
|
885
|
885
|
/** @var CategoryCore $category */ |
|
886
|
886
|
$category = new Category(); |
|
887
|
|
- $categoryArray = array((int)Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY ); |
|
|
887
|
+ $categoryArray = array((int) Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY); |
|
888
|
888
|
$category->is_root_category = false; |
|
889
|
889
|
$category->link_rewrite = $categoryArray; |
|
890
|
890
|
$category->meta_description = $categoryArray; |
|
891
|
891
|
$category->meta_keywords = $categoryArray; |
|
892
|
892
|
$category->meta_title = $categoryArray; |
|
893
|
|
- $category->name = array((int)Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY_NAME); |
|
|
893
|
+ $category->name = array((int) Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY_NAME); |
|
894
|
894
|
$category->id_parent = Configuration::get('PS_HOME_CATEGORY'); |
|
895
|
|
- $category->active=0; |
|
896
|
|
- $description = 'Pagantis: Products with this category have free financing assumed by the merchant. ' . |
|
|
895
|
+ $category->active = 0; |
|
|
896
|
+ $description = 'Pagantis: Products with this category have free financing assumed by the merchant. '. |
|
897
|
897
|
'Use it to promote your products or brands.'; |
|
898
|
898
|
$category->description = $this->l($description); |
|
899
|
899
|
$category->save(); |
|
@@ -913,7 +913,7 @@ discard block |
|
|
block discarded – undo |
|
913
|
913
|
} |
|
914
|
914
|
|
|
915
|
915
|
if (is_null($product)) { |
|
916
|
|
- $sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \'' . pSQL($config) . '\' limit 1'; |
|
|
916
|
+ $sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \''.pSQL($config).'\' limit 1'; |
|
917
|
917
|
if ($results = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql)) { |
|
918
|
918
|
if (is_array($results) && count($results) === 1 && isset($results[0]['value'])) { |
|
919
|
919
|
return $results[0]['value']; |
|
@@ -921,7 +921,7 @@ discard block |
|
|
block discarded – undo |
|
921
|
921
|
} |
|
922
|
922
|
} |
|
923
|
923
|
|
|
924
|
|
- $sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \'' . pSQL($product) . '\' limit 1'; |
|
|
924
|
+ $sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \''.pSQL($product).'\' limit 1'; |
|
925
|
925
|
if ($results = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql)) { |
|
926
|
926
|
if (is_array($results) && count($results) === 1 && isset($results[0]['value'])) { |
|
927
|
927
|
$configs = json_decode($results[0]['value'], true); |
|
@@ -941,10 +941,10 @@ discard block |
|
|
block discarded – undo |
|
941
|
941
|
*/ |
|
942
|
942
|
public function checkLogoExists() |
|
943
|
943
|
{ |
|
944
|
|
- $logoPg = _PS_MODULE_DIR_ . '/onepagecheckoutps/views/img/payments/pagantis.png'; |
|
945
|
|
- if (!file_exists($logoPg) && is_dir(_PS_MODULE_DIR_ . '/onepagecheckoutps/views/img/payments')) { |
|
|
944
|
+ $logoPg = _PS_MODULE_DIR_.'/onepagecheckoutps/views/img/payments/pagantis.png'; |
|
|
945
|
+ if (!file_exists($logoPg) && is_dir(_PS_MODULE_DIR_.'/onepagecheckoutps/views/img/payments')) { |
|
946
|
946
|
copy( |
|
947
|
|
- _PS_PAGANTIS_DIR . '/logo.png', |
|
|
947
|
+ _PS_PAGANTIS_DIR.'/logo.png', |
|
948
|
948
|
$logoPg |
|
949
|
949
|
); |
|
950
|
950
|
} |
|
@@ -960,7 +960,7 @@ discard block |
|
|
block discarded – undo |
|
960
|
960
|
if (count($langArray) != 2 && isset($lang['locale'])) { |
|
961
|
961
|
$langArray = explode("-", $lang['locale']); |
|
962
|
962
|
} |
|
963
|
|
- $this->language = Tools::strtoupper($langArray[count($langArray)-1]); |
|
|
963
|
+ $this->language = Tools::strtoupper($langArray[count($langArray) - 1]); |
|
964
|
964
|
// Prevent null language detection |
|
965
|
965
|
if (in_array(Tools::strtolower($this->language), $this->allowedCountries)) { |
|
966
|
966
|
return; |