Jump to content

Group discount doesn't work


Recommended Posts

I have a group called 10% discount.
I have a client placed in the groups: Default and 10% discount.

And the category to which the rebate applies (when a customer logs) in the group: 10% discount.

But the discount is not calculated on the products in that category!?

HELP (you have the solution you get a fee of course!)

PS Version: 1.3.1.1


Stefan

Link to comment
Share on other sites

Topic renamed - please don't write in caps or write the word "help" in the title

The customer must be in the default group to see the products. The only reason I can think that it wouldn't work would be if you are using an old third-party theme that was created for a version of PrestaShop that didn't have group discounts. Try switching to the default PrestaShop v1.3.1 theme to check for sure.

Link to comment
Share on other sites

The file product.php should pass the group reduction amount into product.tpl, which puts it in a Javascript variable. You need to check that value to make sure it isn't 1. It is line 204 in product.php (in PrestaShop v1.3.1):

'group_reduction' => (100 - Group::getReduction(intval($cookie->id_customer))) / 100,



Which is then used to create a Javascript variable on line 30 of product.tpl:

var group_reduction = '{$group_reduction}';



You can view the source code of your product page in your browser to see the value of group_reduction. If it is 1, then you know something is going wrong in the Group::getReduction(intval($cookie->id_customer)) call. Either the customer ID is wrong or the link between the customer ID and group reduction is broken.

Link to comment
Share on other sites

I have checked that files right now, the are the same as this code above.

BUT, my source code when I watch a product on the product.tpl page looks like this:

var reduction_percent = 0;
var reduction_price = 0;
var reduction_from = '2010-07-08 00:00:00';
var reduction_to = '2010-07-08 00:00:00';
var group_reduction = '1';


What now?
I see the value 0 two times?

Link to comment
Share on other sites

Sorry, I meant 1, not 0. I've corrected my post above.

var group_reduction = '1';



That confirms that the group reduction isn't working. That value should be 0.9, not 1. You need to debug the getReduction() function on line 87 of classes/Group.php on line 87:

static public function getReduction($id_customer = NULL)
{
   if ($id_customer)
       $customer = new Customer(intval($id_customer));
   return Db::getInstance()->getValue('
   SELECT `reduction`
   FROM `'._DB_PREFIX_.'group`
   WHERE `id_group` = '.((isset($customer) AND Validate::isLoadedObject($customer)) ? intval($customer->id_default_group) : 1));
}



Check the value of $id_customer to make sure it is valid by adding the following after the {:

echo 'Group::getReduction(' . $id_customer . ')';



This should display when you refresh your product page. Post the result here.

Link to comment
Share on other sites

Change:

static public function getReduction($id_customer = NULL)
{
   if ($id_customer)
       $customer = new Customer(intval($id_customer));
   return Db::getInstance()->getValue('
   SELECT `reduction`
   FROM `'._DB_PREFIX_.'group`
   WHERE `id_group` = '.((isset($customer) AND Validate::isLoadedObject($customer)) ? intval($customer->id_default_group) : 1));
}



to:

static public function getReduction($id_customer = NULL)
{
   echo 'Group::getReduction(' . $id_customer . ')';
   if ($id_customer)
       $customer = new Customer(intval($id_customer));
   return Db::getInstance()->getValue('
   SELECT `reduction`
   FROM `'._DB_PREFIX_.'group`
   WHERE `id_group` = '.((isset($customer) AND Validate::isLoadedObject($customer)) ? intval($customer->id_default_group) : 1));
}

Link to comment
Share on other sites

Well, that tells us that the customer ID is working, assuming that customer 1 was logged in when that message was displayed. It must be a database issue. Try changing:

static public function getReduction($id_customer = NULL)
{
   if ($id_customer)
       $customer = new Customer(intval($id_customer));
   return Db::getInstance()->getValue('
   SELECT `reduction`
   FROM `'._DB_PREFIX_.'group`
   WHERE `id_group` = '.((isset($customer) AND Validate::isLoadedObject($customer)) ? intval($customer->id_default_group) : 1));
} 



to:

static public function getReduction($id_customer = NULL)
{
   if ($id_customer)
       $customer = new Customer(intval($id_customer));
   echo 'SELECT `reduction`
   FROM `'._DB_PREFIX_.'group`
   WHERE `id_group` = '.((isset($customer) AND Validate::isLoadedObject($customer)) ? intval($customer->id_default_group) : 1);
   return Db::getInstance()->getValue('
   SELECT `reduction`
   FROM `'._DB_PREFIX_.'group`
   WHERE `id_group` = '.((isset($customer) AND Validate::isLoadedObject($customer)) ? intval($customer->id_default_group) : 1));
} 



This should display the SQL query that is failing for some reason.

Link to comment
Share on other sites

Thanks, you've know all!

I see this now on my shop (header)

SELECT `reduction` FROM `group` WHERE `id_group` = 0SELECT `reduction` FROM `group` WHERE `id_group` = 0SELECT `reduction` FROM `group` WHERE `id_group` = 0

Link to comment
Share on other sites

So Default is ticked? That's weird. I don't know why the default group is 0. You'll need to log in to phpMyAdmin, open the ps_customer table, edit the id_default_group of each customer and change it from 0 to 1.

Link to comment
Share on other sites

I have another solution for this problem.

I have made alot of new categories, then I have customers acces to one of them.

And i work in that new categories with discount on the products themselves.

And that will work.

Link to comment
Share on other sites

  • 1 month later...

Everything works fine in 1.3.1

All you have to do is to create discount group and afterwords

mark the Default group and
New group for the customer.

AND ofcourse you have to

mark the default group and
New group
for each category you want to use

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...