Jump to content

Add image for quantity available


Recommended Posts

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

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

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 by Nemo1 (see edit history)
Link to comment
Share on other sites

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
×
×
  • Create New...