X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Products.tpl - What is safe to get rid of? (https://forum.x-cart.com/showthread.php?t=21730)

Grant 05-15-2006 08:33 AM

Ok I've sorted it out now. I'm using multiple templates for both products and catergories. Here is the products_t.tpl I played around with below just in case it's at all useful to anybody else and a little screen shot of how it renders.

http://www.wyzeshop.com/screenshot5.jpg

Quote:

{* $Id: products_t.tpl,v 1.10.2.12 2006/02/27 08:53:50 svowl Exp $ *}
<TABLE border="0" width="100%" cellpadding="0" cellspacing="0"><TR><TD class="TableThumbnailBorder">

<TABLE border="0" width="100%" cellpadding="5" cellspacing="1">

{math equation="floor(100/x)" x=$config.Appearance.products_per_row assign="width"}

{section name=product loop=$products}
{assign var="discount" value=0}

{if %product.index% is div by $config.Appearance.products_per_row}
<TR>
{assign var="cell_counter" value=0}
{/if}

{math equation="x+1" x=$cell_counter assign="cell_counter" }

<TD align="center" valign="top" width="{$width}%" class="DialogBox">
<TABLE cellpadding="3" cellspacing="0" border="0" height="120">
<TR>
<TD height="100" width="60"> <A href="product.php?productid={$products[product].productid}&cat={$cat}&page={$navigation_page}">{i nclude
file="product_thumbnail.tpl" productid=$products[product].productid
image_x=$config.Appearance.thumbnail_width product=$products[product].product
tmbn_url=$products[product].tmbn_url}</A>
</TD>
<TD width="439">{$products[product].product}

{$lng.lbl_sku}: {$products[product].productcode}

{if $active_modules.Special_Offers ne "" and $products[product].have_offers}
{include file="modules/Special_Offers/customer/product_offer_thumb.tpl"
product=$products[product]} {else}{/if} {if $products[product].product_type
ne "C"} </TD>
<TD width="150">{if $active_modules.Subscriptions ne "" and ($products[product].catalogprice
gt 0 or $products[product].sub_priceplan gt 0)} {include file="modules/Subscriptions/subscription_info_inlist.tpl"}
{else} {if $products[product].taxed_price ne 0} {if $products[product].list_price
gt 0 and $products[product].taxed_price lt $products[product].list_price}
{math equation="100-(price/lprice)*100" price=$products[product].taxed_price
lprice=$products[product].list_price format="%3.0f" assign=discount}
{if $discount gt 0} <FONT class="MarketPrice">{$lng.lbl_market_price}:
<S> {include file="currency.tpl" value=$products[product].list_price}
</S></FONT>

{/if} {/if} <FONT class="ProductPrice">{include file="currency.tpl"
value=$products[product].taxed_price}</FONT><FONT class="MarketPrice">{include
file="customer/main/alter_currency_value.tpl" alter_currency_value=$products[product].taxed_price}</FONT>{if
$discount gt 0}{if $config.General.alter_currency_symbol ne
""}, {/if}{$lng.lbl_save_price} {$discount}%{/if} {if $products[product].taxes}

{include file="customer/main/taxed_price.tpl" taxes=$products[product].taxes}{/if}
{else} <FONT class="ProductPrice">{$lng.lbl_enter_your_price}</FONT>
{/if} {/if} {if $active_modules.Feature_Comparison ne '' &&
$products[product].fclassid > 0}

{include file="modules/Feature_Comparison/compare_checkbox.tpl"
id=$products[product].productid} {/if}</TD>
<TD width="100">{if $usertype eq "C" and $config.Appearance.buynow_button_enabled
eq "Y"}
<form style="margin:0;" name="orderform_{$products[product].productid}_{$products[product].add_date}" method="post" action="cart.php?mode=add">
<input type="hidden" name="productid2" value="{$products[product].productid}">
<input type="hidden" name="cat2" value="{$smarty.get.cat|escape:"html"}">
<input type="hidden" name="page2" value="{$smarty.get.page|escape:"html"}">
<input type="hidden" name="amount2" value="1">
<input name="button" type="button" value="{$lng.lbl_add_to_cart}" onclick="document.orderform_{$products[product].productid}_{$products[product].add_date}.submit();">
</form>
{/if}</TD>
</TR>
</TABLE>

{/if} </TD>

{capture name=prod_index}
{math equation="index+x+1" index=%product.index% x=$config.Appearance.products_per_row}
{/capture}
{if $smarty.capture.prod_index is div by $config.Appearance.products_per_row }
</TR>
{/if}

{/section}

{if $cell_counter lt $config.Appearance.products_per_row}
{section name=rest_cells loop=$config.Appearance.products_per_row start=$cell_counter}
<TD class="DialogBox"></TD>
{/section}
</TR>
{/if}

</TABLE>
</TD></TR></TABLE>
{if $active_modules.Feature_Comparison ne '' && $products && $printable ne 'Y'}
{include file="modules/Feature_Comparison/compare_selected_button.tpl"}
{/if}


Grant 05-16-2006 08:51 AM

Zaja,

The code you so generously supplied is working like a charm, again thank you so much. But I have a little problem with it that I can't figure out. I'm sure it's a simple one - well I hope it's a simple one ;)

