| View previous topic :: View next topic |
| Author |
Message |
kate!!
Joined: 04 May 2007 Posts: 3
|
Posted: Fri May 04, 2007 3:05 pm Post subject: Shopping Cart |
|
|
Hi everybody,
I'm having problems setting up a shopping cart as JavaScript goes completely over my head. I just want to set something up with an ‘add to cart’ button which will lead to a checkout, listing the items added to the cart and also calculate a total price. I don't need anything to do with credit card details, as I just want them to able to see what they are ordering and then can send a cheque. Also I would need the order to be sent to my clients email address (so she can make up the order). My client will also need their address to send it to.
I have tried the shopping cart on http://www.nopdesign.com/freecart/
Which half works but the things I have changed like monetary symbol for example I changes to £ and when previewed, hasn’t changed (stays as $). Also it doesn't list the items added to cart.
I am so confused and my deadline is nearing!
If anyone can help me it would be really appreciate.
Thanks. Kate. |
|
| Back to top |
|
 |
|
|
LucasZ21 100+ Club

Joined: 26 Feb 2007 Posts: 195 Location: Mansfield, OH
|
Posted: Sat May 05, 2007 12:04 am Post subject: Re: Shopping Cart |
|
|
You should really pay me for this. haha j/k
| Code: |
<html>
<script language="javascript>
<!--
var numItems = 0
var ShoppingCart = newObject
Function addItem(Description, Price, ItemNum) {
this.Description = Description
this.Price = Price
this.ItemNum = ItemNum
this.display = printItem
return this
}
function addtoCart(Description, Price) {
ShoppingCart[numItems] = new addItem(Description, Price, numItems)
numItems = numItems + 1
alert(Description + " has been added to your shopping cart."
}
Function deleteItem(ItemNum) {
delete ShoppingCart[ItemNum]
viewCart()
}
Function printItem(deleteFlag, TargetDocument) {
with (TargetDocument) {
write("<TR<>TD>" + this.Description + "</TD>")
write("<TD ALIGN=RIGHT>$" + this.Price + "</TD>")
if (deleteFlag == true)
write("<TD<A HREF='JavaScript:top.HIDDEN.deleteItem(" + this.ItemNum + ")'>Remove from Cart</A></TD>")
write("</TR>")
}
}
function viewCart() {
var cartTotal = 0
with (top.MAIN.document) {
write()
close()
<!--PUT YOUR OWN TITLE HERE, DELETE WHEN YOU DO--!>
write("<HTML><TITLE>YOUR TITLE HERE!!!!!!!!!!!!!!!!</TITLE")
<!--PUT YOUR OWN HEX CODE HERE, DELETE WHEN YOU DO--!>
write("<BODY BGCOLOR=#HXCODEGOESHERE><CENTER>")
write("<TABLE BORDER=0><TR>")
<!--PUT YOUR OWN IMAGE HERE, DELETE WHEN YOU DO--!>
write(""<TD><IMAGE SRC=IMG GOES HERE></td>")
write("<TD ALIGN=CENTER VALIGN=BOTTOM>")
<!--PUT YOUR OWN HEADING HERE, DELETE THIS WHEN YOU DO--!>
write("<H2>HEADING GOES HERE</H2></TD>")
<!--PUT YOUR OWN IMAGE IN HERE, DELETE WHEN YOU DO--!>
write("<TD><IMAGE SRC=IMAGE SOURCE GOES HERE>
write("<TABLE>")
write("<BR><HR><BR>")
write("<TABLE BORDER=1 CELLPADDING=3 CELLSPACING=1 WIDTH=500 BGCOLOR=WHITE>")
for (i in ShoppingCart) {
cartTotal = cartTotal + ShoppingCart[i].Price
if (ShoppingCart[i].ItemNum != null)
ShoppingCart[i].display(true, top.MAIN.document)
}
write("<TR><TD>Total:</TD><TD ALIGN=RIGHT>$" + cartTotal + "</TD>")
write("<TD> </TD></TR></TABLE><BR>")
write("<BR></CENTER></BODY></HTML>")
}
}
function goBack() {
top.MAIN.history.go(-2)
}
//-->
</script>
</html>
|
I think thats all the code you need to make your shopping cart work. When you design it, use this code to make your links add the items to thier cart....
| Code: |
| <A HRE="Javascript:top.HIDDEN.addtoCart('THE NAME OF YOUR ITEM GOES HERE')>Add to Cart</A> |
Use this as a link to let them view thier cart....
| Code: |
<A HREF="JavaScript:top.HIDDEN.viewCart();")>View Your Shopping Cart</A>
|
Hope it helps!
It's up to you to design it though, I just gave you pretty much all the javascript you need to make it work.
You have to go into the code I wrote and change a few things tho, I put comments in there for you.
I must be in a nice mood....  |
|
| Back to top |
|
 |
kate!!
Joined: 04 May 2007 Posts: 3
|
Posted: Sat May 05, 2007 2:34 pm Post subject: Re: Shopping Cart |
|
|
| Thanks so much for that I'll give it a try and let you know. I really appreciate the help and time you have taken. |
|
| Back to top |
|
 |
LucasZ21 100+ Club

Joined: 26 Feb 2007 Posts: 195 Location: Mansfield, OH
|
Posted: Sat May 05, 2007 3:40 pm Post subject: Re: Shopping Cart |
|
|
| Well we're starting "how to make a shopping cart" in my web design class on monday so...I figured by helping you, i'd actually be doing my homework. :gasp: |
|
| Back to top |
|
 |
|
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums. Click here to Register
If you are a current member here on DEVPPL, please login below:
|
|
|
|