https://medium.com/@lmeyer./get-an-error-free-e-commerce-web-site-using-sentry-b6061264efc8...
Prestashop 1.7 - Alerte du marchand quand retour produits
Alerte par email demande de retour produits
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
class baba_alertforrefund extends Module
{
public function __construct()
{
$this->name = 'baba_alertforrefund';
$this->tab = 'others';
$this->version = '1.0.0';
$this->author = 'presta.cafe';
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('baba_alertforrefund');
$this->description = $this->l('Add mail alert for refund');
}
/**
* Installation du module
* @return bool
*/
public function install()
{
if (!parent::install()
|| !$this->registerHook([
'actionObjectOrderReturnAddAfter',
])
) {
return false;
}
return true;
}
/**
* Désinstallation du module
* @return bool
*/
public function uninstall()
{
if (
!parent::uninstall()
) {
return false;
}
return true;
}
/**
* Envoie de l'email après l'ajout d'un retour
* @return bool
*/
public function hookActionObjectOrderReturnAddAfter($params)
{
$order = new Order((int)$params['object']->id_order);
$customer = new Customer((int)$params['object']->id_customer);
$var_list = [
'{customer_firstname}' => $customer->firstname,
'{customer_lastname}' => $customer->lastname,
'{shop_name}' => Configuration::get('PS_SHOP_NAME'),
'{order_reference}' => $order->reference,
'{comment}' => $params['object']->question,
];
if (
!Mail::Send(
$this->context->language->id,
'refund',
$this->trans('Nouvelle demande de retour', [], 'Emails.Subject'),
$var_list,
Configuration::get('PS_SHOP_EMAIL'),
Configuration::get('PS_SHOP_NAME'),
null,
null,
null,
null,
_PS_MODULE_DIR_.'baba_alertforrefund/mails',
false,
null,
null,
$customer->email,
)) {
return false;
}
return true;
}
}
Publié dans:
Aide Prestashop
Laissez un commentaire