-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprestashopdevcon.php
executable file
·74 lines (62 loc) · 2.2 KB
/
prestashopdevcon.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
use Dotenv\Dotenv;
use Invertus\Prestashopdevcon\ServiceProvider\ServiceProvider;
use Invertus\Prestashopdevcon\Services\PaymentProvider;
class PrestashopDevCon extends PaymentModule
{
public function __construct()
{
$this->name = 'prestashopdevcon';
$this->author = 'Invertus';
parent::__construct();
}
public function install()
{
return parent::install()
&& $this->registerHook('displayHome')
&& $this->registerHook('displayCheckoutSummaryTop')
&& $this->registerHook('actionDispatcherBefore')
&& $this->registerHook('displayShoppingCartFooter')
&& $this->registerHook('header');
}
public function get($serviceName)
{
return (new ServiceProvider())->getService($serviceName);
}
public function hookHeader()
{
return $this->context->smarty->fetch(
"{$this->getLocalPath()}/views/templates/header.tpl"
);
}
public function hookActionDispatcherBefore()
{
include_once _PS_MODULE_DIR_ . $this->name . '/' . "vendor/autoload.php";
$dotenv = Dotenv::createImmutable($this->getLocalPath());
$dotenv->load();
}
public function hookDisplayHome()
{
return $this->context->smarty->fetch(
"{$this->getLocalPath()}/views/templates/home.tpl"
);
}
public function hookDisplayCheckoutSummaryTop()
{
$text = "";
if ($this->context->controller instanceof OrderControllerCore && method_exists($this->context->controller, 'getCheckoutProcess')) {
$checkoutProcess = $this->context->controller->getCheckoutProcess();
$text .= "We are currently at step: " . $checkoutProcess->getCurrentStep()->getTitle();
}
return $text;
}
public function hookDisplayShoppingCartFooter()
{
/** @var PaymentProvider $paymentProvider */
$paymentProvider = $this->get(PaymentProvider::class);
$this->context->smarty->assign([ "creditCardsNames" => $paymentProvider->getCardNames()]);
return $this->context->smarty->fetch(
"{$this->getLocalPath()}/views/templates/cartFooter.tpl"
);
}
}