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

ADD TO CART ????
 
Reply
   X-Cart forums > X-Cart 4 > Changing design
 
Thread Tools Search this Thread
  #1  
Old 09-19-2002, 01:53 PM
 
CrazyLou CrazyLou is offline
 

Newbie
  
Join Date: Sep 2002
Posts: 2
 

Default ADD TO CART ????

I would like to have an add to cart option on the full product catagory listing or in search results.

Is this possible
Reply With Quote
  #2  
Old 09-19-2002, 02:49 PM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

I took this from the old forum. you can see it in full here --> http://mysitedesigns.com/XcartForum/viewtopic.php?t=8


Quote:
It isn't as hard as it sounds to add a button (or text link) to the /customer/main/products.tpl (Product Listing) so a customer can add a product to their cart without having to first view it in greater detail.

First thing we need to do is figure out how the /customer/main/product.tpl (Product Detail) is calling the add to cart. Once we know that we can put the Add To Cart in the Product Listing page any which way we like.

In the Product Detail page I see we need a form tag (<form name=orderform method=post action="cart.php?mode=add">). We also will need to assume the customer only wants one of that item, for simplicity's sake, so we create a hidden form field indicating that (<input type=hidden name=amount value=1>). I don't see the point of redundancy, but for the sake of arguement let's go ahead and reitterate to the PHP script what mode we want for the cart (<input type=hidden name=mode value=add>).

Now for the fun part. We need to tell the cart which item to add (<input type=hidden name=productid value="{$products[product].productid}">) and from which category it is in (<input type=hidden name=cat value="{$smarty.get.cat}">). Then we add another hidden field to tell the script where we came from for the location.tpl (<input type=hidden name=page value="{$smarty.get.page}">). The second to last thing we do is add the button (or text or whatever) so the user can just click it from the Product Listing page ({include file="buttons/add_to_cart.tpl"}). The final thing of course is to close the form (</form>).

Your form should look like this as a minimum:

<form name=orderform method=post action="cart.php?mode=add">
<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="javascript: orderform.submit()">
{include file="buttons/add_to_cart.tpl"}</a>
</form>

This should be sufficient for adding an Add To Cart button/link to the Product Listing. Hopefully this will clear up alot of the questions going around about this. If you need any further help then please let me know, I will help where I can.

- Ken

* Note: This has been edited from the original post to reflect the correct code to create an Add To Cart button to your Product Listing page. *

Last edited by eclipsboi on Mon Sep 02, 2002 3:42 am, edited 1 time in total


Hope that helps
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Changing design


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 06:37 PM.

   

 
X-Cart forums © 2001-2018