ezakimak Posted September 10, 2010 Share Posted September 10, 2010 Hi, I am in the process of upgrading our shop (1.2.5) to the latest prestashop version, since I had made some modifications to the 1.2.5 Product.php file, I am comparing both files to include my changes to the new file provided with 1.3.1 version, I found this piece of code in Product::getPriceStatic that was not in the previous version .... if (intval($id_cart)) // Quantity discount { $totalQuantity = intval(Db::getInstance()->getValue(' SELECT SUM(`quantity`) FROM `'._DB_PREFIX_.'cart_product` WHERE `id_product` = '.intval($id_product).' AND `id_cart` = '.intval($id_cart)) ) + intval($quantity); }; if ($quantity> 1 AND ($qtyD = QuantityDiscount::getDiscountFromQuantity($id_product, $quantity))) { $discount_qty_price = QuantityDiscount::getValue($price, $qtyD->id_discount_type, $qtyD->value, $usetax, floatval($result['rate'])); $price -= $discount_qty_price; } .... but it is not working in the way I think it should, for example if you have one product with combinations, the cuantity discount is applying if and only if the customer buys more than one item of the same combination, so if I have the same product in various colors and the customer chooses to buy one of each color he wont get the quantity discount it should have, so I changed the code to be like this if (intval($id_cart)) // Quantity discount { $totalQuantity = intval(Db::getInstance()->getValue(' SELECT SUM(`quantity`) FROM `'._DB_PREFIX_.'cart_product` WHERE `id_product` = '.intval($id_product).' AND `id_cart` = '.intval($id_cart)) ); } if ($totalQuantity > 1 AND ($qtyD = QuantityDiscount::getDiscountFromQuantity($id_product, $totalQuantity))) { $discount_qty_price = QuantityDiscount::getValue($price, $qtyD->id_discount_type, $qtyD->value, $usetax, floatval($result['rate'])); $price -= $discount_qty_price; } I would like to know if this is the desired intention of this piece of code, in my case it is not, so i changed it and I am sharing with you , perhaps other people are in the same situation as meregardsHugh Link to comment Share on other sites More sharing options...
olea Posted September 10, 2010 Share Posted September 10, 2010 When you look in th eBackOffice, there is not way to specify quantity discount per declinaisonThe quantity discount applies to the product, whatever the declinaison Link to comment Share on other sites More sharing options...
ezakimak Posted September 10, 2010 Author Share Posted September 10, 2010 by declinaison you mean combination ? Link to comment Share on other sites More sharing options...
olea Posted September 10, 2010 Share Posted September 10, 2010 Yes, sorry for my english A product in different sizes or colors are computed in the same total for the quantity discount Link to comment Share on other sites More sharing options...
ezakimak Posted September 10, 2010 Author Share Posted September 10, 2010 Hi, that is what I was trying to say, with the original code, prestashop is not doing the way you said it should. With the original code provided with 1.3.1 version, the same producut with different size or color are not computed in the same total for quantity discounts.regards Link to comment Share on other sites More sharing options...
olea Posted September 10, 2010 Share Posted September 10, 2010 I've read more precisely your first post.I'm perheaps wrong in what I was saying.In BO, for sure, you can only define discount price per product not per product/combination.Then, with this config, there are 2 ways of working in FO :-- include different combination of the same product in the total, to apply the discount-- count products of same combination to apply the discountBoth computation methods make sense.I don't know what was the prestateam chose on the subjectTry on their demo or on a frsh installDon't hesitate to post a feature evolution Link to comment Share on other sites More sharing options...
ezakimak Posted September 10, 2010 Author Share Posted September 10, 2010 I tried the online demo, For instance, in the BO I configured Ipod shuffle to have these quantity discounts * 2qty ---> 2 € , * 4qty ---> 4 € then I placed an order in the FO this way-- Ipod shuffle (color green ) 2 qty, it gave the 2 € discount-- Ipod shuffle (color blue ) 2 qty , it gave the 2 € discountbut , as you can see, I bought 4 Ipod suffles in total. From this I concluded that they chose the second option you mentioned in your previous post.In my case , in our shop we needed to give the discount for the total quantity no matter the color or size as long as it is the same product. I hope this will help other people in the same situationregardsHugh Link to comment Share on other sites More sharing options...
Mixto Posted March 1, 2011 Share Posted March 1, 2011 Great!!! I have the same problem... and applied this solution in version 1.3.6.0: if (intval($id_cart)) // Quantity discount { $totalQuantity = intval(Db::getInstance()->getValue(' SELECT SUM(`quantity`) FROM `'._DB_PREFIX_.'cart_product` WHERE `id_product` = '.intval($id_product).' AND `id_cart` = '.intval($id_cart)) ) /*+ intval($quantity)*/; } if ($totalQuantity > 1 AND ($qtyD = QuantityDiscount::getDiscountFromQuantity($id_product, $totalQuantity))) { if (self::getTaxCalculationMethod($id_customer) == PS_TAX_EXC) $discount_qty_price = Tools::ps_round(QuantityDiscount::getValue($price, $qtyD->id_discount_type, $qtyD->value, $usetax, floatval($result['rate']), $currency), 2); else $discount_qty_price = QuantityDiscount::getValue($price, $qtyD->id_discount_type, $qtyD->value, $usetax, floatval($result['rate']), $currency); $price -= $discount_qty_price; } RegardsMarco Hi, I am in the process of upgrading our shop (1.2.5) to the latest prestashop version, since I had made some modifications to the 1.2.5 Product.php file, I am comparing both files to include my changes to the new file provided with 1.3.1 version, I found this piece of code in Product::getPriceStatic that was not in the previous version .... if (intval($id_cart)) // Quantity discount { $totalQuantity = intval(Db::getInstance()->getValue(' SELECT SUM(`quantity`) FROM `'._DB_PREFIX_.'cart_product` WHERE `id_product` = '.intval($id_product).' AND `id_cart` = '.intval($id_cart)) ) + intval($quantity); }; if ($quantity> 1 AND ($qtyD = QuantityDiscount::getDiscountFromQuantity($id_product, $quantity))) { $discount_qty_price = QuantityDiscount::getValue($price, $qtyD->id_discount_type, $qtyD->value, $usetax, floatval($result['rate'])); $price -= $discount_qty_price; } .... but it is not working in the way I think it should, for example if you have one product with combinations, the cuantity discount is applying if and only if the customer buys more than one item of the same combination, so if I have the same product in various colors and the customer chooses to buy one of each color he wont get the quantity discount it should have, so I changed the code to be like this if (intval($id_cart)) // Quantity discount { $totalQuantity = intval(Db::getInstance()->getValue(' SELECT SUM(`quantity`) FROM `'._DB_PREFIX_.'cart_product` WHERE `id_product` = '.intval($id_product).' AND `id_cart` = '.intval($id_cart)) ); } if ($totalQuantity > 1 AND ($qtyD = QuantityDiscount::getDiscountFromQuantity($id_product, $totalQuantity))) { $discount_qty_price = QuantityDiscount::getValue($price, $qtyD->id_discount_type, $qtyD->value, $usetax, floatval($result['rate'])); $price -= $discount_qty_price; } I would like to know if this is the desired intention of this piece of code, in my case it is not, so i changed it and I am sharing with you , perhaps other people are in the same situation as meregardsHugh 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