Show one left in stock message?
Is there a way to have a message automatically come up on the product page saying "only 1 left in stock" when the stock level reaches 1, instead of showing how many is in stock otherwise? I hope this makes sense lol. Any help is greatly appreciated!!!
Re: Show one left in stock message?
I did something similar before, I will post that code so you get the idea. My PHP skills aren't that great but it works.
in:
/includes/templates/YOUR_TEMPLATE/templates/tpl_product_info_display.php
find:
PHP Code:
<?php echo (($flag_show_product_info_quantity == 1) ? '<li>' . $products_quantity . TEXT_PRODUCT_QUANTITY . '</li>' : '') . "\n"; ?>
change to:
PHP Code:
<?php echo (($flag_show_product_info_quantity == 1 && $products_quantity >3) ? '<li>' . $products_quantity . TEXT_PRODUCT_QUANTITY . '</li>' : '') . "\n"; ?>
<?php
if ($products_quantity == 1) {
echo '<li>' . TEXT_ONE_LEFT . '</li>';
} else {
if ($products_quantity == 2) {
echo '<li>' . TEXT_TWO_LEFT . '</li>';
} else {
if ($products_quantity == 3) {
echo '<li>' . TEXT_THREE_LEFT . '</li>';
}}}
?>
then in:
/includes/languages/english/YOUR_TEMPLATE/product_info.php
Add:
PHP Code:
define('TEXT_ONE_LEFT', 'Are you feeling lucky, only 1 available!');
define('TEXT_TWO_LEFT', 'Don\'t miss out, only 2 left.');
define('TEXT_THREE_LEFT', 'Hurry, while supplies last!');
if the languages file product_info.php doesn't exist, create it.
Hope this helps!
Re: Show one left in stock message?
Nice one rbarbour :clap:! It may be a good idea to put the defines in a separate file
Will certainly keep this piece of code on file for future reference - thanks.
Re: Show one left in stock message?
thanks for the update that this works for you!
Re: Show one left in stock message?
Quote:
Originally Posted by
frank18
It may be a good idea to put the defines either in a separate file.
I thought it was!
Quote:
Originally Posted by
rbarbour
then in:
/includes/languages/english/YOUR_TEMPLATE/product_info.php
Add:
PHP Code:
PHP Code:
define('TEXT_ONE_LEFT', 'Are you feeling lucky, only 1 available!');
define('TEXT_TWO_LEFT', 'Don\'t miss out, only 2 left.');
define('TEXT_THREE_LEFT', 'Hurry, while supplies last!');
Re: Show one left in stock message?
Something like this:
includes/languages/english/extra_definitions/YOUR_TEMPLATE/one_left_defines.php
Re: Show one left in stock message?
Re: Show one left in stock message?
Thanks to everyone who replied! I have been trying different things to get this to work but am having no luck. The following seems to be the problem... (I think)
Quote:
Originally Posted by
rbarbour
then in:
/includes/languages/english/YOUR_TEMPLATE/product_info.php
Add:
PHP Code:
define('TEXT_ONE_LEFT', 'Are you feeling lucky, only 1 available!');
define('TEXT_TWO_LEFT', 'Don\'t miss out, only 2 left.');
define('TEXT_THREE_LEFT', 'Hurry, while supplies last!');
if the languages file product_info.php doesn't exist, create it.
Hope this helps!
I follow everything up to /includes/languages/english but after that I don't have a your_template folder. I tried adding one and then creating a product_info.php file but still no luck. Anyone know what I'm doing wrong? I am using the Mostly Grey template and zencart version 1.3.9h
Thanks!
Re: Show one left in stock message?
your_template = the Mostly Grey template name ( i think it is mostlygrey )
go to admin > tools > template selection
What does it say under Template Directory?
Re: Show one left in stock message?
Thanks for the reply. You are correct, it is mostlygrey, but as I said I go to /includes/languages/english and there is no mostlygrey folder or any other template folder. I created one and the product_info.php but had no luck getting it to work.