Post by Phil » Fri Feb 18, 2011 6:23 pm

Hi All,

Firstly I just want to say that I think this forum is amazing, I am currently in the process of changing our current website over to opencart and have found endless support using this forum and think that opencart itself is brilliant.

Anyway, I have checked this forum for the last hour or so and cant see any posts that tell me how I can change the colour of the "Out Of Stock" text on the products page, I would like to have the text in red, but only if the product is out of stock?? i.e " In Stock" = Black "Out Of Stock" = Red...... Is this possible, my current test store is located at http://www.pandorasjewellerybox.co.uk/store/ version 1.4.9

Any help is much appreciated.
Thanks,
Phil

New member

Posts

Joined
Fri Feb 18, 2011 6:10 pm


Post by kedgetech » Fri Feb 18, 2011 7:14 pm

You can check the text coming on the product tpl file and change the color to red. We did the same for pre-order. see below.
http://www.opencartaustralia.com/sales/ ... duct_id=30

User avatar
Active Member

Posts

Joined
Mon Mar 22, 2010 5:20 pm
Location - USA, Australia, India

Post by Phil » Fri Feb 18, 2011 10:18 pm

Thanks, for the quick response.

I have just looked at your pre-order as suggested and that is exactly what I would like to do, I'm just not sure how to do it?? ???

I have looked in the product.tpl file and can't see what I am supposed to change.....

Code: Select all

<tr>
                <td><b><?php echo $text_availability; ?></b></td>
                <td><?php echo $stock; ?></td>
              </tr>
I'm assuming that this is the control for the stock status displayed but I'm not sure what I am meant to add so that only "out of stock" shows up in red?

Thanks again for your help.
Phil

New member

Posts

Joined
Fri Feb 18, 2011 6:10 pm


Post by kedgetech » Sun Feb 20, 2011 4:47 am

Very simple if the coming value is equal to PRE-ORDER change the color jazz it up with red if not follow the usual logic. You just need to add a if condition and then color the text. Thats all.

User avatar
Active Member

Posts

Joined
Mon Mar 22, 2010 5:20 pm
Location - USA, Australia, India

Post by Phil » Sun Feb 20, 2011 8:26 am

Many thanks for your help, all is now sorted.

Phil

New member

Posts

Joined
Fri Feb 18, 2011 6:10 pm


Post by Erunix » Thu Mar 03, 2011 10:03 am

I register simply because I was actually searching for more info on items in carts, search, and some other functions and came across this post.

Is great Phil found the solution, and Kedgetech point him on the path to solve his problem. The only thing I saw is that other people with this issue might not be coders, maybe they are just the designer, also taking in consideration the new coders. I just simply give them a view of what the code should do.

Here my fellow OpenCarters:

Code: Select all

 <td><b><?php echo $text_availability; ?></b></td>
                <?php if($stock >= 11){
                $wcd_color_stock = '#006633';
                } elseif($stock <= 10 && $stock >= 5){
                $wcd_color_stock = '#FF9900';
                } elseif($stock <= 4 || $stock == 'SOLD OUT'){
                $wcd_color_stock = '#990033';
                }
                ?>
                <td><span style="font-size:12px;font-weight:bolder;color:<?php echo $wcd_color_stock; ?>;"><?php echo $stock; ?></span></td>
Enjoy.

Newbie

Posts

Joined
Thu Mar 03, 2011 9:57 am

Post by kedgetech » Thu Mar 03, 2011 2:01 pm

@Erunix - You the man ;) Thanks.

User avatar
Active Member

Posts

Joined
Mon Mar 22, 2010 5:20 pm
Location - USA, Australia, India

Post by bassdude » Mon Dec 26, 2011 2:40 pm

Erunix wrote:I register simply because I was actually searching for more info on items in carts, search, and some other functions and came across this post.

Is great Phil found the solution, and Kedgetech point him on the path to solve his problem. The only thing I saw is that other people with this issue might not be coders, maybe they are just the designer, also taking in consideration the new coders. I just simply give them a view of what the code should do.

Here my fellow OpenCarters:

Code: Select all

 <td><b><?php echo $text_availability; ?></b></td>
                <?php if($stock >= 11){
                $wcd_color_stock = '#006633';
                } elseif($stock <= 10 && $stock >= 5){
                $wcd_color_stock = '#FF9900';
                } elseif($stock <= 4 || $stock == 'SOLD OUT'){
                $wcd_color_stock = '#990033';
                }
                ?>
                <td><span style="font-size:12px;font-weight:bolder;color:<?php echo $wcd_color_stock; ?>;"><?php echo $stock; ?></span></td>
Enjoy.
hi. that is very usfull thanks. but also where would i find the tpl to be able to edit this?

