pette Posted March 21, 2013 Share Posted March 21, 2013 I want to add an image to show the quantity available of a product. I want to calculate the rate of initial stock - the available quantity... if the rate is > 70% I want to display an image if it is < 30 % I want to display an other image... Is it possibile ? thanks Link to comment Share on other sites More sharing options...
NemoPS Posted March 21, 2013 Share Posted March 21, 2013 You'll need another field to store the initial quantity, otherwise you simply can't take out the rate. You'll need a product override which grabs the field you need in the database. If you don't want to add those values manually, you'll also need to use some custom code/inputs from the back office (it's a bit too long to explain here, but I believe you can find info in the docs) Finally, in product.tpl, locate the spot where the image must appear and use something like the following: {math equation="a/b" a=$product->quantity b=$product->initial_quantity assign=quantity-rate} {if $quantity_rate > 70} <img src=".....image url"> {else if $quantity_rate > 30} <img src="..another one"> {/if} The trickierst part being, of course, the first one Link to comment Share on other sites More sharing options...
pette Posted March 21, 2013 Author Share Posted March 21, 2013 Hi Nemo1, i'm not able to add the initial values manually, so it's possible find the initial quantity? thanks! Link to comment Share on other sites More sharing options...
pette Posted March 21, 2013 Author Share Posted March 21, 2013 (edited) Hi, but the variable {$product->initial_quantity} is it set? it exists ? thanks And if the quantity is for every combination ? thanks Edited March 21, 2013 by pette (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted March 21, 2013 Share Posted March 21, 2013 (edited) No, it must be created as far as I know :/ You're right, the combinations thing introduces a new whole series of problems, since you'd need to add the intial quantity there too, and check it. No way to store in in the database with an out of the box prestashop i fear, you'll need some heavy core extensions Edited March 21, 2013 by Nemo1 (see edit history) Link to comment Share on other sites More sharing options...
pette Posted March 22, 2013 Author Share Posted March 22, 2013 Thanks, so it is not possible with the default variable. the only possibility is to check with the available quantity with a javascript.. Link to comment Share on other sites More sharing options...
NemoPS Posted March 22, 2013 Share Posted March 22, 2013 This would not give you the "initial" quantity either i fear Link to comment Share on other sites More sharing options...
pette Posted March 22, 2013 Author Share Posted March 22, 2013 (edited) No, the only way is check if amount is > 3 or < 2 .... Edited March 22, 2013 by pette (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted March 22, 2013 Share Posted March 22, 2013 yes, that's correct. You can setup a standard in your mind (like green image i you have > 40 or so). This wouldn't require modifications to the core 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