ply Posted June 17, 2013 Share Posted June 17, 2013 I have searched high and low for a solution to this, which was so simple in 1.4 but seems almost impossible in 1.5: How do I add the product discount in % in the product-list? Link to comment Share on other sites More sharing options...
vekia Posted June 17, 2013 Share Posted June 17, 2013 so, you've got defined special price on product, right? for example - 10% value down. Now you want to display "10%" on product page, rigth? not amount, just percentage reduction? if so, this module can be helpful: https://mypresta.eu/modules/front-office-features/quantity-discounts-on-products-lists.html it displays all available product quantity discounts on list of products (product-list.tpl) 1 Link to comment Share on other sites More sharing options...
ply Posted June 17, 2013 Author Share Posted June 17, 2013 Exactly! Just like this, but in 1.5 http://www.labelhouse.dk/da/35-kabelmarker Link to comment Share on other sites More sharing options...
vekia Posted June 17, 2013 Share Posted June 17, 2013 try with this code: {if $product->specificPrice AND $product->specificPrice.reduction_type == 'percentage'}{$product->specificPrice.reduction*100}%{/if} this code shows special price percentage discount value. Link to comment Share on other sites More sharing options...
ply Posted June 17, 2013 Author Share Posted June 17, 2013 it just displays a 0. It is as if it simple does not get the data. I have attached the product-list. I just dont get, why it has to be this hard in 1.5 or why i cant find any documentation on which variable can be used and were. product-list.php Link to comment Share on other sites More sharing options...
NemoPS Posted June 17, 2013 Share Posted June 17, 2013 You might achieve the result using part of the code from my tut here: http://blog.arvixe.com/display-the-lowest-price-in-prestashops-product-list/ Link to comment Share on other sites More sharing options...
ply Posted June 17, 2013 Author Share Posted June 17, 2013 Hi there:-) I have actually been through your code, both on the linked website and on your blog. I actually asked a question on the blog also:-) I just cant quite wrap my head around, how I modify your code to fit my scenario. Got a suggestion? Link to comment Share on other sites More sharing options...
NemoPS Posted June 17, 2013 Share Posted June 17, 2013 And I didn't respond to the comment? Must have forgot, sorry! I would stop when retrieving the quantity dicount prices, and assigning that array directly to the product instead of only getting the lower price. In the template, I'd then copy the product.tpl quantity discount table and replace the variables Link to comment Share on other sites More sharing options...
ply Posted June 17, 2013 Author Share Posted June 17, 2013 There is no need to, I asked today:-) COuld you make a quick(dont want to hog to much of your time) example? Link to comment Share on other sites More sharing options...
NemoPS Posted June 17, 2013 Share Posted June 17, 2013 Here is an example for 1.4, I did it some time ago {if isset($product.qty_discounts) && $product.qty_discounts} <table class="std" style="font-size: 11px;margin-top: 3px;"> <tr> <th style="text-align:left">{l s='Buy'}</th> {foreach from=$product.qty_discounts item=quantity_discount name=quantity_discounts} <th style="text-align:left">{$quantity_discount.from_quantity|intval}+ </th> {/foreach} </tr> <tr> <td>{l s='Pay(each)'}</td> {foreach from=$product.qty_discounts item=quantity_discount name=quantity_discounts} <td> {if $quantity_discount.price != 0 OR $quantity_discount.reduction_type == 'amount'} {convertPrice price=$quantity_discount.price} {else} {math equation="a*b" a=$original_price b=$quantity_discount.reduction assign=reduction_amt} {math equation="a-b" a=$original_price b=$reduction_amt assign=finalPrice} {convertPrice price=$finalPrice} {/if} </td> {/foreach} </tr> </table> {/if} Link to comment Share on other sites More sharing options...
ply Posted June 17, 2013 Author Share Posted June 17, 2013 Sadly, the above does not work in the 1.5 versions:-( I allready have a working and easy solution for 1.4 but I cant for the life of me figure out how to do it in 1.5. Link to comment Share on other sites More sharing options...
NemoPS Posted June 17, 2013 Share Posted June 17, 2013 It should work if you add that after implementing the tut's controller, assigning the quantity discounts variable Link to comment Share on other sites More sharing options...
ply Posted June 17, 2013 Author Share Posted June 17, 2013 Great, and this is for the product list? Will try your method! Link to comment Share on other sites More sharing options...
ply Posted June 17, 2013 Author Share Posted June 17, 2013 BTW You guide which is allready very good, would be massively improved if you had the entire override file at the bottom.Perhaps even for download:-) Link to comment Share on other sites More sharing options...
vekia Posted June 17, 2013 Share Posted June 17, 2013 hello the problem is solved with outstanding Nemo solution? Link to comment Share on other sites More sharing options...
ply Posted June 17, 2013 Author Share Posted June 17, 2013 I am woking on it now, will return with a status in a short while. Link to comment Share on other sites More sharing options...
ply Posted June 17, 2013 Author Share Posted June 17, 2013 Sadly it isnt working:-( I have added the category controller file, just in case I F'ed something up. CategoryController.php Link to comment Share on other sites More sharing options...
ply Posted June 17, 2013 Author Share Posted June 17, 2013 Save us Nemowan, you are our only hope;-) Link to comment Share on other sites More sharing options...
NemoPS Posted June 17, 2013 Share Posted June 17, 2013 Use the Force, Ply Anyway that controller will never work. First there is an incomplete comment. Secondly, you need to grab quantity discounts before checking if there's any An you need a method anyway public function initContent() { parent::initContent(); if($this->cat_products) { $id_customer = (isset($this->context->customer) ? (int)$this->context->customer->id : 0); $id_group = (isset($this->context->customer) ? $this->context->customer->id_default_group : _PS_DEFAULT_CUSTOMER_GROUP_); $id_country = (int)$id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT'); $id_currency = (int)$this->context->cookie->id_currency; $id_shop = $this->context->shop->id; foreach ($this->cat_products as $key => $product) { $prices_array = array(); /* For each product, grab quantity discounts */ $quantity_discounts = SpecificPrice::getQuantityDiscounts($product['id_product'], $id_shop, $id_currency, $id_country, $id_group, null, true); } } } Link to comment Share on other sites More sharing options...
ply Posted June 17, 2013 Author Share Posted June 17, 2013 Ooops my bad! I posted the wrong file. THis is how it looks. CategoryController (3).php Link to comment Share on other sites More sharing options...
NemoPS Posted June 18, 2013 Share Posted June 18, 2013 Check if quantity discounts are assigned first: /* Process quantity discounts to get the real price */ if ($quantity_discounts) { var_dump($quantity_discounts); } // end if quantity discounts Then simply assign them to the current product like $this->cat_products[$key]['quantity_discounts'] = $quantity_discounts Link to comment Share on other sites More sharing options...
Fixfinn Posted September 20, 2013 Share Posted September 20, 2013 Where to put this code? in CategoryController.php in the overirde folder or ? Link to comment Share on other sites More sharing options...
NemoPS Posted September 20, 2013 Share Posted September 20, 2013 Yes, categorycontroller override Link to comment Share on other sites More sharing options...
Fixfinn Posted September 20, 2013 Share Posted September 20, 2013 Hmm, It does not seem to Work anymore in 1.5.5.0? Link to comment Share on other sites More sharing options...
NemoPS Posted September 20, 2013 Share Posted September 20, 2013 Uh Sad, do you get any error if you turn on error reporting? Link to comment Share on other sites More sharing options...
And63 Posted September 20, 2013 Share Posted September 20, 2013 (edited) My simply method: in classes/product.php after line 3695 add code: $row['original_price'] = Tools::ps_round($row['price'], 2); In productlist.tpl i added this code: {if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}<span class="price" style="display: inline;">{if !$priceDisplay}{convertPrice price=$product.price_tax_exc}{else} {(round((($product.price_tax_exc/$product.original_price)-1)*-100, 2))} {l s=' %'} {/if}</span>{l s=' reduction'}<br />{/if} Edited September 20, 2013 by And63 (see edit history) Link to comment Share on other sites More sharing options...
Fixfinn Posted September 20, 2013 Share Posted September 20, 2013 in classes/product.php it looks like this then? public function getTags($id_lang) { if (!$this->isFullyLoaded && is_null($this->tags)) $this->tags = Tag::getProductTags($this->id); if (!($this->tags && key_exists($id_lang, $this->tags))) return ''; $result = ''; foreach ($this->tags[$id_lang] as $tag_name) $result .= $tag_name.', '; $row['original_price'] = Tools::ps_round($row['price'], 2); return rtrim($result, ', '); } it does not work. Nemo, I do not know how to turn on error reporting, but it looks like it does not know there is a discount? Link to comment Share on other sites More sharing options...
And63 Posted September 20, 2013 Share Posted September 20, 2013 (edited) in classes/product.php it looks like this then? public function getTags($id_lang) { if (!$this->isFullyLoaded && is_null($this->tags)) $this->tags = Tag::getProductTags($this->id); if (!($this->tags && key_exists($id_lang, $this->tags))) return ''; $result = ''; foreach ($this->tags[$id_lang] as $tag_name) $result .= $tag_name.', '; $row['original_price'] = Tools::ps_round($row['price'], 2); return rtrim($result, ', '); } it does not work. Nemo, I do not know how to turn on error reporting, but it looks like it does not know there is a discount? I add my code after line look this: $row['attribute_price'] = (float)Product::getProductAttributePrice($row['id_product_attribute']); Edited September 20, 2013 by And63 (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted September 20, 2013 Share Posted September 20, 2013 in classes/product.php it looks like this then? public function getTags($id_lang) { if (!$this->isFullyLoaded && is_null($this->tags)) $this->tags = Tag::getProductTags($this->id); if (!($this->tags && key_exists($id_lang, $this->tags))) return ''; $result = ''; foreach ($this->tags[$id_lang] as $tag_name) $result .= $tag_name.', '; $row['original_price'] = Tools::ps_round($row['price'], 2); return rtrim($result, ', '); } it does not work. Nemo, I do not know how to turn on error reporting, but it looks like it does not know there is a discount? You can do as suggested in my signature Link to comment Share on other sites More sharing options...
And63 Posted September 20, 2013 Share Posted September 20, 2013 You can do as suggested in my signature First of all, sorry for my english. In my personal opinion ps_product_group_reduction_cache table is unnecessary, which will take place in the database and slows down the shop. 1.4.4.1 The modification ps I used a different method. We know what customer group is the user know what is a discount on a particular product category. What does this mean - in Table product_group_reduction_cache have 9292 records in the database. Once we know which kind of customer, as are discounts for the category of cereal and using the data in Table group_reduction - number of records 122 - is the difference? Why would benefit from a reduction in the price for the group in the category for a specific product? Just by to give the customer a discount for the product, depending on which group the customer belongs. My solution is to other than original works by collecting rebates eight months and there was no error. In order to relieve my database table is empty product_group_reduction_cache has 0 records. In summary: With the cookies we know to which group the client belongs. We know what is category discount on products. Why do we, then, individual discount on a particular product? - Which belongs to a particular category, which is in turn assigned a discount for a group? - All necessary data can be found in Table group_reduction If you want to see if it works my solution - welcome http://www.fortec.pl, please register on the site - without it you will not get discounts - I'm assigning them Link to comment Share on other sites More sharing options...
Fixfinn Posted September 23, 2013 Share Posted September 23, 2013 Nemo, Now I have the errors turned on :-) And I get it to work by resetting the cache_index.php Thanks for the help. Link to comment Share on other sites More sharing options...
Fixfinn Posted September 24, 2013 Share Posted September 24, 2013 (edited) I was a bit fast then. When the product has a quantity discount, it shows the price without tax. When the product does not have a quantity discount, it shows the price with tax. It looks like the varable is changing how it is telling to show or not to show taxes. any idea? Edited September 24, 2013 by Fixfinn (see edit history) Link to comment Share on other sites More sharing options...
prestashopnew Posted February 26, 2016 Share Posted February 26, 2016 (edited) Hello guys, I am using prestashop 1.6.1.4 I wish I could see the percentage discount for each product at the top right of the image, instead of the word "new" or "sale" I would appreciate your help, it is very important, thanks in advance Edited February 27, 2016 by prestashopnew (see edit history) 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