Page 2 of 2

Re: "Out Of Stock" text colour change

Posted: Thu Oct 18, 2012 9:06 pm
by Zohaib
I want the code for shoppica theme. this code is not working with it. It is not checking the if condition.

Re: "Out Of Stock" text colour change

Posted: Wed Feb 13, 2013 9:44 am
by tora0515
Had a bit of a different way of doing it, using 1.5.3.1, I don't count down my stock (endless supply...hahaha, just not that high of a turnover to worry about it). Anyway, this is what I did:

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 } ?>
Could probably get away with this, but I haven't tried it yet:

Code: Select all

<?php if ($stock != "In Stock") { ?>
      <span style="color: red;"><?php echo $stock; ?></span><?php } 
else { ?>
 <span><?php echo $stock; ?></span> 
<?php }?>

Re: "Out Of Stock" text colour change

Posted: Fri May 31, 2013 5:45 pm
by James_K
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>
and this code makes black and red and inserts a scroll bar under the description container:

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 } ?>
Any one????

Re: "Out Of Stock" text colour change

Posted: Fri May 31, 2013 6:21 pm
by James_K
Done IT!

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>

Re: "Out Of Stock" text colour change

Posted: Thu Jun 06, 2013 7:51 pm
by laurent_11
Hello there,

I am running a multi-lingual shop (1.5.5.1) and I would like to implement the functionality discussed here (text colour change, based on stock status). However, I understand the solution presented here is based on the verification of a text string - if($stock == "In Stock"). I rather would like to check the amount (numerical value) rather than the stock status, i.e. use the numerical value of $stock. Note that I do not want to display the stock amount in the frontend.

Can someone help?

Thank you!!!

Re: "Out Of Stock" text colour change

Posted: Wed Jul 24, 2013 3:16 am
by starcked
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:

Code: Select all

<span><?php echo $text_stock; ?></span> <?php echo $stock; ?></div>
And replace it with:

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>
I also have the code if you're using the Shoppica theme, so let me know if you need/want it.

Hello! im using shoppica theme, I hope you can help me! i would really appreciate you help! =)

Re: "Out Of Stock" text colour change

Posted: Wed Feb 11, 2015 10:10 pm
by sunsys
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>
...by this script "Out In stock" does become RED but In stock also becomes RED and not BLUE.
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>
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:

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>
Please tell is this ok as I am a total newbee and learning from the masters here, my background is industrial electronics.

...TY

Re: "Out Of Stock" text colour change

Posted: Sat Nov 07, 2015 12:20 am
by Concept211
Here's a quick vQmod to avoid editing the system files if anyone needs it.

Re: "Out Of Stock" text colour change

Posted: Wed Mar 23, 2016 7:43 pm
by webheartpro
Concept211 wrote:Here's a quick vQmod to avoid editing the system files if anyone needs it.
Thank you, works well, but only in English; doesn't works in my language, Danish?

Re: "Out Of Stock" text colour change

Posted: Thu Mar 24, 2016 1:17 am
by Concept211
webheartpro wrote:
Concept211 wrote:Here's a quick vQmod to avoid editing the system files if anyone needs it.
Thank you, works well, but only in English; doesn't works in my language, Danish?
Just change the language path in the file to your danish file.