Copy of Shopping Cart Code Does not Work!

Problems installing or using the NOP Design Free Shopping Cart that do not fit into one of the above categories.

Moderators: Koibito, Stefko, Randy

Copy of Shopping Cart Code Does not Work!

Postby garytanis » Sun Nov 09, 2008 6:09 pm

Hello,

Until now I am experimenting to see if NOP Cart can work for my application. I started off by trying something that I felt sure would work. I copied just the lines of the code from one of the products of the Sample Store, and then pasted it into my html editor document page (Dreamweaver). I saved the file by the name test.html in the htdocs directory of the Sample Store which I downloaded to my computer. When I looked at it in my browser I could see the "Buy Now" button and a Quantity Field. When I clicked on the "Buy Now" button, it took me to another screen that would normally show a list of items in the Shopping Cart, but for some reason it does not add my item to the cart. It just says that it is an Empty Cart. I see the information in the code referring to the product, the price and the shipping, but none of that information is added to the Shopping Cart list. The code that I am using is as below and I have pasted it on the page as html. Can anyone tell me where I am going wrong?

<!--Shopping Cart Begin-->
<p>
<form name=order action="managecart.html" onSubmit="AddToCart(this);">
Quantity:
<input type=text size=2 maxlength=3 name=QUANTITY onChange='this.value=CKquantity(this.value)' value="1">
<input name="image" type="image" value="Add to Cart" src="./images/buynow.gif" align=top border=0>

<input type=hidden name=PRICE value="79.95">
<input type=hidden name="NAME" value="Chili Peppers">
<input type=hidden name="ID_NUM" value="VCP1">
<input type=hidden name=SHIPPING value="9.95">
</form>
<!--Shopping Cart End -->
garytanis
WebMaster
 
Posts: 3
Joined: Sun Nov 09, 2008 5:23 pm

Re: Copy of Shopping Cart Code Does not Work!

Postby Randy » Mon Nov 10, 2008 1:32 pm

You took a big jump!
The zip file has everything in it except the checkout php/Perl files, which you download separately -- the link is in the instructions.
The normal procedure is to Unzip the demo and make sure it works first.
The demo will work right out of the box, no editing required. This is necessary for those using Front Page, since that editor seems to think it knows how to code better than you do, and changes the code without telling you!

On your product page, make sure you call the Language-xx.js file first and then nopcart.js.
Your browser must have Javascript turned on and allow cookies.
When you click on the buy button, you should get a dialog box that tells you it has been added to the cart.

If it still doesn't work, try getting the demo working on your computer, and then edit a product page by inserting one of your products into it. If it still works, you are doing things right, so continue with the transfer of products.

One big help with Javascript is the Error console in FireFox. Load up FireFox, go to Tools, click on Error console before looking at your page. It will tell you the error, in what file and which line it occurs on! It will even point out the offending character!

It is great fun, so enjoy!
Randy
Randy
Guru
 
Posts: 1511
Joined: Tue Apr 22, 2003 12:21 pm
Location: Thunder Bay, Ontario

Re: Copy of Shopping Cart Code Does not Work!

Postby garytanis » Tue Nov 11, 2008 3:36 pm

Hello Randy,

Thank you for replying so quickly. Actually, I did not really start at the point that I described. I did download the zip file first. Then I worked with the existing store and everything worked fine. I even changed some of the products to mine and the shopping cart worked fine. This was all on my computer. My problem started when I copied the shopping cart script and pasted it onto another html. I will try what you suggested. My first question is What do you mean by: "On your product page, make sure you call the Language-xx.js file first and then nopcart.js."? The second question is, What do I do with the PHP/Perl files when I download them? I mean, how do I integrate them into the shopping cart so that it will work? I look forward to your reply.

Gary
garytanis
WebMaster
 
Posts: 3
Joined: Sun Nov 09, 2008 5:23 pm

Re: Copy of Shopping Cart Code Does not Work!

Postby Randy » Wed Nov 12, 2008 3:44 pm

This code in blue must be included in each html page that is accessing nopcart:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>
The Ultimate Delicacy: Your Source for Gourmet Foods
</title>
<link type="text/css" rel="stylesheet" href="./nopcart.css">
<script type="text/javascript" SRC="./language-en.js" language="JavaScript"></script>
<script type="text/javascript" SRC="./nopcart.js" language="JavaScript">
//=====================================================================||
// NOP Design JavaScript Shopping Cart ||
// ||
// For more information on SmartSystems, or how NOPDesign can help you ||
// Please visit us on the WWW at http://www.nopdesign.com ||
// ||
// JavaScript Shop Module, V.4.4.0 ||
//=====================================================================||
</script>
</head>

If you have it up on a server, you can always post your URL along with the question so we can take a peek if necessary.

The Perl or PHP Checkout files will only work from your server. They both do the same thing, use the language that your server will process. These files are the ones that email you and your customer the cart contents, billing and shipping info etc. Just remember that if you are processing your own credit cards, checkout must be on a secure server.

Don't worry about checkout right away, get the product pages working first.
This forum has a lot of information on payment processor integration and various other forms of checkout in use.

There are excellent tutorials on JavaScript on the net, and I would recommend 2 books that I use all the time:
"JavaScript for Dummies" and Danny Goodman's "JavaScript Bible". Both should be available at the Public Library if you want to take a look before buying them.

It is a lot of fun!

Randy
Randy
Guru
 
Posts: 1511
Joined: Tue Apr 22, 2003 12:21 pm
Location: Thunder Bay, Ontario

Re: Copy of Shopping Cart Code Does not Work!

Postby garytanis » Wed Nov 12, 2008 9:31 pm

Hello Randy,

Thank you for your quick reply. I added the code that you gave me to html page in question. You did not say exactly where in the page it should go so I guessed that it should go between the Head tags since that was the way the code was written. In any case that is where I put it but it still does not work. The URL of that page is below. It takes me to the shopping cart page but like before, it does not add the item to the shopping cart list. Where am I going wrong?

Gary


http://harekrishnaculturalcenter.org/Sh ... s/test.htm
garytanis
WebMaster
 
Posts: 3
Joined: Sun Nov 09, 2008 5:23 pm

Re: Copy of Shopping Cart Code Does not Work!

Postby Randy » Thu Nov 13, 2008 1:38 pm

Just use the part of the code in blue -- the rest is for placement.

Make sure the page has a DOCTYPE at the top -- Dreamweaver will do most of the page coding for you.

Randy
Randy
Guru
 
Posts: 1511
Joined: Tue Apr 22, 2003 12:21 pm
Location: Thunder Bay, Ontario

Re: Copy of Shopping Cart Code Does not Work!

Postby NiceTxn » Sun May 02, 2010 5:44 pm

I have not been able to get the shopping cart to work in FireFox. When I run the Error Console, I get a AddToCart not defined message. I dowloaded the working site and ran that in FireFox as well, and it does not work. It does work in IE7. I checked to make sure I had JavaScript and cookies enabled in FireFox. Any ideas what to check next?
NiceTxn
WebMaster
 
Posts: 1
Joined: Sun May 02, 2010 4:58 pm


Return to Help: Cart / General

Who is online

Users browsing this forum: Exabot [Bot], wuhuilin11 and 5 guests