Our team is constantly monitoring Prestashop forum and we always try to help other users. So, today we would like to solve another issue indicated in this thread: “How I could show the “As Low As” price?”
Hi,
I have 5 different prices depending of the quantity and I’m looking to show below the products thumbs, the “As Low As” price similar to:
http://www.trophydepot.com/
How I could get show the low price, since the prestashop work basis in a discount way? Example, I have:
1+= $9.37
10+= $ 8.77
75+= $8.17
150+= $7.42
300+= $6.42
I would like to show the $6.42 (low price) in the category page. Any idea?
See attachment.
Thanks!
Prestаshоp allows setting scalable prices for different quantities of items and thereby stimulate customers to make purchases. You can set this option in the Prices tab under the Catalog > Products > Edit section
After that you will see a table with prices on the product page:
There are several ways to access product price data:
- Use the hook “actionProductListOverride”;
- Override the function CategoryController::assignProductList();
- Override the function Category::getProducts($id_lang, $p, $n, $order_by = null, $order_way = null, $get_total = false, $active = true, $random = false, $random_number_products = 1, $check_access = true, Context $context = null);
The correct way would be use a hook, because this a “modular” approach, however in this example we will override the function CаtegоryCоntrоller: :аssignPrоduсtList( ). So, lets change the collection of products by adding the following code into the function CategoryController::assignProductList():
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
$this->cat_products = $this->category->getProducts($this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay); foreach($this->cat_products as &$cat_product) { if ($specific_prices = SpecificPrice::getByProductId($cat_product['id_product'])) { $min_price = $cat_product['price']; foreach ($specific_prices as $specific_price) { if ($specific_price['price'] < 0) { switch ($specific_price['reduction_type']) { case 'amount': $tmp_price = $cat_product['price'] - $specific_price['reduction']; break; case 'percentage': $tmp_price = $cat_product['price'] * $specific_price['reduction']; break; } } if ($tmp_price < $min_price) { $min_price = $tmp_price; } } if ($specific_price['price'] < $tmp_price) { $cat_product['from_price'] = $min_price; //minimal possible product price } } } |
So now our collection contains the necessary data which we can output by customizing the template product-list.tpl:
1 2 3 4 5 6 7 8 9 10 11 12 |
<div class="content_price"> {if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}<span class="price" style="display: inline;">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span><br />{/if} {*AS LOW AS --begin*} {if isset($product.from_price)} <div class="as_low_as_price"> as low as {convertPrice price=$product.from_price} </div> {/if} {*AS LOW AS --end*} {if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability">{if ($product.allow_oosp || $product.quantity > 0)}{l s='Available'}{elseif (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}{l s='Product available with different options'}{else}{l s='Out of stock'}{/if}</span>{/if} </div> |
Let’s add some styles into the global.css:
1 2 3 4 5 |
.as_low_as_price{ font-size: 13px; font-weight: bold; color: #07A22C; } |
Now the directory page looks like this:
Hi, how do I display this in the list configuration as well? It works fine when in grid configuration, but not in the list configuration.
Hi,
Tank you very much for this useful topic. It works fine but there is no price on homefeatured (popular products on homepage) when I use it. Do you have a solution?
Bye
Good evening, I’m a newbie prestashop, use version 1.6 where the first change should be applied not quite understand.
It should be changed in the file override / controllers / front / categorycontroller.php right?
and where it needs to be added to this code?
thanks
Jovicyr,
You may contact our support team at [email protected] and they will help you.
Hi!
I have exactly the same need as described in the post.
Thanks for sharing it
I implemented the code on a Prestashop 1.6. Seems to “work” as I have data, but they are not really relevant.
The different in my case is that I have prices depending on customer group.
On BO for a product, prices are :
https://docs.google.com/file/d/0B8Ovb3KCwQK4M0lPQ3ZsVktROUE/edit?usp=drivesdk
124.92 € without tax (=149.90 with taxes)
58,28 for a specific customer
83.25 for B2B customer group (=”Revendeurs”) from 1 piece
74.95 for B2B customer group (=”Revendeurs”) from 5 pieces
-30% for GAT customer group
In FO I have the following as low as price : 44.97 which seems to be the reduction price with taxes : 149.90 * 30% = 44.97
But this price should be 149.90 – (149.90 * 30%) = 104.93
and only displayed if I am logged as a customer from GAT group.
So the price should be the folowing, depending of the customer :
– 124.92 for unlogged customer or B2C customers
– 58.28 for the specific customer
– 74.95 for B2B customers (=”Revendeurs”)
– 104.93 for GAT customers
instead of 44.97 which is a reduction and not a product price and appears independently of the customer group.
And it should be displayed with or without taxes depending on group configuration.
How can we fix your code?
Other notes:
– How can we add this hack as an override instead of modifying a core php file?
– In your code you write “as low as” not with best practices which is to use {l s=”as low as”}
Thanks a lot for your answer
Jota Dominguez,
I have not checked this myself, but you may let us know. But in general, the main principle remains the same.
Does this solution works with Prestashop 1.6?
Thanks
Hi again, Jacek!
all the below controllers should use the template product-list.tpl:
search -> controllers/front/SearchController.php
new products -> controllers/front/NewProductsController.php
best sellers -> controllers/front/BestSalesController.php
specials -> controllers/front/PricesDropController.php
list of products by manufacturer -> controllers/front/ManufacturerController.php
compare -> controllers/front/CompareController.php
Alex,
The solution that you show in this tutorial is definitely needed but it’s very incomplete. As a result you are able to show “As low as” prices on the product listing page but this is not the only place this would need to be presented. When browsing products via: Search, New products, Best sellers, Specials, List of products by manufacturer or even using the PrestaShop ‘Product compare’ feature the prices are shown without “As low as” values. I am looking for a way to display “As low as” prices in all above mentioned areas. Is there a method to achieve this or the relevant templates and controllers would need to be modified?
Jacek,
Thanks a lot!
Alexander,
What I meant is that the function that is achieved via the steps described in this article should be already built into a modern e-commerce software, such as Prestashop 1.6. It’s a very useful function. Thanks for sharing your knowledge.
John,
Please contact our support team at [email protected] and they will help you to customize the template.
Hello, I’m not very good at prestashop or customizations yet, and was wondering if this could work for what I am trying. I would like the display price to be the 10-25 price on trophies, instead of the highest price. Here is a page with one of my items on it
What I would like to display is “Team Price” with the 10-25 quantity price listed. I have setup a 10+ custom price, but couldn’t make the above instructions work for me. Any help would be greatly appreciated.
Jacek,
Sorry, but I am not sure I understand your question. Each product can have a price which is displayed on the frontend – this is the default price.
Very useful article. Thank you. I am surprised that the PrestaShop 1.6 doesn’t provide displaying prices in such a way as a standard or there are no modules that would do this.
Adrian,
In our case product iPod Nano already had combinations.
Thanks.
Can you tell me how can i display this in case that a product has multiple price/combinations ?