Free Stuff

NOP's Free Shopping Cart JavaScript cart modification

NOP's Free Shopping Cart is a free shopping cart written in JavaScript. The interesting thing about having a cart written in JavaScript is that it is super easy to add it to existing HTML documents. This is what originally attracted me to it. I had a client who needed a simple / cheap shopping cart solution. She wanted to be able to add the cart herself to existing documents, but needed to have a few initial pages set up for her to use as an example.

I set up the cart and soon realized one of its limitations is that it relies on cookies to hold the cart data. The problem with this is if you switch domains in the course of the checkout, you can not read the cookie from your checkout page. I noticed that most of the data is passed along via a GET method, so a quick and dirty solution was to grab the contents from the URL and rebuild the cart data from that. I originally created a solution using PHP, which worked well for my client, and released the code as a modification back to the NOP forum.

When the code from the original forum thread disappeared, I rewrote the fix from scratch in JavaScript, this time keeping it as simple as possible. I have not tested it in a live production environment, so I make no guarantee that this is going to work for you. If you need support or further modifications, don't hesitate to put what it is you need done in the comment section of your PayPal donation.

— Jared Eckersley

Usage

  1. Set HiddenFieldsToCheckout = true; in your nopcart.js file.
  2. Replace the nopcart.js file on your secure server with my modified version.
  3. Locate the line in your checkout page that says CheckoutCart(); and place getQueryVariable(); on a line before that one.

Download

nopcart.js

Donate