Jump to content

Display warning when last 2 items left in stock at product page


Recommended Posts

Hi guys,

 

Need help to display warning in product page if only as below:

 

3 and above quantities of stock doesn't display any warning

2 quantities of stock left warning display "“Last 2 items in stock!”" 

1 quantity of stock left warning display "“Last items in stock!”"

 

how can i add the code in product.tpl

 

I believe below code call that warning to be displayed.

<p class="warning_inline" id="last_quantities"{if ($product->quantity > $last_qties OR $product->quantity <= 0) OR $allow_oosp OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if} >{l s='Warning: Last items in stock!'}</p>

*in BO>PREFERENCES>PRODUCT>

 

I've set Display remaining quantities when the qty is lower than 1

 

I'm using prestashop v1.5.4.1

 

Thanks in advance
 

 

Link to comment
Share on other sites

Hi Vekia,

 

it doesnt work if i add those 2 lines of code and remove code below:

<p class="warning_inline" id="last_quantities"{if ($product->quantity > $last_qties OR $product->quantity <= 0) OR $allow_oosp OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if} >{l s='Warning: Last items in stock!'}</p>

it also doesn't work if add those 2 lines of code with out removing code below: -> only show default warning "“Last items in stock!”" when product left 1 unit.

<p class="warning_inline" id="last_quantities"{if ($product->quantity > $last_qties OR $product->quantity <= 0) OR $allow_oosp OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if} >{l s='Warning: Last items in stock!'}</p>

Thanks and have a nice day

Link to comment
Share on other sites

  • 2 months later...
  • 2 months later...

use this simple code:

{if $product->quantity ==2}{l s='Last 2 items in stock!'}{/if}
{if $product->quantity ==1}{l s='Last item in stock!'}{/if}

nothing more :)

 

Thanks but this doesnt work with attributes. The option in the back office-> products also doesnt work.

 

Is there a solution for this with attributes??

 

Any input is welcome !

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...