Re: "Out Of Stock" text colour change
Posted: Thu Oct 18, 2012 9:06 pm
I want the code for shoppica theme. this code is not working with it. It is not checking the if condition.
OpenCart Community Forum - Discuss shopping cart and e-commerce solutions.
https://forum.opencart.com/
Code: Select all
<?php echo $text_stock; ?>
<?php if ($stock == "In Stock") { ?>
<span><?php echo $stock; ?></span> <?php }
elseif ($stock != "In Stock") { ?>
<span style="color: red;"><?php echo $stock; ?></span><?php } ?>
Code: Select all
<?php if ($stock != "In Stock") { ?>
<span style="color: red;"><?php echo $stock; ?></span><?php }
else { ?>
<span><?php echo $stock; ?></span>
<?php }?>
Code: Select all
<span><?php echo $text_stock; ?></span>
<?php if($stock >= 1) {
$my_color_stock = 'blue';
} elseif($stock < 1) {
$my_color_stock = 'red';
}
?>
<span style="color: <?php echo $my_color_stock ?>;"><?php echo $stock; ?></span></div>
Code: Select all
<span><?php echo $text_stock; ?></span>
<?php if ($stock == "In Stock") { ?>
<span><?php echo $stock; ?></span> <?php }
elseif ($stock != "In Stock") { ?>
<span style="font-size:14px;font-weight:bolder;color: #FF0000;"><?php echo $stock; ?></span><?php } ?>
Code: Select all
<span><?php echo $text_stock; ?></span>
<?php if($stock == "In Stock") {
$my_color_stock = '#0000FF';
} elseif($stock != "In Stock") {
$my_color_stock = '#FF0000';
}
?>
<span style="font-size:14px;font-weight:bolder;color:<?php echo $my_color_stock; ?>;"><?php echo $stock; ?></span></div>
markisonfire wrote:This is a simple version that works for me, it is only red when something is out of stock.
In /catalog/view/theme/default/template/product/product.tpl, find:
And replace it with:Code: Select all
<span><?php echo $text_stock; ?></span> <?php echo $stock; ?></div>
I also have the code if you're using the Shoppica theme, so let me know if you need/want it.Code: Select all
<span><?php echo $text_stock; ?></span> <?php if($stock >= 1) { $my_color_stock = '#000'; } elseif($stock < 1) { $my_color_stock = 'red'; } ?> <span style="color: <?php echo $my_color_stock ?>;"><?php echo $stock; ?></span></div>
...by this script "Out In stock" does become RED but In stock also becomes RED and not BLUE.James_K wrote:Done IT!Code: Select all
<span><?php echo $text_stock; ?></span> <?php if($stock == "In Stock") { $my_color_stock = '#0000FF'; (to get blue color) } elseif($stock != "In Stock") { $my_color_stock = '#FF0000'; (to get red color) } ?> <span style="font-size:14px;font-weight:bolder;color:<?php echo $my_color_stock; ?>;"><?php echo $stock; ?></span></div>
So I have combined the 2 scripts as given by you and achived the RED and BLUE change in BOLD, please find the changed script below. I have checked its working in OC-1.5.6.4 and it works fine:James_K wrote:HI, we are trying to do the same thing in v1.5.5.1 so In Stock shown as bold blue and Out Of Stock shown as bold red
this code makes all red:Code: Select all
<span><?php echo $text_stock; ?></span> <?php if($stock >= 1) { $my_color_stock = 'blue'; } elseif($stock < 1) { $my_color_stock = 'red'; } ?> <span style="color: <?php echo $my_color_stock ?>;"><?php echo $stock; ?></span></div>
Code: Select all
<span><?php echo $text_stock; ?></span>
<?php if($stock >= 1) {
$my_color_stock = 'blue';
} elseif($stock < 1) {
$my_color_stock = 'red';
}
?>
<span style="font-size:14px;font-weight:bolder;color:<?php echo $my_color_stock; ?>;"><?php echo $stock; ?></span></div>
Thank you, works well, but only in English; doesn't works in my language, Danish?Concept211 wrote:Here's a quick vQmod to avoid editing the system files if anyone needs it.
Just change the language path in the file to your danish file.webheartpro wrote:Thank you, works well, but only in English; doesn't works in my language, Danish?Concept211 wrote:Here's a quick vQmod to avoid editing the system files if anyone needs it.