Re: Show one left in stock message?
I also tried to add to the code...
Example:
<?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>';
} else {
if ($products_quantity == 4) {
echo '<li>' . TEXT_FOUR_LEFT . '</li>';
} else {
if ($products_quantity == 5 {
echo '<li>' . TEXT_FIVE_LEFT . '</li>';
} else {
if ($products_quantity == 6) {
echo '<li>' . TEXT_SIX_LEFT . '</li>';
} else {
if ($products_quantity == 7) {
echo '<li>' . TEXT_SEVEN_LEFT . '</li>';
} else {
if ($products_quantity == 8) {
echo '<li>' . TEXT_EIGHT_LEFT . '</li>';
} else {
if ($products_quantity == 9) {
echo '<li>' . TEXT_NINE_LEFT . '</li>';
} else {
if ($products_quantity == 10) {
echo '<li>' . TEXT_TEN_LEFT . '</li>';
} else {
if ($products_quantity == 11) {
echo '<li>' . TEXT_ELEVEN_LEFT . '</li>';
} else {
if ($products_quantity == 12) {
echo '<li>' . TEXT_TWELVE_LEFT . '</li>';
} else {
if ($products_quantity == 13) {
echo '<li>' . TEXT_THIRTEEN_LEFT . '</li>';
} else {
if ($products_quantity == 14) {
echo '<li>' . TEXT_FOURTEEN_LEFT . '</li>';
} else {
if ($products_quantity == 15) {
echo '<li>' . TEXT_FIFTEEN_LEFT . '</li>';
}}}
?>
And...
<?php
define('TEXT_ONE_LEFT', 'ONLY ONE COPY LEFT!');
define('TEXT_TWO_LEFT', 'LOW STOCK');
define('TEXT_THREE_LEFT', 'In stock');
define('TEXT_FOUR_LEFT', 'In stock');
define('TEXT_FIVE_LEFT', 'In stock');
define('TEXT_SIX_LEFT', 'In stock');
define('TEXT_SEVEN_LEFT', 'In stock');
define('TEXT_EIGHT_LEFT', 'In stock');
define('TEXT_NINE_LEFT', 'In stock');
define('TEXT_TEN_LEFT', 'In stock');
define('TEXT_ELEVEN_LEFT', 'In stock');
define('TEXT_TWELVE_LEFT', 'In stock');
define('TEXT_THIRTEEN_LEFT', 'In stock');
define('TEXT_FOURTEEN_LEFT', 'In stock');
define('TEXT_FIFTEEN_LEFT', 'In stock');
?>
Still produces blank page...
Re: Show one left in stock message?
Re: Show one left in stock message?
I am also getting this error message "syntax error, unexpected $end" from tpl_product_info_display.php on line 319. Line 319 is the last line of code and only has </div> on it
Re: Show one left in stock message?
Wow! No one on this? :huh:
Re: Show one left in stock message?
try changing
PHP Code:
if ($products_quantity == 15) {
echo '<li>' . TEXT_FIFTEEN_LEFT . '</li>';
}}}
?>
to
PHP Code:
if ($products_quantity == 15) {
echo '<li>' . TEXT_FIFTEEN_LEFT . '</li>';
}}}}}}}}}}}}}}}
?>
Re: Show one left in stock message?
Hi rbarbour! Thank you for the reply. I made the suggested changes and I still get a blank page. I should elaborate on what I mean by blank page. When I say blank page, I still get the header and banner and all that, but I lose the actual product listing... picture, description, price, etc. Any idea? Thanks!!!
Re: Show one left in stock message?
By the way this does work for me if I leave the code the way you originally had it.
Re: Show one left in stock message?
Quote:
Originally Posted by
rbarbour
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!
Quote:
Originally Posted by
doooomed
Hello,
I am trying to alter this a little and am having some trouble. All I want to do is eliminate the "define('TEXT_THREE_LEFT', 'Hurry, while supplies last!');" part of this.
Your code example posted above suggests that you're doing nothing special for 3 or greater, so following that pattern, you would just do this:
The following ...
Code:
<?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>';
}}}
?>
becomes:
Code:
<?php
if ($products_quantity == 1) {
echo '<li>' . TEXT_ONE_LEFT . '</li>';
} else {
if ($products_quantity == 2) {
echo '<li>' . TEXT_TWO_LEFT . '</li>';
} else { echo 'In Stock';}}
?>
The nesting of { and } braces is really odd in there. More complicated than it needs to be, but I fear that if I posted tidier code then you might miss the correct cleanup, so I only edited the very tiny bit shown.
Re: Show one left in stock message?
Works Awesome! Thank you Doc! I just sent you guys a few bucks :jump::jump:
I was wondering how I would go about putting one of those "bullet" dots like the others have into this? Also, would it be possible to make the fonts different colors? Green: In Stock, Yellow: Low Stock, Red: One left
Re: Show one left in stock message?
Those "bullet dots" are created by the <li> ... </li> tags wrapped around it.
So you could do this:
Code:
} else { echo '<li>In Stock</li>';}}
or for consistency with the other defined phrases, maybe do this:
Code:
} else { echo '<li>' . TEXT_IN_STOCK . '</li>';}}
And then that would allow you to add styling to those various phrases all in one place:
Code:
define('TEXT_ONE_LEFT', '<span style="color:red">ONLY ONE COPY LEFT!</span>');
define('TEXT_TWO_LEFT', '<span style="color:yellow">LOW STOCK</span>');
define('TEXT_IN_STOCK', '<span style="color: green">In stock</span>');