The 'add to cart' button displays in product listings even if the item is out of stock. Is there a simple fix for this?

Cheers,

G

Quote:

Originally Posted by Zaja
Grant, do you feel lucky today? :D

Replace products.tpl code with this:
Code:

{* $Id: products.tpl,v 1.45.2.17 2006/04/21 08:53:50 svowl Exp $ *}
{if $usertype eq "C" and $config.Appearance.products_per_row ne "" and $config.Appearance.products_per_row gt 0 and $config.Appearance.products_per_row lt 4 and ($featured eq "Y" or $config.Appearance.featured_only_multicolumn eq "N")}
{include file="customer/main/products_t.tpl" products=$products}
{else}
{if $products}
{section name=product loop=$products}
{assign var="discount" value=0}
<table border="0" cellpadding="5" cellspacing="1" width="100%">
<tr style="background-color:{cycle values="#eee,#fff};">
<td style="width:300px;">
<font class="ProductTitle">{$products[product].product}</font>
</td>
<td>
{if $products[product].product_type eq "C"}
{include file="buttons/details.tpl" href="product.php?productid=`$products[product].productid`&cat=`$cat`&page=`$navigation_page`"}
{else}
{if $active_modules.Subscriptions ne "" and ($products[product].catalogprice gt 0 or $products[product].sub_priceplan gt 0)}
{include file="modules/Subscriptions/subscription_info_inlist.tpl"}
{else}
{if $products[product].taxed_price ne 0}
<font class="ProductPrice">{include file="currency.tpl" value=$products[product].taxed_price}</font>
{/if}
{/if}
</td>
<td style="text-align:right;width:110px;">
{if $usertype eq "C" and $config.Appearance.buynow_button_enabled eq "Y"}
<form style="margin:0;" name="orderform_{$products[product].productid}_{$products[product].add_date}" method="post" action="cart.php?mode=add">
<input type="hidden" name="productid" value="{$products[product].productid}">
<input type="hidden" name="cat" value="{$smarty.get.cat|escape:"html"}">
<input type="hidden" name="page" value="{$smarty.get.page|escape:"html"}">
<input type="hidden" name="amount" value="1">
<input type="button" value="{$lng.lbl_add_to_cart}" onclick="document.orderform_{$products[product].productid}_{$products[product].add_date}.submit();">
</form>
{/if}
</td>
{/if}
</tr>
</table>
{/section}
{else}
{$lng.txt_no_products_found}
{/if}
{/if}



Zaja 05-16-2006 09:26 AM

Try to replace:
Code:

<input type="button" value="{$lng.lbl_add_to_cart}" onclick="document.orderform_{$products[product].productid}_{$products[product].add_date}.submit();">
with(not tested):
Code:

{if $product.avail gt 0}
<input type="button" value="{$lng.lbl_add_to_cart}" onclick="document.orderform_{$products[product].productid}_{$products[product].add_date}.submit();">
{else}
{$lng.txt_out_of_stock}
{/if}


Grant 05-16-2006 09:41 AM

Quote:

Originally Posted by Zaja
Try to replace:
Code:

<input type="button" value="{$lng.lbl_add_to_cart}" onclick="document.orderform_{$products[product].productid}_{$products[product].add_date}.submit();">
with(not tested):
Code:

{if $config.General.unlimited_products ne "Y" and ($product.avail le 0 or $product.avail lt $product.min_amount)}
{$lng.txt_out_of_stock}
{else}
<input type="button" value="{$lng.lbl_add_to_cart}" onclick="document.orderform_{$products[product].productid}_{$products[product].add_date}.submit();">
{/if}



Oooppps! Now everything is out of stock?

Zaja 05-16-2006 09:46 AM

I have changed the code, try again please.

Grant 05-16-2006 09:56 AM

Nope still out of stock?

Just in case i'm being a spaz here is my products_t.tpl

Quote:

{* $Id: products_t.tpl,v 1.10.2.12 2006/02/27 08:53:50 svowl Exp $ *}
<TABLE border="0" width="100%" cellpadding="0" cellspacing="0"><TR><TD class="TableThumbnailBorder">

<TABLE border="0" width="100%" cellpadding="3" cellspacing="1">

{math equation="floor(100/x)" x=$config.Appearance.products_per_row assign="width"}

{section name=product loop=$products}
{assign var="discount" value=0}

{if %product.index% is div by $config.Appearance.products_per_row}
<TR>
{assign var="cell_counter" value=0}
{/if}

{math equation="x+1" x=$cell_counter assign="cell_counter" }

