Stefand Posted September 25, 2010 Share Posted September 25, 2010 I have a question, I have products work with quantity by discount.eg. 1 quantity is standard € 2.25but by 10 quantity’s the price for one = € 2.00Is it possible to display the lowest price in the product list in this case € 2.00 ?Customers see than immediately the lowest price, and that’s what counts.I hope somebody can help me with this and understand this.Stefan Link to comment Share on other sites More sharing options...
rocky Posted September 27, 2010 Share Posted September 27, 2010 This is a tricky problem. I think I've found a solution though. Add the following code after line 59 of category.php in the root of PrestaShop v1.3.1 (the $cat_products = line): for ($i = 0; $i < sizeof($cat_products); $i++) { $quantity_discounts = QuantityDiscount::getQuantityDiscounts(intval($cat_products[$i]['id_product']), $cat_products[$i]['price']); $from_price = $cat_products[$i]['price']; foreach ($quantity_discounts as $quantity_discount) if ($quantity_discount['real_value'] < $from_price) $from_price = $quantity_discount['real_value']; if ($from_price != $cat_products[$i]['price']) $cat_products[$i]['from_price'] = $from_price; } then change line 18 of product-list.tpl in your theme's directory from: {if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if} to: {if $product.from_price}{l s='From'} {convertPrice price=$product.from_price}{else}{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}{/if} This will display "From $xx.xx" for products with quantity discounts and just "$xx.xx" for products without quantity discounts. It will pick the quantity discount that results in the lowest per-unit price.Note that this will work for the category listings only. To do this for the featured products, search results and other prices will require similiar modifications to other files. Link to comment Share on other sites More sharing options...
Stefand Posted October 1, 2010 Author Share Posted October 1, 2010 I have try this.But is there a solution to decide by myself which discount price on that place need to display?eg. it displays right know the lowest discount price.But I would like to display the highest discount price? Link to comment Share on other sites More sharing options...
rocky Posted October 1, 2010 Share Posted October 1, 2010 No, that would require adding a new field to the ps_product table in database and modify much PrestaShop code in order to save and read the field. It is too difficult for me to post here. Link to comment Share on other sites More sharing options...
Stefand Posted October 1, 2010 Author Share Posted October 1, 2010 Ok , maybe is this idea a simple solution:Make a new input field in the backoffice on the add product / change product pages.I can fill in there the price what I like to display in the product-list.So that I can decide on that way what I like to display in the product-list? Link to comment Share on other sites More sharing options...
rocky Posted October 1, 2010 Share Posted October 1, 2010 That's no easier, since it still requires creating a new field. The easiest way would be to put the price in another field, depending on which fields you are using. For example, you could use the "Wholesale price" field, then change product-list.tpl to read the wholesale price instead of the price. If you are already using that field, you could use the Location field instead. Link to comment Share on other sites More sharing options...
Stefand Posted October 1, 2010 Author Share Posted October 1, 2010 I use not the location field...But how can I display that field in the product-list ? Link to comment Share on other sites More sharing options...
rocky Posted October 1, 2010 Share Posted October 1, 2010 Change line 18 of product-list.tpl from: {if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if} to: {if $product.location|intval > 0}{convertPrice price=$product.location|intval}{elseif !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if} Link to comment Share on other sites More sharing options...
Stefand Posted October 1, 2010 Author Share Posted October 1, 2010 I have try that but what I have fill in in the location field in the BO will not display with that code.. Link to comment Share on other sites More sharing options...
rocky Posted October 1, 2010 Share Posted October 1, 2010 I just tested the code on my test site and it is working fine. When I enter 7 in the "Location" field, the price is overwritten as $7 instead of $13.95. I'm not sure why it isn't working for you. Link to comment Share on other sites More sharing options...
Stefand Posted October 1, 2010 Author Share Posted October 1, 2010 Yes..But when I fill in as location: 1.50. Displays 1.00 ? Link to comment Share on other sites More sharing options...
rocky Posted October 1, 2010 Share Posted October 1, 2010 Oops, my mistake. Try the following instead: {if $product.location|floatval > 0}{convertPrice price=$product.location|floatval}{elseif !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if} Link to comment Share on other sites More sharing options...
Stefand Posted October 1, 2010 Author Share Posted October 1, 2010 Rocky,Thanks, that part works fine right know! (I will soon make a donation to you).My last question and last part, maybe you can help me also with this (small) problem:I work with the module: quantity discountsBut it works without taxes, so the prices with quantity discount displays not right.The part of the code from the module which display the prices etc: function writeDiscountsContent(price) {ldelim} var discountStr = " "; var discountedPrice = 0; {foreach from=$qd_quantity_discounts item='qd_quantity_discount' name='quantity_discounts'} discountStr += "{$qd_quantity_discount.quantity|intval} "; {if $qd_quantity_discount.quantity|intval > 1} discountStr += "{l s='quantities' mod='quantitydiscounts'}: "; {else} discountStr += "{l s='quantity' mod='quantitydiscounts'}: "; {/if} {if $qd_quantity_discount.id_discount_type|intval == 1} discountedPrice = price - (price * {$qd_quantity_discount.value} / 100); {else} discountedPrice = price - {$qd_quantity_discount.value}; {/if} discountStr += formatCurrency(discountedPrice, currencyFormat, currencySign, currencyBlank) + " "; {/foreach} discountStr += " "; maybe you have the solution or somebody else...I have contact the module maker but he is on holiday and I need this very soon. Link to comment Share on other sites More sharing options...
Stefand Posted January 6, 2011 Author Share Posted January 6, 2011 Rocky.Thanks for you help with my previous question above.I need also display the location in the new_order mail in the module Mailalerts.When I add this in the codes into mailalerts.php it willn't work..: '{location}' => $product['location']->location(), (line 158)I also add this code: '.$product['location'].' line 112You solved my previous question also, so I hope that you can help me again.Thanks. Link to comment Share on other sites More sharing options...
rocky Posted January 7, 2011 Share Posted January 7, 2011 It's not that easy, since PrestaShop doesn't store the location of the products with the order. You will have to add extra code to get the location. Change lines 107-108 of modules/mailalerts/mailalerts.php from: foreach ($params['cart']->getProducts() AS $key => $product) { to: foreach ($params['cart']->getProducts() AS $key => $product) { $productObj = new Product(intval($product['id_product']), false, $id_lang); Then you can use $productObj->location in the foreach loop to display the product's location. Link to comment Share on other sites More sharing options...
Stefand Posted January 7, 2011 Author Share Posted January 7, 2011 The codes that you tell me, I try: foreach ($params['cart']->getProducts() AS $key => $product) { $productObj = new Product(intval($product['id_product']), false, $id_lang); And this one for the display. '.$product['location'].' Will not working... Link to comment Share on other sites More sharing options...
rocky Posted January 8, 2011 Share Posted January 8, 2011 You should use $productObj->location not $product['location'] 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