How to add Digioh JavaScript to PrestaShop

PrestaShop is an online platform that allows users to create an e-commerce presence, enabling them to sell products and services through the web to an online audience.

Follow these steps to install the Digioh JavaScript on your PrestaShop site.

1) Get the Digioh Script

Log into your Digioh account and copy the JavaScript snippet.

2. Add script to PrestaShop

Go to [Your Website] => ./controllers/front/IndexController.php

Inside initContent() function paste this code:

$this->context->controller->registerJavascript(
'monurl',
'https://js.example.com/files/test.js', // Your external javascript file
array('server' => 'remote', 'position' => 'bottom', 'priority' => 150)
);

Note: Replace the JS file link Digioh Script link

Also note that [‘server’ => ‘remote’] is the required attribute, otherwise your remote file will not work

Replace the URL in the 2nd attribute with your JavaScript file

The initContent() function will look like this:

public function initContent()
 {
 parent::initContent();
 $this->context->controller->registerJavascript(
 'monurl',
 'https://js.example.com/files/test.js', // Your external javascript file
 array('server' => 'remote', 'position' => 'bottom', 'priority' => 150)
);
 $this->context->smarty->assign([
 'HOOK_HOME' => Hook::exec('displayHome'),
 ]);
 $this->setTemplate('index'); 
 }

The Digioh JavaScript is now added to your PrestaShop site.

If you have any questions about adding Digioh to PrestaShop, send us a message.