63 lines
1.8 KiB
PHP
Raw Normal View History

2016-09-13 15:10:50 +02:00
<?php
if (!defined('_PS_VERSION_'))
exit;
class Affilnet extends Module
{
public function __construct()
{
$this->name = 'affilnet';
$this->tab = 'analytics_stats';
$this->version = '1.0.0';
$this->author = 'Antadis';
$this->displayName = 'Affilnet analytics';
$this->module_key = 'fd2aaefea84ac1bb512e6f1878d990b8';
parent::__construct();
$this->description = $this->l('Affilnet analytics');
$this->confirmUninstall = $this->l('Are you sure you want to delete your details ?');
}
public function install()
{
return (parent::install() && $this->registerHook('actionCustomerAccountAdd') && $this->registerHook('orderConfirmation'));
}
public function hookActionCustomerAccountAdd($params)
{
$customer = $params['newCustomer'];
if (Validate::isLoadedObject($customer)) {
$this->context->smarty->assign('email', $customer->email);
$this->context->smarty->assign('status', $params['_POST']['check_b2b'] == 1 ? 'professionnel' : 'particulier');
2016-09-15 16:28:35 +02:00
return $this->display(__FILE__, 'authentication.tpl');
2016-09-13 15:10:50 +02:00
}
}
public function hookOrderConfirmation($params)
{
2016-09-15 16:28:35 +02:00
$order = $params['objOrder'];
if (Validate::isLoadedObject($order)) {
$customer = new Customer($order->id_customer);
$discounts = $order->getDiscounts();
$ids_discount = '';
for ($i = 0 ; $i <= count($discounts); $i++) {
$ids_discount .= $discounts[$i]['id_cart_rule'];
if ($i < count($discounts) - 1) {
$ids_discount .= ':';
}
}
$this->context->smarty->assign(array(
'id_order', $order->id,
'total_paid_wt_ws', $order->total_paid_tax_excl - $order->total_shipping_tax_excl,//PRICE = NO TAX AND NO SHIPPING
'status' => $customer->pro == 1 ? 'professionnel' : 'particulier',
'payment_method' => $order->payment,
'ids_discount' => $ids_discount
));
return $this->display(__FILE__, 'order-confirmation.tpl');
}
2016-09-13 15:10:50 +02:00
}
}