luca.lb Posted February 15, 2010 Share Posted February 15, 2010 Hello,I need to use a variable $quantity_discounts in product-list.tplactualy this variable not work in product-list.tpl, but also in product.tplthat change should be done? Link to comment Share on other sites More sharing options...
luca.lb Posted February 18, 2010 Author Share Posted February 18, 2010 Hello,I need to use a variable $quantity_discounts in product-list.tplactualy this variable not work in product-list.tpl, but also in product.tplthat change should be done? no one answers? Magento community is more prepared and available Link to comment Share on other sites More sharing options...
luca.lb Posted February 18, 2010 Author Share Posted February 18, 2010 Hello,I need to use a variable $quantity_discounts in product-list.tplactualy this variable not work in product-list.tpl, but also in product.tplthat change should be done?I want to see the quantity discounts when you see the products in the categories and when you do a search Link to comment Share on other sites More sharing options...
rocky Posted February 18, 2010 Share Posted February 18, 2010 You aren't getting any responses because it is difficult to do. You need to modify every file that calls product-list.tpl (category.php, search.php, best-sales.php) and write code like this before the $smarty->display: $quantity_discounts = array(); foreach ($products as $product) { $quantity_discounts[$product['id_product']] = QuantityDiscount::getQuantityDiscounts(intval($product->id), $product->getPriceWithoutReduct()); } $smarty->assign('quantity_discounts', $quantity_discounts); Then inside the foreach loop in product-list.tpl, you can access the appropriate quantity discount using code like: {foreach from=$quantity_discounts key=id_product item=quantity_discount} {if $product.id_product == $id_product} {foreach from=$quantity_discount item=$discount} {$quantity_discount.quantity|intval}: {if $quantity_discount.id_discount_type|intval == 1}{$quantity_discount.value|floatval}%{else}{convertPrice price=$quantity_discount.value|floatval}{/if} {/foreach} {/if} {/foreach} I don't have time to test this code, so you'll have to do that yourself. Link to comment Share on other sites More sharing options...
luca.lb Posted February 18, 2010 Author Share Posted February 18, 2010 the array is empty.I've print the array in category PHP with print_r function. foreach ($products as $product) { $quantity_discounts[$product['id_product']] = QuantityDiscount::getQuantityDiscounts(intval($product->id), $product->getPriceWithoutReduct()); } print_r($quantity_discounts); The result is:Array ( ) Link to comment Share on other sites More sharing options...
luca.lb Posted February 18, 2010 Author Share Posted February 18, 2010 in category.php Link to comment Share on other sites More sharing options...
rocky Posted February 19, 2010 Share Posted February 19, 2010 Now that I've got time to have a better look at the code, I see it is more difficult than that because each file uses a different variable name. In category.php, you need to use: foreach ($cat_products as $product) { $quantity_discounts[$product['id_product']] = QuantityDiscount::getQuantityDiscounts(intval($product->id), $product->getPriceWithoutReduct()); } In search.php, you need to use: foreach ($search['result'] as $product) { $quantity_discounts[$product['id_product']] = QuantityDiscount::getQuantityDiscounts(intval($product->id), $product->getPriceWithoutReduct()); } and in best-sales.php, you need to use: $products = ProductSale::getBestSales(intval($cookie->id_lang), intval($p) - 1, intval($n), $orderBy, $orderWay); foreach ($products as $product) { $quantity_discounts[$product['id_product']] = QuantityDiscount::getQuantityDiscounts(intval($product->id), $product->getPriceWithoutReduct()); } and replace the $smarty->assign with the following to save a query: $smarty->assign(array( 'products' => $products, 'nbProducts' => $nbProducts)); Link to comment Share on other sites More sharing options...
luca.lb Posted February 19, 2010 Author Share Posted February 19, 2010 i've tested on category.php$cat_products is a correct array with the product informations, but this code not work $quantity_discounts[$product['id_product']] = QuantityDiscount::getQuantityDiscounts(intval($product->id), $product->getPriceWithoutReduct()); Link to comment Share on other sites More sharing options...
rocky Posted February 19, 2010 Share Posted February 19, 2010 You're right. I rushed that code. Now I see that category.php doesn't have a product object you can use. Try using the following instead: $productObj = new Product($product['id_product']); $quantity_discounts[$product->id] = QuantityDiscount::getQuantityDiscounts(intval($productObj->id), $product->getPriceWithoutReduct()); Link to comment Share on other sites More sharing options...
luca.lb Posted February 19, 2010 Author Share Posted February 19, 2010 not work... $quantity_discounts[$product->id] = QuantityDiscount::getQuantityDiscounts(intval($productObj->id), $product->getPriceWithoutReduct()); Link to comment Share on other sites More sharing options...
Patric Posted February 19, 2010 Share Posted February 19, 2010 Topics merged and moved. Link to comment Share on other sites More sharing options...
rocky Posted February 20, 2010 Share Posted February 20, 2010 I was hoping you'd see what I was doing and figure it out how to fix it yourself. Anyway, I noticed a couple of errors in the code I posted. Try the following instead: $productObj = new Product($product['id_product']); $quantity_discounts[$productObj->id] = QuantityDiscount::getQuantityDiscounts(intval($productObj->id), $productObj->getPriceWithoutReduct()); Link to comment Share on other sites More sharing options...
luca.lb Posted February 20, 2010 Author Share Posted February 20, 2010 finally working on!the coregory.php correct code is: foreach ($cat_products as $product) { $productObj = new Product($product['id_product']); $quantity_discounts[$productObj->id] = QuantityDiscount::getQuantityDiscounts(intval($productObj->id), $productObj->getPriceWithoutReduct()); } $smarty->assign('quantity_discounts', $quantity_discounts); in product-list.php is {foreach from=$quantity_discounts key=id_product item=quantity_discount} {if $product.id_product == $id_product} {foreach from=$quantity_discount item=discount} da {$discount.quantity|intval}pz : {$discount.value|floatval} € {/foreach} {/if} {/foreach} thanks! Link to comment Share on other sites More sharing options...
dzindzilia Posted May 29, 2010 Share Posted May 29, 2010 Hi,could you please describe in more detail what should I change to show discounted price in product list?We sell products for base price of $1.50, but we offer quantity discounts down to $1.00 . Customers are redirected from our ads to product lists, and see prices of $1.50 . I would be very grateful if you could help me solving this. Link to comment Share on other sites More sharing options...
dzindzilia Posted May 31, 2010 Share Posted May 31, 2010 I tried to put above codes everywhere I could think of, and it doesn't work.Please help. Link to comment Share on other sites More sharing options...
Just Ben Posted July 13, 2010 Share Posted July 13, 2010 I believe this would be more efficient for the smarty code: > {if $quantity_discounts[$product.id_product]} <!-- quantity discount --> </pre> <ul> {foreach from=$quantity_discounts[$product.id_product] item='quantity_discount' name='quantity_discounts'} Buy {$quantity_discount.quantity|intval}+ : {if $quantity_discount.id_discount_type|intval == 1} {$quantity_discount.value|floatval}% {else} { convertPrice price=$product.price-$quantity_discount.value } each {/if} {/foreach} </ul> <br> {/if Instead of looping through every single quantity discount, you just loop through the ones for the product you are on, and only if that product has quantity discount to show. My output is different but that's up to you. This will print out something like: Buy 100+ : £1.04 each. Thanks for the php Rocky, that helped me quite a bit. Link to comment Share on other sites More sharing options...
dzindzilia Posted July 23, 2010 Share Posted July 23, 2010 I believe this would be more efficient for the smarty code: Just Ben, please, could you write more detailed instruction where to put the code you provided?This would help more people than just me.Thanks! Link to comment Share on other sites More sharing options...
mormoniusz Posted May 31, 2011 Share Posted May 31, 2011 Could We get more detailed information wher to put this code?Please Link to comment Share on other sites More sharing options...
airbag Posted June 23, 2011 Share Posted June 23, 2011 Hi, THanks for the messages, but how to do this in 1.4?Do you need to put something into CategoryController.php file instead? Link to comment Share on other sites More sharing options...
dramony Posted July 4, 2011 Share Posted July 4, 2011 Hey Rocky,Whats the code for showing the Quantity discount in Ascending order like this:50 Discount Price: $2.70100 Discount Price: $1.88250 Discount Price: $1.35500 Discount Price: $1.201000 Discount Price: $1.15I am using Presto-changeo Quantity Discounts module on PS1.4.Thanks. Link to comment Share on other sites More sharing options...
REFO.cz Posted August 24, 2011 Share Posted August 24, 2011 I am bumping this one too for prestashop 1.4.4 The problem is that when i add the following to the category.php $smarty->assign('quantity_discounts', $quantity_discounts); i get blank page. Is that in a correct format for PS v.1.4.4? Help would be appreciated. I am also willing to pay 10 bucks to a person who will help me implement this. Link to comment Share on other sites More sharing options...
nikmagnus Posted January 21, 2012 Share Posted January 21, 2012 Hi Rocky or anyone else who is listening... Can you assist me is getting the array $quantity_discounts working in product-list.tpl I have it working in product.tpl in this way: {if $quantity_discounts} {foreach from=$quantity_discounts item='quantity_discount' name='quantity_discounts'} <p class="price"><span class="our_price_display" id="our_price_display"> {$quantity_discount.quantity|intval} or more for [spam-filter]$productPrice *(100-{$quantity_discount.real_value|floatval})/100}|convertAndFormatPrice} each </span></p> {/foreach} The variable $quantity_discount.quantity and .real_value are not set. Thanks, nik Link to comment Share on other sites More sharing options...
PrestaShark Posted October 23, 2015 Share Posted October 23, 2015 Bump UP!Not solved at all! Anybody hear something about set quantitty discounts in product-list.tpl ? Any information much appreciated! 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