Newbie

Posts

Joined
Mon Nov 21, 2011 11:22 am

Post by spharx » Mon Jan 16, 2012 11:26 pm

You find it in /catalog/view/theme/YOU THEME/template/product

Got a question tho:
The code works perfecly if you use stock levels as numbers, but how do i make it work with text instead? I have choosen to not show stock level from admin so it just show "in stock" instead, but then the color is not working.

/Spharx

Newbie

Posts

Joined
Mon Jan 16, 2012 11:22 pm

Post by spharx » Tue Jan 17, 2012 3:48 am

anyone?

Newbie

Posts

Joined
Mon Jan 16, 2012 11:22 pm

Post by markisonfire » Sun Jan 22, 2012 7:27 am

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.

New member

Posts

Joined
Sat Oct 29, 2011 8:33 am

Post by vallentin24 » Sat Feb 04, 2012 5:59 pm

can you post that code for shoppica theme?
thank you

Active Member

Posts

Joined
Fri Feb 03, 2012 1:00 am

Post by temptious » Fri Feb 10, 2012 8:06 pm

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.
Can this code be modified to replace the text for images?

Newbie

Posts

Joined
Fri Feb 10, 2012 8:02 pm

Post by markisonfire » Tue Feb 21, 2012 2:24 pm

temptious wrote:
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.
Can this code be modified to replace the text for images?
I'm not sure what you mean, please elaborate?

New member

Posts

Joined
Sat Oct 29, 2011 8:33 am

Post by Joxe » Fri Mar 09, 2012 7:34 pm

Hello,

I'm also interested in changing the out of stock text in red colour and I tried the markisonfire's solution but didn't worked :-\

My original code is:
<tr>
<td><b><?php echo $text_availability; ?></b></td>
<td><?php echo $stock; ?></td>
</tr>

Any help please? Thanks! ;)
PS: OC v. 1.4.9.6

v. 1.4.9.6 & v. 2.0.2.0


Active Member

Posts

Joined
Wed Apr 28, 2010 6:12 am

Post by Joxe » Wed Mar 14, 2012 5:45 am

Any one please?.....

v. 1.4.9.6 & v. 2.0.2.0


Active Member

Posts

Joined
Wed Apr 28, 2010 6:12 am

Post by eka7a » Wed Mar 14, 2012 9:57 am

Joxe wrote:Hello,

I'm also interested in changing the out of stock text in red colour and I tried the markisonfire's solution but didn't worked :-\

My original code is:
<tr>
<td><b><?php echo $text_availability; ?></b></td>
<td><?php echo $stock; ?></td>
</tr>

Any help please? Thanks! ;)
PS: OC v. 1.4.9.6
you use it for 1.4.9.6
http://forum.opencart.com/viewtopic.php ... 23#p138711

Windows 11 Pro Digital License Key


User avatar
Active Member

Posts

Joined
Sun Apr 12, 2009 12:59 am
Location - Türkiye

Post by zreon » Sun Apr 15, 2012 3:21 am

spharx wrote:You find it in /catalog/view/theme/YOU THEME/template/product

Got a question tho:
The code works perfecly if you use stock levels as numbers, but how do i make it work with text instead? I have choosen to not show stock level from admin so it just show "in stock" instead, but then the color is not working.

/Spharx
Thats exactly what I needed. Well this is what I came up with and it is working for me in 1.5.2.1.

Code: Select all

				<span><?php echo $text_stock; ?></span>      
<?php if($stock == "In Stock") {
       $my_color_stock = '#000';
      } elseif($stock == "Out of stock") {
       $my_color_stock = 'red';
      }
?>
<span style="color: <?php echo $my_color_stock ?>;"><?php echo $stock; ?></span></div>

Newbie

Posts

Joined
Sat Apr 07, 2012 11:45 pm

Post by Joxe » Sun Apr 15, 2012 6:14 am

eka7a wrote: you use it for 1.4.9.6
http://forum.opencart.com/viewtopic.php ... 23#p138711
Sorry, I did not understand...

v. 1.4.9.6 & v. 2.0.2.0


Active Member

Posts

Joined
Wed Apr 28, 2010 6:12 am

Post by CapriBlue » Sun Sep 16, 2012 7:16 am

I tried for 1.5.4.1
The "Out of Stock "color changed as Red but the "in stock" also became Red.

I tried to fix it and changed the part $my_color_stock='#00000'; or just 'black';
but didn't work.

So, on my site, both Out of Stock and In Stock are red color.
Do you have any idea to fix?

Newbie

Posts

Joined
Sat Aug 18, 2012 2:00 pm
Who is online

Users browsing this forum: No registered users and 59 guests