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

Quantity and Add to Cart Button on products.tpl
 
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features
 
Thread Tools Search this Thread
  #1  
Old 04-03-2003, 10:43 AM
 
ucmarty ucmarty is offline
 

Advanced Member
  
Join Date: Mar 2003
Posts: 34
 

Default Quantity and Add to Cart Button on products.tpl

This code is modified from funkydunks code for "Number of Products per Row changeable in admin"

I have just added some extra code so that you can specify quantity to add to cart also. And I removed the View Details button, but that isn't significant ..... I just didn't want it there.

Put in skin1/customer/main/products.tpl
Code:
{* $Id: products.tpl,v 1.21 2002/11/19 12:57:48 alfiya Exp $ and amended further by funkydunk.net*} <table border=0 width=100% cellspacing=0 cellpadding=0> {section name=product loop=$products} {if $smarty.section.product.index is div by $config.General.products_per_row} <tr valign="top"> {/if} <td valign="top"> <table width=100% border=0 cellpadding=3 cellspacing=0> <tr> <td width=100 rowspan="2" align=left valign=top> <a href=product.php?productid={$products[product].productid}&cat={$cat}&page={$navigation_page}>{include file="product_thumbnail.tpl" productid=$products[product].productid image_x=$products[product].image_x image_y=$products[product].image_y product=$products[product].product}</a> </td> <td valign=top width=90%> {$products[product].product|escape}</font> <font class="ProductDetails"> {$products[product].descr|truncate:300:"...":true} </font> {if $active_modules.Subscriptions ne "" and $products[product].catalogprice} {include file="modules/Subscriptions/subscription_info_inlist.tpl"} {else} {if $products[product].price ne 0} {if $products[product].discount ne 0} <font class=MarketPrice>{$lng.lbl_market_price}: <s> {math equation="price/(1-(discount/100))" price=$products[product].price discount=$products[product].discount format="%d.00" assign=unformatted}{include file="currency.tpl" value=$unformatted} </s></font> {/if} <font class=ProductPrice>{$lng.lbl_our_price}: {include file="currency.tpl" value=$products[product].price}</font><font class=MarketPrice>{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$products[product].price}</font>{if $products[product].discount ne 0}, save {$products[product].discount}%{/if}{if $config.General.use_vat eq "Y"}, including VAT {$products[product].vat}%{/if} {else} <font class=ProductPrice>{$lng.lbl_enter_your_price}</font> {/if} {/if} </td> </tr> <tr> <td valign=top> <table width="200" border="0" cellspacing="0" cellpadding="2"> <tr valign="top"> <form name=orderform_{%product.index%} method=post action="cart.php?mode=add"><td> {if $config.General.show_in_stock eq "Y" and ($products[product].avail le 0 or $products[product].avail lt $products[product].min_amount)} {$lng.txt_out_of_stock} {else} {if $config.General.show_in_stock ne "Y"} {assign var="mq" value=$config.General.max_select_quantity} {else} {math equation="min(maxquantity+minamount, productquantity)+1" assign="mq" maxquantity=$config.General.max_select_quantity minamount=$products[product].min_amount productquantity=$products[product].avail} {/if} {if $products[product].distribution eq ""} <select name=amount> {if $products[product].min_amount le 1} {assign var="start_quantity" value=1} {else} {assign var="start_quantity" value=$products[product].min_amount} {/if} {section name=quantity loop=$mq start=$start_quantity} <option value="{%quantity.index%}" {if $smarty.get.quantity eq %quantity.index%}selected{/if}>{%quantity.index%}</option> {/section} </select> {else} <font class=ProductDetailsTitle>1</font><input type=hidden name=amount value=1> {$lng.txt_product_downloadable} {/if} {/if} </td> <td> <input type=hidden name=mode value=add> {if $config.General.show_in_stock ne "Y" or ($product.avail gt 0 and $product.avail ge $product.min_amount)} {include file="customer/main/product_prices.tpl"} {include file="buttons/add_to_cart.tpl"}б═б═б═б═б═б═б═ {/if} {if $product.discount ne 0}<table border=0 width=60><tr><td width=55 height=56 class="SaveMoneyLabel" background="{$ImagesDir}/save_money.gif" align=center valign=middle> б═ { $product.discount }% </td></tr></table> {/if} <input type=hidden name=mode value=add> <input type=hidden name=productid value="{$products[product].productid}"> <input type=hidden name=cat value="{$smarty.get.cat}"> <input type=hidden name=page value="{$smarty.get.page}"> </form></td> </tr> </table></td> </tr> <tr colspan=2><HR color=ff0000></tr> </table> </td> {/section} </tr> </table>

If anyone notices any problems I have overlooked please let me know.
Otherwise, I hope you can find it useful.
Reply With Quote
  #2  
Old 04-04-2003, 12:34 PM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

nice bit of coding

only thing I would say is it is genrally a good idea to try to keep maths equations outside of loops such as this cos they can really hit the speed of the pages. Great equation though

Haven't tried it but read the code but it looks like it would work very well indeed.
__________________
ex x-cart guru
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 09:49 PM.

   

 
X-Cart forums © 2001-2018