Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Color coded order status...
 
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features
 
Thread Tools Search this Thread
  #11  
Old 10-26-2003, 04:31 PM
  adpboss's Avatar 
adpboss adpboss is offline
 

X-Man
  
Join Date: Feb 2003
Location: Ontario, Canada
Posts: 2,389
 

Default

Could use some help with this code

Code:
{* $Id: products_colors.tpl,v 1.0 2003/10/26 13:07:50 ADPBoss Exp $ *} {if $products[cat_num].forsale eq "N"} bgcolor="#00CCCC"} {else} {if $products[cat_num].avail eq "0"} bgcolor="#CCCCCC"} {if $products[cat_num].avail eq "1"} bgcolor="#FFFF99"} {/if}

What I want it to do is

1. Check if the product is active or disabled "forsale"
2. Check if the product has an availability of 0 or 1.

I was able to make this work with just checking the avail (inventory) number but cannot seem to combine the two checks. It's probably because I am not very smart at this stuff.

I am sure someone who knows what they are doing could fix this in a minute.
Reply With Quote
  #12  
Old 10-27-2003, 07:32 AM
 
dealsondeals dealsondeals is offline
 

eXpert
  
Join Date: Dec 2002
Location: Dallas, Texas, USA
Posts: 231
 

Default

Nicely Done!

Now that's what I call some value-added programming!

Regards,

G;en
__________________
Never understimate stupidity.
--------
X-Cart Version: 3.5.2
Hosting:mind-in-design.net
Configuration: Virtual Dedicated Server || Intel Pentium 4 2.4 GHZ CPU || 1024MB PC2100 DDR RAM || Linux || PHP 4.3.2 || MySQL server 4.0.14
Reply With Quote
  #13  
Old 10-28-2003, 02:13 PM
  adpboss's Avatar 
adpboss adpboss is offline
 

X-Man
  
Join Date: Feb 2003
Location: Ontario, Canada
Posts: 2,389
 

Default

Could really use some help with my code

It's so close
Reply With Quote
  #14  
Old 10-28-2003, 02:51 PM
 
pipercub pipercub is offline
 

Advanced Member
  
Join Date: Oct 2002
Posts: 82
 

Default

Quote:
Originally Posted by adpboss
Could really use some help with my code

It's so close

I do believe that you can use 'and' in your 'if' statements. So, you code might look something like this:

Code:
{* $Id: products_colors.tpl,v 1.0 2003/10/26 13:07:50 ADPBoss Exp $ *} {if $products[cat_num].forsale eq "N"} bgcolor="#00CCCC"} {else} {if $products[cat_num].forsale eq "N" and $products[cat_num].avail eq "0"} bgcolor="#CCCCCC"} {if $products[cat_num].forsale eq "N" and $products[cat_num].avail eq "1"} bgcolor="#FFFF99"} {/if}

I'm not a master programmer either, so this may be a shot in the dark. Maybe Shan, Boomer or Funky could shed some light on this if thay happen to stroll through here.

Piper

P.S. Let me know what happens!
Reply With Quote
  #15  
Old 10-28-2003, 03:00 PM
  adpboss's Avatar 
adpboss adpboss is offline
 

X-Man
  
Join Date: Feb 2003
Location: Ontario, Canada
Posts: 2,389
 

Default

Nah that don't work but thanks for trying.

I have another idea....
Reply With Quote
  #16  
Old 10-28-2003, 04:34 PM
 
pipercub pipercub is offline
 

Advanced Member
  
Join Date: Oct 2002
Posts: 82
 

Default

How 'bout this...

Code:
{* $Id: products_colors.tpl,v 1.0 2003/10/26 13:07:50 ADPBoss Exp $ *}б═ {if $products[cat_num].forsale eq "N"} bgcolor="#00CCCC"} {else} {if $products[cat_num].forsale eq "N" and $products[cat_num].avail eq "0"} bgcolor="#CCCCCC"} {else} {if $products[cat_num].forsale eq "N" and $products[cat_num].avail eq "1"} bgcolor="#FFFF99"} {/if}

It's the blind leading the blind!

Piper
Reply With Quote
  #17  
Old 10-28-2003, 04:39 PM
  adpboss's Avatar 
adpboss adpboss is offline
 

X-Man
  
Join Date: Feb 2003
Location: Ontario, Canada
Posts: 2,389
 

Default

LOL!

We are blind!

This didn't work either. I wish I knew more about this stuff.
Reply With Quote
  #18  
Old 10-28-2003, 05:40 PM
 
pipercub pipercub is offline
 

Advanced Member
  
Join Date: Oct 2002
Posts: 82
 

Default

One more before I go to bed...

Code:
{* $Id: products_colors.tpl,v 1.0 2003/10/26 13:07:50 ADPBoss Exp $ *}б═б═ {if $products[cat_num].forsale eq "N" bgcolor="#00CCCC"} {elseif $products[cat_num].forsale eq "N" and $products[cat_num].avail eq "0" bgcolor="#CCCCCC"} {elseif $products[cat_num].forsale eq "N" and $products[cat_num].avail eq "1" bgcolor="#FFFF99"} {/if}

