Overriding Customer Data
<?php
if (!defined('_PS_VERSION_')) exit;
/**
* Module for overriding Nosto default behavior.
*
* Depends on the "Personalization for PrestaShop" module by Nosto.
*/
class MyNosto extends Module
{
/**
* Constructor.
*
* Defines the module.
*/
public function __construct()
{
$this->name = 'mynosto';
$this->tab = 'advertising_marketing';
$this->version = '0.1.0';
$this->author = 'YourName';
$this->need_instance = 1;
$this->bootstrap = true;
$this->ps_versions_compliancy = array(
'min' => '1.4',
'max' => _PS_VERSION_
);
parent::__construct();
$this->displayName = $this->l('My mini nosto plugin');
$this->description = $this->l('Module for overriding Nosto default behavior');
}
/**
* Module installer.
*
* Registers the event listener for nosto events
*
* @return bool
*/
public function install()
{
return (
parent::install()
&& $this->registerHook('actionNostoCustomerLoadAfter')
&& $this->registerHook('actionNostoOrderLoadAfter')
);
}
public function hookActionNostoCustomerLoadAfter(array $params)
{
/** @var NostoCustomer $nostoCustomer */
$nostoCustomer = $params['nosto_customer'];
//Set marketing permission for the customer, '1' or 'true' means the customer accepts newsletters
$nostoCustomer->setMarketingPermission('1');
}
public function hookactionNostoOrderLoadAfter(array $params)
{
/** @var NostoOrder $nostoOrder */
$nostoOrder = $params['nosto_order'];
//Set marketing permission for the customer, '1' or 'true' means the customer accepts newsletters
if ($nostoOrder->getCustomer() instanceof NostoOrderBuyer) {
$nostoOrder->getCustomer()->setMarketingPermission('1');
}
}
}Verifying
Last updated