Jump to content

Display volume discounts ($quantity_discounts) in product-list.tpl prestashop 1.6


Desamedia
 Share

Recommended Posts

Hi all,

 

I need to show the "volume discounts" in product-list.tpl. This is very easy to manage in product.tpl using $quantity_discounts, but this is not possible in the product-list.tpl.

 

I have been searching in /controllers/front/ProductController.php and /classes/Product.php but I can not see how call $quantity_discounts in product-list.tpl

 

Does anyone know the solution?

 

Thank you very much.

Share this post


Link to post
Share on other sites

I found the solution.

 

1) Go to /controllers/front/CategoryController.php

 

In line 232 you can read:

foreach ($this->cat_products as &$product)
if (isset($product['id_product_attribute']) && $product['id_product_attribute'] && isset($product['product_attribute_minimal_quantity']))
$product['minimal_quantity'] = $product['product_attribute_minimal_quantity']; 

You must change by:

 

foreach($this->cat_products as &$cat_product) $cat_product['quantity_discount'] = SpecificPrice::getQuantityDiscounts((int)$cat_product['id_product'], (int)Shop::getCurrentShop(), (int)self::$cookie->id_currency, $id_country, $id_group);
 
2) Go to product-list.tpl
 
Now you can use $product.quantity_discount
 
With  <pre>{$product.quantity_discount|print_r}</pre>  you can get the array with the volume discounts and use them.

Share this post


Link to post
Share on other sites

  • 2 years later...

Thank you Desamedia,

i search this

foreach ($this->cat_products as &$product)
if (isset($product['id_product_attribute']) && $product['id_product_attribute'] && isset($product['product_attribute_minimal_quantity']))
$product['minimal_quantity'] = $product['product_attribute_minimal_quantity']; 

and i add that :

foreach ($this->cat_products as &$product)
$product['quantity_discount'] = SpecificPrice::getQuantityDiscounts((int)$product['id_product'], (int)Shop::getCurrentShop(), (int)self::$cookie->id_currency, $id_country, $id_group);
if (isset($product['id_product_attribute']) && $product['id_product_attribute'] && isset($product['product_attribute_minimal_quantity']))
$product['minimal_quantity'] = $product['product_attribute_minimal_quantity']; 

Now i can use  $product.quantity_discount

With  <pre>{$product.quantity_discount|print_r}</pre>  i get the array with the volume discounts and use them
in my product list.tpl i use it just like that :
<ul>
	{foreach from=$product.quantity_discount item='zediscount'}
		<li>
			<span style="color: #00a2ea;">{convertPrice price = $zediscount.price*1.2|floatval}</span>
			for <b>{$zediscount.from_quantity}</b>
		</li>
	{/foreach}
</ul>

 

Share this post


Link to post
Share on other sites

  • 1 year later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More