<TD align="center" valign="top" width="{$width}%" class="DialogBox">
<TABLE cellpadding="3" cellspacing="0" border="0" height="55">
<TR>
<TD height="50" width="60"> <A href="product.php?productid={$products[product].productid}&cat={$cat}&page={$navigation_page}">{i nclude
file="product_thumbnail.tpl" productid=$products[product].productid
image_x=$config.Appearance.thumbnail_width product=$products[product].product
tmbn_url=$products[product].tmbn_url}</A>
</TD>
<TD width="439">{$products[product].product}

{$lng.lbl_sku}: {$products[product].productcode}

{if $active_modules.Special_Offers ne "" and $products[product].have_offers}
{include file="modules/Special_Offers/customer/product_offer_thumb.tpl"
product=$products[product]} {else}{/if} {if $products[product].product_type
ne "C"} </TD>
<TD width="60"><div align="center">{if $active_modules.Subscriptions
ne "" and ($products[product].catalogprice gt 0 or $products[product].sub_priceplan
gt 0)} {include file="modules/Subscriptions/subscription_info_inlist.tpl"}
{else} {if $products[product].taxed_price ne 0} {if $products[product].list_price
gt 0 and $products[product].taxed_price lt $products[product].list_price}
{math equation="100-(price/lprice)*100" price=$products[product].taxed_price
lprice=$products[product].list_price format="%3.0f" assign=discount}
{if $discount gt 0} <FONT class="MarketPrice">{$lng.lbl_market_price}:
<S> {include file="currency.tpl" value=$products[product].list_price}
</S></FONT>

{/if} {/if} <FONT class="ProductPrice">{include file="currency.tpl"
value=$products[product].taxed_price}</FONT><FONT class="MarketPrice">

<font size="1" face="Geneva, Arial, Helvetica, sans-serif">{include
file="customer/main/alter_currency_value.tpl" alter_currency_value=$products[product].taxed_price}</font>
</FONT><font size="1" face="Geneva, Arial, Helvetica, sans-serif">{if
$discount gt 0}{if $config.General.alter_currency_symbol ne
""}, {/if}</font>
{$lng.lbl_save_price} {$discount}%{/if}
{/if} {/if} {if $active_modules.Feature_Comparison ne '' &&
$products[product].fclassid > 0}

{include file="modules/Feature_Comparison/compare_checkbox.tpl"
id=$products[product].productid} {/if}</div></TD>
<TD width="100">{if $usertype eq "C" and $config.Appearance.buynow_button_enabled
eq "Y"}
<form style="margin:0;" name="orderform_{$products[product].productid}_{$products[product].add_date}" method="post" action="cart.php?mode=add">
<input type="hidden" name="productid" value="{$products[product].productid}">
<input type="hidden" name="cat" value="{$smarty.get.cat|escape:"html"}">
<input type="hidden" name="page" value="{$smarty.get.page|escape:"html"}">
<input type="hidden" name="amount" value="1">
{if $product.avail gt 0}
<input type="button" value="{$lng.lbl_add_to_cart}" onclick="document.orderform_{$products[product].productid}_{$products[product].add_date}.submit();">
{else}
{$lng.txt_out_of_stock}
{/if}
</form>

{/if}</TD>
</TR>
</TABLE>{/if}</TD>
{capture name=prod_index}
{math equation="index+x+1" index=%product.index% x=$config.Appearance.products_per_row}
{/capture}
{if $smarty.capture.prod_index is div by $config.Appearance.products_per_row }
</TR>
{/if}
{/section}
{if $cell_counter lt $config.Appearance.products_per_row}
{section name=rest_cells loop=$config.Appearance.products_per_row start=$cell_counter}
<TD class="DialogBox" height="29"></TD>
{/section}
</TR>
{/if}
</TABLE>
</TD></TR></TABLE>
{if $active_modules.Feature_Comparison ne '' && $products && $printable ne 'Y'}
{include file="modules/Feature_Comparison/compare_selected_button.tpl"}
{/if}

Zaja 05-16-2006 10:03 AM

fixed, replace(in products.tpl):
Code:

{if $product.avail gt 0}
with:
Code:

{if $products[product].avail gt 0}

Grant 05-16-2006 10:06 AM

You are officially THE man! 8)

It be workin' harder than a $5 hooker...

Thanks so much bro ;)

Zaja 05-16-2006 10:10 AM

Quote:

Originally Posted by Grant
You are officially THE man! 8)

It be workin' harder than a $5 hooker...


8) :mrgreen: :wink: :)

Grant 05-16-2006 10:12 AM

I don't wanna take the piss but would you also know the code for placing a form button that is linked to 'show product details'?

As i'm using custom templates I have different things set up all over the place. I'm having a problem as everything that is searched for displays using the same template containing the 'add to cart' button when some products require the customer to select options before hitting the buy button.

I just want to replace the 'add to cart' button with a 'show details' button for the cat listings pulled from a search.


All times are GMT -8. The time now is 10:11 AM.

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