48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
|
<?php
|
||
|
if (!defined('_CAN_LOAD_FILES_'))
|
||
|
exit;
|
||
|
|
||
|
class Antadis_Cross_Selling extends Module
|
||
|
{
|
||
|
public function __construct()
|
||
|
{
|
||
|
$this->name = 'antadis_cross_selling';
|
||
|
$this->tab = 'administration';
|
||
|
$this->version = '1.0';
|
||
|
$this->author = 'Antadis';
|
||
|
|
||
|
parent::__construct();
|
||
|
|
||
|
$this->displayName = $this->l('Antadis Cross Selling');
|
||
|
$this->description = $this->l('Ajouter un élément au panier.');
|
||
|
$this->secure_key = Tools::encrypt($this->name);
|
||
|
|
||
|
$this->confirmUninstall = $this->l('Are you sure ?');
|
||
|
}
|
||
|
|
||
|
public function install()
|
||
|
{
|
||
|
return parent::install() && $this->registerHook('displayProductLineShoppingCart');
|
||
|
}
|
||
|
|
||
|
public function hookdisplayProductLineShoppingCart($params)
|
||
|
{
|
||
|
$id_product = 34;
|
||
|
$cart = Context::getContext()->cart;
|
||
|
$product = new Product($id_product, true, Context::getContext()->language->id);
|
||
|
$image = Image::getCover($product->id);
|
||
|
$product->id_image = $image['id_image'];
|
||
|
|
||
|
|
||
|
if (empty($cart->containsProduct($product->id))) {
|
||
|
$this->context->smarty->assign(
|
||
|
array(
|
||
|
'product' => $product
|
||
|
)
|
||
|
);
|
||
|
return $this->display(__FILE__, 'cartCrossSelling.tpl');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|