// fix product comparison
This commit is contained in:
@@ -104,6 +104,9 @@ class CustomerCore extends ObjectModel
|
|||||||
/** @var boolean is the customer logged in */
|
/** @var boolean is the customer logged in */
|
||||||
public $logged = 0;
|
public $logged = 0;
|
||||||
|
|
||||||
|
/** @var int id_guest meaning the guest table, not the guest customer */
|
||||||
|
public $id_guest;
|
||||||
|
|
||||||
protected $tables = array ('customer');
|
protected $tables = array ('customer');
|
||||||
|
|
||||||
protected $fieldsRequired = array('lastname', 'passwd', 'firstname', 'email');
|
protected $fieldsRequired = array('lastname', 'passwd', 'firstname', 'email');
|
||||||
|
|||||||
@@ -186,7 +186,6 @@ class DispatcherCore
|
|||||||
$_GET['isolang'] = $m[1];
|
$_GET['isolang'] = $m[1];
|
||||||
$this->requestURI = substr($this->requestURI, 3);
|
$this->requestURI = substr($this->requestURI, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get and instantiate controller
|
// Get and instantiate controller
|
||||||
$this->getController();
|
$this->getController();
|
||||||
$controllers = Dispatcher::getControllers();
|
$controllers = Dispatcher::getControllers();
|
||||||
@@ -376,6 +375,7 @@ class DispatcherCore
|
|||||||
return $this->controller;
|
return $this->controller;
|
||||||
|
|
||||||
$controller = Tools::getValue('controller');
|
$controller = Tools::getValue('controller');
|
||||||
|
|
||||||
if (isset($controller) && preg_match('/^([0-9a-z_-]+)\?(.*)=(.*)$/Ui', $controller, $m))
|
if (isset($controller) && preg_match('/^([0-9a-z_-]+)\?(.*)=(.*)$/Ui', $controller, $m))
|
||||||
{
|
{
|
||||||
$controller = $m[1];
|
$controller = $m[1];
|
||||||
|
|||||||
@@ -150,10 +150,10 @@ class CategoryControllerCore extends FrontController
|
|||||||
'homeSize' => Image::getSize('home')
|
'homeSize' => Image::getSize('home')
|
||||||
));
|
));
|
||||||
|
|
||||||
if (isset(self::$cookie->id_customer))
|
if (isset($this->context->customer->id))
|
||||||
self::$smarty->assign('compareProducts', CompareProduct::getCustomerCompareProducts((int)self::$cookie->id_customer));
|
$this->context->smarty->assign('compareProducts', CompareProduct::getCustomerCompareProducts($this->context->customer->id));
|
||||||
elseif (isset(self::$cookie->id_guest))
|
elseif (isset($this->context->customer->id_guest))
|
||||||
self::$smarty->assign('compareProducts', CompareProduct::getGuestCompareProducts((int)self::$cookie->id_guest));
|
$this->context->smarty->assign('compareProducts', CompareProduct::getGuestCompareProducts($this->context->customer->id_guest));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,27 +47,27 @@ class CompareControllerCore extends FrontController
|
|||||||
{
|
{
|
||||||
if (Tools::getValue('action') == 'add')
|
if (Tools::getValue('action') == 'add')
|
||||||
{
|
{
|
||||||
if (isset(self::$cookie->id_customer))
|
if (isset($this->context->customer->id))
|
||||||
{
|
{
|
||||||
if(CompareProduct::getCustomerNumberProducts(self::$cookie->id_customer) < Configuration::get('PS_COMPARATOR_MAX_ITEM'))
|
if(CompareProduct::getCustomerNumberProducts($this->context->customer->id) < Configuration::get('PS_COMPARATOR_MAX_ITEM'))
|
||||||
CompareProduct::addCustomerCompareProduct((int)self::$cookie->id_customer, (int)Tools::getValue('id_product'));
|
CompareProduct::addCustomerCompareProduct((int)$this->context->customer->id, (int)Tools::getValue('id_product'));
|
||||||
else
|
else
|
||||||
die('0');
|
die('0');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((isset(self::$cookie->id_guest) AND CompareProduct::getGuestNumberProducts(self::$cookie->id_guest) < Configuration::get('PS_COMPARATOR_MAX_ITEM')))
|
if ((isset($this->context->customer->id_guest) AND CompareProduct::getGuestNumberProducts($this->context->customer->id_guest) < Configuration::get('PS_COMPARATOR_MAX_ITEM')))
|
||||||
CompareProduct::addGuestCompareProduct((int)self::$cookie->id_guest, (int)Tools::getValue('id_product'));
|
CompareProduct::addGuestCompareProduct((int)$this->context->customer->id_guest, (int)Tools::getValue('id_product'));
|
||||||
else
|
else
|
||||||
die('0');
|
die('0');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif (Tools::getValue('action') == 'remove')
|
elseif (Tools::getValue('action') == 'remove')
|
||||||
{
|
{
|
||||||
if (isset(self::$cookie->id_customer))
|
if (isset($this->context->customer->id))
|
||||||
CompareProduct::removeCustomerCompareProduct((int)self::$cookie->id_customer, (int)Tools::getValue('id_product'));
|
CompareProduct::removeCustomerCompareProduct((int)$this->context->customer->id, (int)Tools::getValue('id_product'));
|
||||||
elseif (isset(self::$cookie->id_guest))
|
elseif (isset($this->context->customer->id_guest))
|
||||||
CompareProduct::removeGuestCompareProduct((int)self::$cookie->id_guest, (int)Tools::getValue('id_product'));
|
CompareProduct::removeGuestCompareProduct((int)$this->context->customer->id_guest, (int)Tools::getValue('id_product'));
|
||||||
else
|
else
|
||||||
die('0');
|
die('0');
|
||||||
}
|
}
|
||||||
@@ -92,10 +92,10 @@ class CompareControllerCore extends FrontController
|
|||||||
|
|
||||||
if ($product_list = Tools::getValue('compare_product_list') AND $postProducts = (isset($product_list) ? rtrim($product_list,'|') : ''))
|
if ($product_list = Tools::getValue('compare_product_list') AND $postProducts = (isset($product_list) ? rtrim($product_list,'|') : ''))
|
||||||
$ids = array_unique(explode('|', $postProducts));
|
$ids = array_unique(explode('|', $postProducts));
|
||||||
elseif (isset(self::$cookie->id_customer))
|
elseif (isset($this->context->customer->id))
|
||||||
$ids = CompareProduct::getCustomerCompareProducts(self::$cookie->id_customer);
|
$ids = CompareProduct::getCustomerCompareProducts($this->context->customer->id);
|
||||||
elseif(isset(self::$cookie->id_guest))
|
elseif(isset($this->context->customer->id_guest))
|
||||||
$ids = CompareProduct::getGuestCompareProducts(self::$cookie->id_guest);
|
$ids = CompareProduct::getGuestCompareProducts($this->context->customer->id_guest);
|
||||||
else
|
else
|
||||||
$ids = null;
|
$ids = null;
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ $('document').ready(function(){
|
|||||||
var idProduct = $(this).attr('rel').replace('ajax_id_product_', '');
|
var idProduct = $(this).attr('rel').replace('ajax_id_product_', '');
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'products-comparison.php?ajax=1&action=remove&id_product=' + idProduct,
|
url: 'index.php?controller=products-comparison&ajax=1&action=remove&id_product=' + idProduct,
|
||||||
async: false,
|
async: false,
|
||||||
success: function(){
|
success: function(){
|
||||||
return true;
|
return true;
|
||||||
@@ -46,7 +46,7 @@ $('document').ready(function(){
|
|||||||
if(checkbox.is(':checked'))
|
if(checkbox.is(':checked'))
|
||||||
{
|
{
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'products-comparison.php?ajax=1&action=add&id_product=' + idProduct,
|
url: 'index.php?controller=products-comparison&ajax=1&action=add&id_product=' + idProduct,
|
||||||
async: true,
|
async: true,
|
||||||
success: function(data){
|
success: function(data){
|
||||||
if (data == '0')
|
if (data == '0')
|
||||||
@@ -63,7 +63,7 @@ $('document').ready(function(){
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'products-comparison.php?ajax=1&action=remove&id_product=' + idProduct,
|
url: 'index.php?controller=products-comparison&ajax=1&action=remove&id_product=' + idProduct,
|
||||||
async: true,
|
async: true,
|
||||||
success: function(data){
|
success: function(data){
|
||||||
if (data == '0')
|
if (data == '0')
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
var max_item = "{l s='You cannot add more than' js=1} {$comparator_max_item} {l s='product(s) in the product comparator' js=1}";
|
var max_item = "{l s='You cannot add more than' js=1} {$comparator_max_item} {l s='product(s) in the product comparator' js=1}";
|
||||||
//]]>
|
//]]>
|
||||||
</script>
|
</script>
|
||||||
<form method="get" action="{$link->getPageLink('products-comparison', true)}" onsubmit="true">
|
<form method="post" action="{$link->getPageLink('products-comparison', true)}" onsubmit="true">
|
||||||
<p>
|
<p>
|
||||||
<input type="submit" class="button" value="{l s='Compare'}" style="float:right" />
|
<input type="submit" class="button" value="{l s='Compare'}" style="float:right" />
|
||||||
<input type="hidden" name="compare_product_list" class="compare_product_list" value="" />
|
<input type="hidden" name="compare_product_list" class="compare_product_list" value="" />
|
||||||
|
|||||||
Reference in New Issue
Block a user