Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loaded web component code #4

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions prestashopdevcon.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,22 @@ public function install()
&& $this->registerHook('displayHome')
&& $this->registerHook('displayCheckoutSummaryTop')
&& $this->registerHook('actionDispatcherBefore')
&& $this->registerHook('displayShoppingCartFooter');
&& $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";
Expand All @@ -36,7 +44,9 @@ public function hookActionDispatcherBefore()

public function hookDisplayHome()
{
return "Hello from {$this->name}!";
return $this->context->smarty->fetch(
"{$this->getLocalPath()}/views/templates/home.tpl"
);
}

public function hookDisplayCheckoutSummaryTop()
Expand Down
1 change: 1 addition & 0 deletions views/templates/header.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<script type="module" src="https://cdn.skypack.dev/invertus-prestashopdevcon2023-sample"></script>
3 changes: 3 additions & 0 deletions views/templates/home.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<inv-counter>
This button is loaded using web components. Your number is:
</inv-counter>
Loading