By Josh Bartolomucci | May 02, 2017
By Josh Bartolomucci | December 30, 2016
Most of this was written by steeeeephen, the developer of Narwhal Company’s website. We have a huge crush on him. Read his description of the site’s requirements and his solutions, which might give you some ideas of the power of FoxyCart’s JSON and XML.
Narwhal Co sells mostly one-of-a-kind hand-made accessories made from recycled vintage ties. Because of this, a flexible purchasing system had to be implemented. The system also had to be very transparent, as the look and feel of the site were a high priority. All the shopping cart systems I had tried were either overly cumbersome to setup and work with, or created nightmarish HTML that required hours of tedious trimming and debugging to produce decent looking pages (and code for that matter). Even the stores that bragged about being standards-compliant generate some pretty scary HTML. After weeks of searching for an e-commerce solution that would fit our requirements, we stumbled across FoxyCart. I took the 2-minute tour and that was all it took to realize I had finally found the right system.
Because most of the products in the Narwhal Co. store are one-of-a-kind, it was important to ensure that two people didn’t purchase the same one item. Through use of some AJAX requests, items that are added to a user’s cart they are locked in the database so nobody else can purchase the item for a certain time period: 15 minutes from the user’s last activity on the site.
The inventory system works off of the built-in FoxyCart datafeed. Every time the datafeed is sent, a script goes through the datafeed and makes a list of all the items purchased in the transaction (s). It then automatically changes these products status in the database from available to sold. The other neat feature of the inventory system relates to order fulfillment. Using information pulled from the datafeed a transaction record is created. From this transaction record, the store manager can create a printable invoice to ship with the product, and check which transactions have been shipped and which still need to be.
Before the page is sent the script does the following:
Only products that are marked in the database as available and unlocked are diplayed.
An AJAX (non-asynchronous) request is sent to query the database to get the current status (available, sold, or locked) of the item. This check is important as the item may have been purchased or added to somebody else’s cart since the page initially loaded for this user.
As the cart is being closed (using the
TRUNCATED! Please download pandoc if you want to convert large files.
The views expressed in the above post are the author's own, and may not reflect those of FoxyCart.com LLC.