Skip to content
This repository was archived by the owner on Nov 12, 2019. It is now read-only.

Commit 90a65db

Browse files
committed
[+] MO : Added product tooltips module (Show how many people are watching a product page, last sale and last cart add)
1 parent 70780f7 commit 90a65db

File tree

8 files changed

+318
-1
lines changed

8 files changed

+318
-1
lines changed

css/jquery.jgrowl.css

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
2+
div.jGrowl {
3+
padding: 10px;
4+
z-index: 9999;
5+
}
6+
7+
/** Special IE6 Style Positioning **/
8+
div.ie6 {
9+
position: absolute;
10+
}
11+
12+
div.ie6.top-right {
13+
right: auto;
14+
bottom: auto;
15+
left: expression( ( 0 - jGrowl.offsetWidth + ( document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth ) + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + 'px' );
16+
top: expression( ( 0 + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );
17+
}
18+
19+
div.ie6.top-left {
20+
left: expression( ( 0 + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + 'px' );
21+
top: expression( ( 0 + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );
22+
}
23+
24+
div.ie6.bottom-right {
25+
left: expression( ( 0 - jGrowl.offsetWidth + ( document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth ) + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + 'px' );
26+
top: expression( ( 0 - jGrowl.offsetHeight + ( document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );
27+
}
28+
29+
div.ie6.bottom-left {
30+
left: expression( ( 0 + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + 'px' );
31+
top: expression( ( 0 - jGrowl.offsetHeight + ( document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );
32+
}
33+
34+
div.ie6.center {
35+
left: expression( ( 0 + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + 'px' );
36+
top: expression( ( 0 + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );
37+
width: 100%;
38+
}
39+
40+
/** Normal Style Positions **/
41+
body > div.jGrowl {
42+
position: fixed;
43+
}
44+
45+
body > div.jGrowl.top-left {
46+
left: 0px;
47+
top: 0px;
48+
}
49+
50+
body > div.jGrowl.top-right {
51+
right: 0px;
52+
top: 0px;
53+
}
54+
55+
body > div.jGrowl.bottom-left {
56+
left: 0px;
57+
bottom: 0px;
58+
}
59+
60+
body > div.jGrowl.bottom-right {
61+
right: 0px;
62+
bottom: 0px;
63+
}
64+
65+
body > div.jGrowl.center {
66+
top: 0px;
67+
width: 50%;
68+
left: 25%;
69+
}
70+
71+
/** Cross Browser Styling **/
72+
div.center div.jGrowl-notification, div.center div.jGrowl-closer {
73+
margin-left: auto;
74+
margin-right: auto;
75+
}
76+
77+
div.jGrowl div.jGrowl-notification, div.jGrowl div.jGrowl-closer {
78+
background-color: #000;
79+
color: #fff;
80+
opacity: .85;
81+
filter: alpha(opacity = 85);
82+
zoom: 1;
83+
width: 235px;
84+
padding: 10px;
85+
margin-top: 5px;
86+
margin-bottom: 5px;
87+
font-family: Tahoma, Arial, Helvetica, sans-serif;
88+
font-size: 12px;
89+
text-align: left;
90+
display: none;
91+
-moz-border-radius: 5px;
92+
-webkit-border-radius: 5px;
93+
}
94+
95+
div.jGrowl div.jGrowl-notification {
96+
min-height: 40px;
97+
}
98+
99+
div.jGrowl div.jGrowl-notification div.header {
100+
font-weight: bold;
101+
font-size: 10px;
102+
}
103+
104+
div.jGrowl div.jGrowl-notification div.close {
105+
z-index: 99;
106+
float: right;
107+
font-weight: bold;
108+
font-size: 12px;
109+
cursor: pointer;
110+
}
111+
112+
div.jGrowl div.jGrowl-closer {
113+
height: 15px;
114+
padding-top: 4px;
115+
padding-bottom: 4px;
116+
cursor: pointer;
117+
font-size: 11px;
118+
font-weight: bold;
119+
text-align: center;
120+
}
121+
122+
/** Hide jGrowl when printing **/
123+
@media print {
124+
div.jGrowl {
125+
display: none;
126+
}
127+
}

js/jquery/jquery.jgrowl-1.2.1.min.js

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/paypal/fr.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
$_MODULE['<{paypal}prestashop>paypal_bafd7322c6e97d25b6299b5d6fe8920b'] = 'Non';
3232
$_MODULE['<{paypal}prestashop>paypal_ee0174ba1fc039128d0a38074a7af945'] = 'URL de l\'image bannière';
3333
$_MODULE['<{paypal}prestashop>paypal_33887e395a8999be7ccc921fbcccf199'] = 'Cette image doit être hébergée sur un serveur sécurisé pour ne pas afficher d\'avertissement. Sa taille doit être limitée à 750x90px.';
34-
$_MODULE['<{paypal}prestashop>paypal_b17f3f4dcf653a5776792498a9b44d6a'] = 'Mise à jour des réglages';
34+
$_MODULE['<{paypal}prestashop>paypal_b17f3f4dcf653a5776792498a9b44d6a'] = 'Mettre à jour les paramètres';
3535
$_MODULE['<{paypal}prestashop>paypal_a82be0f551b8708bc08eb33cd9ded0cf'] = 'Information';
3636
$_MODULE['<{paypal}prestashop>paypal_8a4a5d8b35abe529250d8167c3035014'] = 'Afin d\'utiliser le module PayPal, vous devez configurer votre compte PayPal. Connectez-vous sur votre compte et suivez ces instructions.';
3737
$_MODULE['<{paypal}prestashop>paypal_efeb369cccbd560588a756610865664c'] = 'Dans';

modules/producttooltip/fr.php

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
global $_MODULE;
4+
$_MODULE = array();
5+
$_MODULE['<{producttooltip}prestashop>producttooltip_4776f7eb5998034f7bbc63b6457d1ff4'] = 'Infobulles produit';
6+
$_MODULE['<{producttooltip}prestashop>producttooltip_f4fe2ee6c6c8e0f1b13c02d6dd2c4b99'] = 'Affiche combien de personnes consultent un produit ainsi que les dates de dernière commande ou ajout au panier';
7+
$_MODULE['<{producttooltip}prestashop>producttooltip_e548d0d6a94a27306b8b31472a3e5ec3'] = 'Afficher le nombre de personnes qui consultent la fiche produit ?';
8+
$_MODULE['<{producttooltip}prestashop>producttooltip_93cba07454f06a4a960172bbd6e2a435'] = 'Oui';
9+
$_MODULE['<{producttooltip}prestashop>producttooltip_bafd7322c6e97d25b6299b5d6fe8920b'] = 'Non';
10+
$_MODULE['<{producttooltip}prestashop>producttooltip_2c8de3180924949acc5f6250af689802'] = 'Période de validité :';
11+
$_MODULE['<{producttooltip}prestashop>producttooltip_640fd0cc0ffa0316ae087652871f4486'] = 'minutes';
12+
$_MODULE['<{producttooltip}prestashop>producttooltip_1e358b149c2d4105f3a74c1961d1d9fb'] = 'Afficher la date de la dernière commande ?';
13+
$_MODULE['<{producttooltip}prestashop>producttooltip_011b9877bbda2534eefeb3cb6ab3594f'] = 'Si aucune commande à afficher, afficher la date du dernier ajout au panier ?';
14+
$_MODULE['<{producttooltip}prestashop>producttooltip_a536f110cc080569666e95e8f49fda9b'] = 'Ne pas afficher les événements datant de plus de :';
15+
$_MODULE['<{producttooltip}prestashop>producttooltip_44fdec47036f482b68b748f9d786801b'] = 'jours';
16+
$_MODULE['<{producttooltip}prestashop>producttooltip_b17f3f4dcf653a5776792498a9b44d6a'] = 'Mettre à jour les paramètres';
17+
$_MODULE['<{producttooltip}prestashop>producttooltip_f0f5fac9602d88bc27f0edf960dda8b8'] = 'Exemple :';
18+
$_MODULE['<{producttooltip}prestashop>producttooltip_975f3743bcce9c5a2e30001aab592fb1'] = 'personne regarde actuellement';
19+
$_MODULE['<{producttooltip}prestashop>producttooltip_e1a1dc1574c9f178c14e2952351aa47d'] = 'personnes regardent actuellement';
20+
$_MODULE['<{producttooltip}prestashop>producttooltip_d296e0c3a7dffc0f4d02574bd502653f'] = 'ce produit';
21+
$_MODULE['<{producttooltip}prestashop>producttooltip_71736c614b237f4368128077411f1699'] = 'Ce produit a été acheté dernièrement le';
22+
$_MODULE['<{producttooltip}prestashop>producttooltip_4dda321f0231c2d50fcee5c20075dbbd'] = 'Ce produit a été ajouté au panier dernièrement le';

modules/producttooltip/logo.gif

359 Bytes
Loading
+156
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<?php
2+
3+
class ProductToolTip extends Module
4+
{
5+
public function __construct()
6+
{
7+
$this->name = 'producttooltip';
8+
$this->tab = 'Products';
9+
$this->version = '1.0';
10+
11+
parent::__construct();
12+
13+
$this->displayName = $this->l('Product tooltips');
14+
$this->description = $this->l('Show how many people are watching a product page, last sale and last cart add');
15+
}
16+
17+
public function install()
18+
{
19+
if (!parent::install())
20+
return false;
21+
22+
/* Default configuration values */
23+
Configuration::updateValue('PS_PTOOLTIP_PEOPLE', 1);
24+
Configuration::updateValue('PS_PTOOLTIP_DATE_CART', 1);
25+
Configuration::updateValue('PS_PTOOLTIP_DATE_ORDER', 1);
26+
Configuration::updateValue('PS_PTOOLTIP_DAYS', 3);
27+
Configuration::updateValue('PS_PTOOLTIP_LIFETIME', 30);
28+
29+
return $this->registerHook('productfooter');
30+
}
31+
32+
public function uninstall()
33+
{
34+
if (!Configuration::deleteByName('PS_PTOOLTIP_PEOPLE')
35+
OR !Configuration::deleteByName('PS_PTOOLTIP_DATE_CART')
36+
OR !Configuration::deleteByName('PS_PTOOLTIP_DATE_ORDER')
37+
OR !Configuration::deleteByName('PS_PTOOLTIP_DAYS')
38+
OR !Configuration::deleteByName('PS_PTOOLTIP_LIFETIME')
39+
OR !parent::uninstall())
40+
return false;
41+
return true;
42+
}
43+
44+
public function getContent()
45+
{
46+
/* Update values in DB */
47+
if (isset($_POST['SubmitToolTip']))
48+
{
49+
Configuration::updateValue('PS_PTOOLTIP_PEOPLE', intval($_POST['ps_ptooltip_people']));
50+
Configuration::updateValue('PS_PTOOLTIP_DATE_CART', intval($_POST['ps_ptooltip_date_cart']));
51+
Configuration::updateValue('PS_PTOOLTIP_DATE_ORDER', intval($_POST['ps_ptooltip_date_order']));
52+
Configuration::updateValue('PS_PTOOLTIP_DAYS', intval($_POST['ps_ptooltip_days']));
53+
Configuration::updateValue('PS_PTOOLTIP_LIFETIME', intval($_POST['ps_ptooltip_lifetime']));
54+
}
55+
56+
/* Configuration form */
57+
$output = '
58+
<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
59+
<fieldset class="width2" style="float: left;">
60+
<legend><img src="'.__PS_BASE_URI__.'modules/producttooltip/logo.gif" alt="" />'.$this->l('Product tooltips').'</legend>
61+
<p>
62+
'.$this->l('Display the number of people who are currently watching this product?').'<br /><br />
63+
<img src="'._PS_ADMIN_IMG_.'enabled.gif" alt="" /><input type="radio" name="ps_ptooltip_people" value="1"'.(Configuration::get('PS_PTOOLTIP_PEOPLE') ? ' checked="checked"' : '').' style="vertical-align: middle;" /> '.$this->l('Yes').'
64+
&nbsp;<img src="'._PS_ADMIN_IMG_.'disabled.gif" alt="" /><input type="radio" name="ps_ptooltip_people" value="0"'.(!Configuration::get('PS_PTOOLTIP_PEOPLE') ? ' checked="checked"' : '').' style="vertical-align: middle;" /> '.$this->l('No').'<br />
65+
66+
</p>
67+
<p>
68+
'.$this->l('Lifetime:').'
69+
<input type="text" name="ps_ptooltip_lifetime" style="width: 30px;" value="'.intval(Configuration::get('PS_PTOOLTIP_LIFETIME')).'" /> '.$this->l('minutes').'<br />
70+
</p>
71+
<hr size="1" noshade />
72+
<p>
73+
'.$this->l('Display the last time the product has been ordered?').'<br /><br />
74+
<img src="'._PS_ADMIN_IMG_.'enabled.gif" alt="" /><input type="radio" name="ps_ptooltip_date_order" value="1"'.(Configuration::get('PS_PTOOLTIP_DATE_ORDER') ? ' checked="checked"' : '').' style="vertical-align: middle;" /> '.$this->l('Yes').'
75+
&nbsp;<img src="'._PS_ADMIN_IMG_.'disabled.gif" alt="" /><input type="radio" name="ps_ptooltip_date_order" value="0"'.(!Configuration::get('PS_PTOOLTIP_DATE_ORDER') ? ' checked="checked"' : '').' style="vertical-align: middle;" /> '.$this->l('No').'<br /><br />
76+
</p>
77+
<p>
78+
'.$this->l('If no order yet, display the last time the product has been added to cart?').'<br /><br />
79+
<img src="'._PS_ADMIN_IMG_.'enabled.gif" alt="" /><input type="radio" name="ps_ptooltip_date_cart" value="1"'.(Configuration::get('PS_PTOOLTIP_DATE_CART') ? ' checked="checked"' : '').' style="vertical-align: middle;" /> '.$this->l('Yes').'
80+
&nbsp;<img src="'._PS_ADMIN_IMG_.'disabled.gif" alt="" /><input type="radio" name="ps_ptooltip_date_cart" value="0"'.(!Configuration::get('PS_PTOOLTIP_DATE_CART') ? ' checked="checked"' : '').' style="vertical-align: middle;" /> '.$this->l('No').'<br /><br />
81+
82+
</p>
83+
<p>
84+
'.$this->l('Do not display events older than:').'
85+
<input type="text" name="ps_ptooltip_days" style="width: 30px;" value="'.intval(Configuration::get('PS_PTOOLTIP_DAYS')).'" /> '.$this->l('days').'<br />
86+
</p>
87+
<hr size="1" noshade />
88+
<center><input type="submit" name="SubmitToolTip" class="button" value="'.$this->l('Update settings').'" style="margin-top: 10px;" /></center>
89+
</fieldset>
90+
<p style="float: left; margin: 10px 0 0 30px;">
91+
<b>'.$this->l('Sample:').'</b><br />
92+
<img src="'.__PS_BASE_URI__.'modules/producttooltip/sample.gif" style="margin-top: 10px;" />
93+
</p>
94+
<div style="clear: both; font-size: 0;"></div>
95+
</form>';
96+
97+
return $output;
98+
}
99+
100+
public function hookProductFooter($params)
101+
{
102+
global $smarty, $cookie;
103+
104+
$id_product = intval($params['product']->id);
105+
106+
/* First we try to display the number of people who are currently watching this product page */
107+
if (Configuration::get('PS_PTOOLTIP_PEOPLE'))
108+
{
109+
$date = strftime('%Y-%m-%d %H:%M:%S' , time() - intval(Configuration::get('PS_PTOOLTIP_LIFETIME') * 60));
110+
111+
$nbPeople = Db::getInstance()->getRow('
112+
SELECT COUNT(DISTINCT(id_connections)) nb
113+
FROM '._DB_PREFIX_.'page p
114+
LEFT JOIN '._DB_PREFIX_.'connections_page cp ON (p.id_page = cp.id_page)
115+
WHERE p.id_page_type = 1 AND p.id_object = '.intval($id_product).' AND cp.time_start > \''.$date.'\'');
116+
117+
if (isset($nbPeople['nb']) AND $nbPeople['nb'] > 0)
118+
$smarty->assign('nb_people', intval($nbPeople['nb']));
119+
}
120+
121+
/* Then, we try to display last sale */
122+
if (Configuration::get('PS_PTOOLTIP_DATE_ORDER'))
123+
{
124+
$days = intval(Configuration::get('PS_PTOOLTIP_DAYS'));
125+
$date = strftime('%Y-%m-%d' , strtotime('-'.intval($days).' day'));
126+
127+
$order = Db::getInstance()->getRow('
128+
SELECT o.date_add
129+
FROM '._DB_PREFIX_.'order_detail od
130+
LEFT JOIN '._DB_PREFIX_.'orders o ON (od.id_order = o.id_order)
131+
WHERE od.product_id = '.intval($id_product).' AND o.date_add >= \''.$date.'\'');
132+
133+
if (isset($order['date_add']))
134+
$smarty->assign('date_last_order', $order['date_add']);
135+
else
136+
{
137+
/* No sale? display last cart add instead */
138+
if (Configuration::get('PS_PTOOLTIP_DATE_CART'))
139+
{
140+
$cart = Db::getInstance()->getRow('
141+
SELECT cp.date_add
142+
FROM '._DB_PREFIX_.'cart_product cp
143+
WHERE cp.id_product = '.intval($id_product));
144+
145+
if (isset($cart['date_add']))
146+
$smarty->assign('date_last_cart', $cart['date_add']);
147+
}
148+
}
149+
}
150+
151+
if ((isset($nbPeople['nb']) AND $nbPeople['nb'] > 0) OR isset($order['date_add']) OR isset($cart['date_add']))
152+
return $this->display(__FILE__, 'producttooltip.tpl');
153+
}
154+
}
155+
156+
?>

0 commit comments

Comments
 (0)