Stefand Posted July 12, 2010 Share Posted July 12, 2010 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.1Stefan Link to comment Share on other sites More sharing options...
Stefand Posted July 12, 2010 Author Share Posted July 12, 2010 can somebody help me with this please? Link to comment Share on other sites More sharing options...
SpyrosT Posted July 12, 2010 Share Posted July 12, 2010 I think your error is that the client is placed in both groups.If you need that client to get 10% discount then he must be in the 10% group only. Link to comment Share on other sites More sharing options...
rocky Posted July 13, 2010 Share Posted July 13, 2010 Topic renamed - please don't write in caps or write the word "help" in the titleThe 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 More sharing options...
Stefand Posted July 13, 2010 Author Share Posted July 13, 2010 I'm using the standard theme? Link to comment Share on other sites More sharing options...
rocky Posted July 13, 2010 Share Posted July 13, 2010 It should be working then. Check the value of var groupReduction on your product page. Can you provide a link to your site? Link to comment Share on other sites More sharing options...
Stefand Posted July 13, 2010 Author Share Posted July 13, 2010 it doesnot work.. Do you mean the product.tpl file or the .php ? Link to comment Share on other sites More sharing options...
rocky Posted July 13, 2010 Share Posted July 13, 2010 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 More sharing options...
Stefand Posted July 13, 2010 Author Share Posted July 13, 2010 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 More sharing options...
rocky Posted July 13, 2010 Share Posted July 13, 2010 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 More sharing options...
Stefand Posted July 13, 2010 Author Share Posted July 13, 2010 Hi,I dont understand you with the first code,the second one I check it and change it but with no result.and where should I place the last code? Link to comment Share on other sites More sharing options...
rocky Posted July 13, 2010 Share Posted July 13, 2010 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 More sharing options...
Stefand Posted July 13, 2010 Author Share Posted July 13, 2010 don't work, I see this on my shop:Group::getReduction(1)Group::getReduction(1)Group::getReduction(1) Link to comment Share on other sites More sharing options...
rocky Posted July 13, 2010 Share Posted July 13, 2010 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 More sharing options...
Stefand Posted July 13, 2010 Author Share Posted July 13, 2010 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 More sharing options...
rocky Posted July 13, 2010 Share Posted July 13, 2010 The problem is that the default group of the customer is 0. It should be 1. Go to the Customers tab, click the Edit button in the Actions column next to customer 1 and make sure that "Default" is ticked. Link to comment Share on other sites More sharing options...
Stefand Posted July 13, 2010 Author Share Posted July 13, 2010 1 Defaultit looks good there? Link to comment Share on other sites More sharing options...
rocky Posted July 13, 2010 Share Posted July 13, 2010 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 More sharing options...
Stefand Posted July 13, 2010 Author Share Posted July 13, 2010 don't not work that value was already on 1.... Link to comment Share on other sites More sharing options...
rocky Posted July 13, 2010 Share Posted July 13, 2010 Well, I'm stumped. According to your output above, the id_default_category is 0, yet the id_default_category is 1 in the database. That doesn't make any sense. Something must be changing the value. Link to comment Share on other sites More sharing options...
Stefand Posted July 17, 2010 Author Share Posted July 17, 2010 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 More sharing options...
sokpet Posted August 22, 2010 Share Posted August 22, 2010 Everything works fine in 1.3.1All you have to do is to create discount group and afterwordsmark the Default group andNew group for the customer. AND ofcourse you have tomark the default group and New group for each category you want to use Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now