This is an old revision of the document!
Table of Contents
The JSON Cart Object
In an effort to make FoxyCart as flexible, customizable, and “Web 2.0” as possible, we've provided a JSON cart object for you to manipulate to your heart's content. As of v0.4.0, the JSON object is loaded:
- Whenever you call
foxycart_includes.js - your cart
- your checkout
- your receipt
Additionally, you can retrieve the JSON at any time by calling:
https://example.foxycart.com/cart?output=json&cart=view
This is described here.
Helper Functions
To run a function either before or after an “add to cart” request is handled, please read the documentation on included functions, such as fc_PreProcess() and fc_BuildFoxyCart().
JSON Example Output
This JSON structure is current as of v0.4.0. If you're using an earlier version you can use Firebug to see the structure of the JSON object.
fc_json = { "products":[ { "id": "2951", "name": "testing 01", "code": "001a", "options": {"color":"red"}, "quantity": 4, "price_each": 14, "price": 56, "shipto": "", "category": "DEFAULT" }, { "id": "2955", "name": "testing", "code": "", "options": {}, "quantity": 4, "price_each": 9.00, "price": 36, "shipto": "", "category": "DEFAULT" }], "product_count": 8, "total_price": 92, "session_id": "blnj77nik4equdg7ou0emr3kd4", "coupons":{ "$5 off all orders over $5!":-5 }, "custom_fields":{ "custom_id":"0123abcd", "other_custom_field":"my value" } };
Example Tutorial with JSON
Example JSON cart display. Adding a mini-cart to display cart quantity and total price, sitewide.