Post by Zohaib » 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.

Newbie

Posts

Joined
Mon Sep 10, 2012 5:29 pm

Post by tora0515 » Wed Feb 13, 2013 9:44 am

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

Active Member

Posts

Joined
Fri Jun 15, 2012 3:05 pm

Post by James_K » Fri May 31, 2013 5:45 pm

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????

Newbie

Posts

Joined
Wed May 22, 2013 10:01 pm

Post by James_K » Fri May 31, 2013 6:21 pm

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>

Newbie

Posts

Joined
Wed May 22, 2013 10:01 pm

Post by laurent_11 » Thu Jun 06, 2013 7:51 pm

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!!!

Newbie

Posts

Joined
Thu Jun 06, 2013 7:43 pm

Post by starcked » Wed Jul 24, 2013 3:16 am

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! =)

Newbie

Posts

Joined
Thu Aug 16, 2012 3:57 am

Post by sunsys » Wed Feb 11, 2015 10:10 pm

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

Regards,
Sun Systems
Industrial Electronics and Instrumentation


User avatar
Active Member

Posts

Joined
Tue Jan 27, 2015 5:19 am

Post by Concept211 » Sat Nov 07, 2015 12:20 am

Here's a quick vQmod to avoid editing the system files if anyone needs it.

Attachments


User avatar
New member

Posts

Joined
Fri Oct 14, 2011 1:40 am

Post by webheartpro » Wed Mar 23, 2016 7:43 pm

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?

Newbie

Posts

Joined
Tue Oct 08, 2013 4:28 pm

Post by Concept211 » Thu Mar 24, 2016 1:17 am

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.

User avatar
New member

Posts

Joined
Fri Oct 14, 2011 1:40 am
Who is online

Users browsing this forum: No registered users and 18 guests