ezakimak Posted June 15, 2010 Share Posted June 15, 2010 Hi everybody, How can I change the default " discount behaviour " in prestashop,this is the case:- I have customers in certain groups with special discounts and - I have products in promotion with special discountsCurrently prestashop is applying the discount on the product based on the special reduction on the catalog and applying at the same time the discount based on the group of the customer.I dont want these customers with already special discounts to access these special discounts when they are buying products in promotion.is there a way to acomplish this ?thanks Hugo Link to comment Share on other sites More sharing options...
rocky Posted June 16, 2010 Share Posted June 16, 2010 Change lines 1451-1452 of classes/Product.php (in PrestaShop v1.3.1) from: // Group reduction $price *= ((100 - Group::getReduction(((isset($id_customer) AND $id_customer) ? $id_customer : 0))) / 100); to: if (!$reduc) // Group reduction $price *= ((100 - Group::getReduction(((isset($id_customer) AND $id_customer) ? $id_customer : 0))) / 100); This code will ignore the group reduction if a product reduction has already been applied. Link to comment Share on other sites More sharing options...
ezakimak Posted June 16, 2010 Author Share Posted June 16, 2010 Thanks ! I will give it a try and let you know Hugo Link to comment Share on other sites More sharing options...
ezakimak Posted June 16, 2010 Author Share Posted June 16, 2010 Hi , making that modification to the code solves the problem, but in the store it still displays the price with the product reduction + the group reduction, but the prices are correct when you add the products to the cartI have also checked the product.php (ps 1.2.5.0) and found this at line 186: $smarty->assign(array( 'quantity_discounts' => QuantityDiscount::getQuantityDiscounts(intval($product->id), $product->getPriceWithoutReduct()), 'product' => $product, 'jqZoomEnabled' => $jqZoomEnabled, 'product_manufacturer' => new Manufacturer(intval($product->id_manufacturer)), 'token' => Tools::getToken(false), 'productPriceWithoutEcoTax' => floatval($productPriceWithoutEcoTax), 'features' => $features, 'attachments' => $attachments, 'allow_oosp' => $product->isAvailableWhenOutOfStock(intval($product->out_of_stock)), 'last_qties' => intval($configs['PS_LAST_QTIES']), 'group_reduction' => (100 - Group::getReduction(intval($cookie->id_customer))) / 100, 'col_img_dir' => _PS_COL_IMG_DIR_, 'HOOK_EXTRA_LEFT' => Module::hookExec('extraLeft'), 'HOOK_EXTRA_RIGHT' => Module::hookExec('extraRight'), 'HOOK_PRODUCT_OOS' => Hook::productOutOfStock($product), 'HOOK_PRODUCT_FOOTER' => Hook::productFooter($product, $category), 'HOOK_PRODUCT_ACTIONS' => Module::hookExec('productActions'), 'HOOK_PRODUCT_TAB' => Module::hookExec('productTab'), 'HOOK_PRODUCT_TAB_CONTENT' => Module::hookExec('productTabContent'))); i think there is something to modify here too, the group_reduction part but i dont know exactly how to procede.I'd appreciate if you could give another hintthanks in advanceHugo Link to comment Share on other sites More sharing options...
rocky Posted June 16, 2010 Share Posted June 16, 2010 I didn't realise that there is code that wasn't using the getPriceStatic function. If you upgrade to PrestaShop v1.3, you'll need add the following code: $now = date('Y-m-d H:M:S'); but since you are using PrestaShop v1.2.5, you should add following code instead: $now = date('Y-m-d'); Then change: 'group_reduction' => (100 - Group::getReduction(intval($cookie->id_customer))) / 100, to: 'group_reduction' => ((($product->reduction_percent > 0 OR $product->reduction_price > 0) AND ($now >= $product->reduction_from AND $now <= $product->reduction_to)) ? 1 : (100 - Group::getReduction(intval($cookie->id_customer))) / 100), Link to comment Share on other sites More sharing options...
ezakimak Posted June 16, 2010 Author Share Posted June 16, 2010 Hi the next code 'group_reduction' => ((($product->reduction_percent > 0 OR $product->reduction_price > 0) AND ($now >= $product->reduction_from AND $now <= $product->reduction_to)) ? 0 : (100 - Group::getReduction(intval($cookie->id_customer))) / 100), should be 'group_reduction' => ((($product->reduction_percent > 0 OR $product->reduction_price > 0) AND ($now >= $product->reduction_from AND $now <= $product->reduction_to)) ? 1 : (100 - Group::getReduction(intval($cookie->id_customer))) / 100), this solved the issuethanks a lot ! Hugo Link to comment Share on other sites More sharing options...
rocky Posted June 16, 2010 Share Posted June 16, 2010 Thanks, I've corrected my code above. Link to comment Share on other sites More sharing options...
MEG Venture Posted June 25, 2010 Share Posted June 25, 2010 What if I want my prestashop ignore product reduction if a group reduction is already applied ? (ps 1.2.5.)Thanks. Link to comment Share on other sites More sharing options...
rocky Posted June 26, 2010 Share Posted June 26, 2010 In that case, add the following code on line 1429 of classes/Product.php in PrestaShop v1.3.1 (before // Only reduction): // Ignore price reduction if there is a group reduction if (Group::getReduction((isset($id_customer) AND $id_customer) ? $id_customer : 0) > 0) $reduc = 0; Link to comment Share on other sites More sharing options...
MEG Venture Posted June 26, 2010 Share Posted June 26, 2010 Thanks for the quick reply. Worked for me. To ignore product discount if there is already a group discount applied let me add me some inputs for PS 1.2.5 users.The code below should be added before line 1271 for PS v. 1.2.5. of classes/Product.php (before //only reduction) // Ignore price reduction if there is a group reduction if (Group::getReduction((isset($id_customer) AND $id_customer) ? $id_customer : 0) > 0) $reduc = 0; And for the product pages, the code below (in product.php of root folder) 'group_reduction' => (100 - Group::getReduction(intval($cookie->id_customer))) / 100, should be changed by 'group_reduction' => ((($product->reduction_percent = 0 AND $product->reduction_price = 0)) ? 1 : (100 - Group::getReduction(intval($cookie->id_customer))) / 100), Hope this works. Link to comment Share on other sites More sharing options...
Rain3r Posted July 9, 2010 Share Posted July 9, 2010 Hi,please what line should I change in order to group reductions won't be applied in certain category and its subcategories? (All customers should have full price for goods in certain category)Thanks Link to comment Share on other sites More sharing options...
MEG Venture Posted July 9, 2010 Share Posted July 9, 2010 Dear Rain3r,You can take a look at this thread. There is a solution but I couldn't understand how to apply. Maybe it works for you. If it does, please let me know, too http://www.prestashop.com/forums/viewthread/26111/ Link to comment Share on other sites More sharing options...
Francisco Carlão Posted September 16, 2010 Share Posted September 16, 2010 thanks Caglar great help.But one question i would like to know if the reduction in the product is bigger than the group reduction , keep the price reduction and not aply the group reduction .is that possible??? Link to comment Share on other sites More sharing options...
syrovidis Posted October 22, 2010 Share Posted October 22, 2010 Great, this is what I was looking for! But I also, like Francisco Carlão, ask if it is possible to check which reduction is bigger (group or product reduction) and then use the bigger one. Then this update would be fantastic! Link to comment Share on other sites More sharing options...
ezakimak Posted October 22, 2010 Author Share Posted October 22, 2010 hi, I've done this, let me check my code to see what needs to be changed, i did it a long time ago, so I am not quite sure wich files you must change, but i think basically it is the /classes/product.php /product.php and /themes/yourtheme/js/product.js and /themes/yourtheme/product.tpllet me check it Link to comment Share on other sites More sharing options...
syrovidis Posted October 23, 2010 Share Posted October 23, 2010 Ok, thank you! I will wait. Link to comment Share on other sites More sharing options...
syrovidis Posted October 26, 2010 Share Posted October 26, 2010 ezakimak: please, didn't you find solution for my problem yet? Link to comment Share on other sites More sharing options...
mindis Posted March 18, 2011 Share Posted March 18, 2011 Hello,Great update, but have 1 problem. Invoice product price is wrong.I had update this: 'group_reduction' => ((($product->reduction_percent > 0 OR $product->reduction_price > 0)) ? 1 : (100 - Group::getReduction(intval($cookie->id_customer))) / 100), if (!$reduc) // Group reduction $price *= ((100 - Group::getReduction(((isset($id_customer) AND $id_customer) ? $id_customer : 0))) / 100); After that work perfect. But in invoice Group discount not working. Maybe have somebody solution?Thanks Link to comment Share on other sites More sharing options...
Libancillo Posted October 17, 2011 Share Posted October 17, 2011 In order to solve the invoicing problem, you need to change additionaly the file: classes/PaymentModule.php e.g: Prestashop 1.3.7, around line 223 change: ', '.floatval(Group::getReduction(intval($order->id_customer))).', to: ', ' . ((floatval($reduction_percent) > 0 || floatval($reduction_amount) > 0) ? 0.00 : floatval(Group::getReduction(intval($order->id_customer)))) . ', in order to not apply the group discount when the product has a price reduction. 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