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