X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Color coded order status... (https://forum.x-cart.com/showthread.php?t=4949)

adpboss 10-26-2003 04:31 PM

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.

dealsondeals 10-27-2003 07:32 AM

:wink: Nicely Done!

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

Regards,

G;en

adpboss 10-28-2003 02:13 PM

Could really use some help with my code

It's so close

pipercub 10-28-2003 02:51 PM

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!

adpboss 10-28-2003 03:00 PM

Nah that don't work but thanks for trying.

I have another idea....

pipercub 10-28-2003 04:34 PM

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

Piper

adpboss 10-28-2003 04:39 PM

LOL!

We are blind!

This didn't work either. I wish I knew more about this stuff.

pipercub 10-28-2003 05:40 PM

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

adpboss 10-28-2003 06:04 PM

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.

enge919 11-07-2003 11:07 PM

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?


All times are GMT -8. The time now is 12:29 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.