I used the 'elseif' to separate the options. Also, there was an extra } in there.

Believe it or not, this is exactly how I teach myself. I try everything using slightly different code until I find the solution. It may take me hours, but I eventually solve the problem as well as learning by trail and error (mostly error).

When all else fails, check other templates to see if you can find similar code and use it as a reference.

Good luck, and good night.

Piper
Reply With Quote
  #19  
Old 10-28-2003, 06:04 PM
  adpboss's Avatar 
adpboss adpboss is offline
 

X-Man
  
Join Date: Feb 2003
Location: Ontario, Canada
Posts: 2,389
 

Default

Yay! Go to bed Piper, you dunnit! Only thing is you had the forsale condition set to "n" in all instances but it should be as below!

Grey - Disabled product, Red - Out of stock, Yellow - Inventory level of 1

http://www.adpmods.com/graphics/x-ample1.gif

Create a file in skin1/main called products_colors.tpl

Code:
{* $Id: products_colors.tpl,v 1.0 2003/10/26 13:07:50 ADPBoss Exp $ *} {if $products[cat_num].forsale eq "N"} bgcolor="#CCCCCC" {elseif $products[cat_num].forsale eq "Y" and $products[cat_num].avail eq "0"} bgcolor="#FF3333" {elseif $products[cat_num].forsale eq "Y" and $products[cat_num].avail eq "1"} bgcolor="#FFFF99" {/if}

Next you need to add the color formatting tags to your skin1/main/products.tpl file

Code:
{* $Id: products.tpl,v 1.22 2002/11/13 07:17:54 alfiya Exp $ *} {section name=cat_num loop=$products} { if %cat_num.first% } <table border=0> <tr class=TableHead> <td>ID</td> <td>Product</td> {if $usertype eq "A" or $active_modules.Simple_Mode ne ""} <TD>Pos.</TD> {/if} <TD>Quantity</TD> <td colspan=2>Shop price</td> <td nowrap>Your price</td> </tr> {/if} <tr> {* START COLOR CODE MOD *} <td width=1% {include file="main/products_colors.tpl"}>#{$products[cat_num].productid}</td> <td width=99% {include file="main/products_colors.tpl"}> <input type=radio name=productid value="{ $products[cat_num].productid }" { if %cat_num.first% }checked{/if}> <a href="product_modify.php?productid={ $products[cat_num].productid }"> <font class=ItemsList>{ $products[cat_num].product|escape|truncate:35:"...":false}</font> </a> </td> {if $usertype eq "A" or $active_modules.Simple_Mode ne ""} <TD nowrap align=right {include file="main/products_colors.tpl"}><INPUT type=text size=4 maxlength=4 value="{$products[cat_num].orderby}" name="product_orderby[{$products[cat_num].productid}]"></TD> {/if} <TD nowrap align=right {include file="main/products_colors.tpl"}><INPUT type=text size=6 maxlength=6 value="{$products[cat_num].avail}" name="product_avail[{$products[cat_num].productid}]"></TD> <td nowrap align=right {include file="main/products_colors.tpl"}> <font class=ProductPriceConverting>{math equation="price/(1-(discount/100))" price=$products[cat_num].price discount=$products[cat_num].discount format="%.1f" assign=unformatted}{include file="currency.tpl" value=$unformatted}</font> </td> <td nowrap align=right {include file="main/products_colors.tpl"}> <font class=AdvancedDiscount> -{$products[cat_num].discount}%</font> </td> <td nowrap align=right {include file="main/products_colors.tpl"}> {* END COLOR CODE MOD *} <input type="text" size="7" value="{$products[cat_num].price}" name="product_price[{$products[cat_num].productid}]"> </td> </tr> { if %cat_num.last% } </table> {/if} {/section}

You will see that I commented where the code change starts and ends. Basically we are adding

Code:
{include file="main/products_colors.tpl"}

inside all of the TD tags that are on the product information lines.

Now, last change. Because we are using red to mark zero stock products, then we had to change the default admin small message css being used on the Advanced Discount display. I created a new CSS style in skin1.css called "AdvancedDiscount". I used a blue colour for the NEW advanced discount display on this page.

You will see the code on the line that produces the discount % display.

Code:
font class=AdvancedDiscount

That's it. Thank Piper for coming up with a really great idea that all of you developers should be incorporating into your cart builds. To the average Joe E-Commerce merchant, this kind of added UI friendliness is a very cool feature.

** One more note, I have changed the hyperlinking on the product name display in main/products.tpl to link to the modify page rather than the details page. I product modify constantly and this is a nice feature for someone like me. Again, thank Piper for the inspiration.
Reply With Quote
  #20  
Old 11-07-2003, 11:07 PM
  enge919's Avatar 
enge919 enge919 is offline
 

Senior Member
  
Join Date: May 2003
Posts: 141
 

Default

I appended the products.tpl as stated but now the list price does not show and the percentage discount shows as -%.

I've been looking at the code but am still a little new, could you please help?
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 07:21 PM.

   

 
X-Cart forums © 2001-2018