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

Add to cart button on product listing

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 11-28-2002, 10:48 PM
 
funkydunk funkydunk is offline
 

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

Default Add to cart button on product listing

Just wanting to do what it says - in the main product list, I would like an add to cart button rather than having to click on see details before doing this.

Has anyone done this already before I try and figure it out?

Cheers
__________________
ex x-cart guru
Reply With Quote
  #2  
Old 11-29-2002, 01:27 PM
  leed's Avatar 
leed leed is offline
 

Senior Member
  
Join Date: Nov 2002
Location: England (UK)
Posts: 128
 

Default

FD

We did ours this way. Here is the code for our products.tpl (skin1/customer/main). As our products show in 2 columns, 2 rows, so you may have to juggle around with the placement of the code (form/endform>) to get it to work.

Good Luck

LeeD
Code:
{* $Id: products.tpl,v 1.16 2002/09/25 10:12:05 zorg Exp $ *} <table border=0 width=100%><tr><td> <table border=0 width=100%> {section name=product loop=$products} {if $smarty.section.product.index is div by 2} </tr><tr valign="top"> {/if} <td valign="top"> <table border=0 width=100%> <tr><td width=90 align=center 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=70 product=$products[product].product} { $lng.lbl_see_details }</a> </td> <td valign=top> {$products[product].productcode | escape} - {$products[product].product|escape}</font> <font class=TableCenterProductTitleOrange></font> <font size=1> {$products[product].descr|truncate:300:"...":true} </font> <hr size=1 noshade width=230 align=left> {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/(100-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=TableCenterProductTitleOrange>{$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} {else} <font class=TableCenterProductTitleOrange>{$lng.lbl_enter_your_price}</font> {/if} {/if} </td> <tr><td> [b]<form name=orderform_{%product.index%} method=post action="cart.php?mode=add"> <td align=left> <a href="javascript: document.orderform_{%product.index%}.submit[/i]()"> {include file="buttons/add_to_cart.tpl"}</a> <input type=hidden name=amount value=1> <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}"> <a href=product.php?productid={$products[product].productid}&cat={$cat}&page={$navigation_page}>{include file="buttons/moreinfo.tpl"}</a> </td> </form>[/b] </td> </tr> </tr> </table> <table width="100" border="0" cellspacing="0" cellpadding="0"> <tr> </tr> </table> </td> {/section} </td></tr></table> </td></tr></table> [b][/b]
__________________
Why a mouse when it spins ......
X-Cart Gunslingers - For Hire!!
http://forum.x-cart.com/viewtopic.php?t=8615
Reply With Quote
  #3  
Old 11-29-2002, 01:28 PM
  leed's Avatar 
leed leed is offline
 

Senior Member
  
Join Date: Nov 2002
Location: England (UK)
Posts: 128
 

Default

Ooops ..just noticed a [/i] in the 2nd line of bold code....remove it ..
__________________
Why a mouse when it spins ......
X-Cart Gunslingers - For Hire!!
http://forum.x-cart.com/viewtopic.php?t=8615
Reply With Quote
  #4  
Old 11-29-2002, 10:58 PM
 
funkydunk funkydunk is offline
 

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

Default

Presumeably the morinfo.tpl is a button template that you have created?

Will try this - thanks.
__________________
ex x-cart guru
Reply With Quote
  #5  
Old 11-30-2002, 03:34 AM
  leed's Avatar 
leed leed is offline
 

Senior Member
  
Join Date: Nov 2002
Location: England (UK)
Posts: 128
 

Default

yep it is ..you can just ignore it
__________________
Why a mouse when it spins ......
X-Cart Gunslingers - For Hire!!
http://forum.x-cart.com/viewtopic.php?t=8615
Reply With Quote
  #6  
Old 11-30-2002, 11:10 AM
 
funkydunk funkydunk is offline
 

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

Default

Perfect - work a treat

cheers
__________________
ex x-cart guru
Reply With Quote
  #7  
Old 01-11-2003, 02:44 PM
 
John7 John7 is offline
 

Senior Member
  
Join Date: Jan 2003
Posts: 136
 

Default

Okay I've installed this script to ad item to cart from product listing and it works like a charm.

But one small problem. I also need to have the color selections display on the product listing page with the ad item to cart button.

Thanks

John
Reply With Quote
  #8  
Old 01-11-2003, 07:25 PM
 
FishBookStore FishBookStore is offline
 

Advanced Member
  
Join Date: Oct 2002
Posts: 58
 

Default In Stock?

You should check to see if it is in stock before displaying the Add to Cart button.
__________________
Regards
Mark

FishBookStore.com
Version (3.3.1) (Not Live)
Reply With Quote
  #9  
Old 01-11-2003, 09:28 PM
 
John7 John7 is offline
 

Senior Member
  
Join Date: Jan 2003
Posts: 136
 

Default

Actually you see its the code itself. I think it needs to be modified to be able to do more than just display the ad buttom it needs to display the choice of which color.

Do you understand?
Reply With Quote
  #10  
Old 01-14-2003, 09:44 PM
 
mgraffix mgraffix is offline
 

Member
  
Join Date: Jan 2003
Location: Tucson, Arizona
Posts: 25
 

Default

LeeD, Just wanted to say thanks, I was looking for help with something else, came across this, - a little cutting and pasting, and Wa La, it works like a charm.
__________________
Cristy
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


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 12:20 PM.

   

 
X-Cart forums © 2001-2020