NOTE: see the comments for updates about how this went in the end.
I think I’ve unearthed a conspiracy. In the wonderful world of the world-wide web (that’s WWWWW for short), with so much information available, and so many companies selling online, surely there must be a collection of standard procedures for implementing an online shop, and reliable sources of information covering them? Apparently not. How else to explain this except an evil conspiracy? In particular, an evil conspiracy against web designers and developers.
This post is drawn from an e-mail that I sent to a tech savvy client, a small business owner. The email summarized their options for e-commerce, in the specific context of the UK, and it was the result … read on »
Posts Tagged ‘ecommerce’…
FoxyCart: Replacing A Cart Item
function add_pre_process() {
//Find the id of the existing registration in the cart, if it does exist
$.each(fc_json.products, function(key, product) {
if(product.name=="Registration") {
// Do the remove request, with parameter quantity=0
$.ajax({
async: false,
type: "GET",
url: "https://mydomain.foxycart.com/cart?output=json&cart=update&id="+product.id+"&quantity=0&callback=?" + fc_AddSession(),
dataType: ‘json’
});
}
});
// Add the new one
add_item();
}
function add_item() {
//Get the form data
var submitted_data = $("#signup").serialize();
//Do the add request
$.ajax({
type: "GET",
url: "https://mydomain.foxycart.com/cart?"+submitted_data+"&callback=?" + fc_AddSession(),
dataType: ‘json’
});
}
This javascript/jQuery code gets the contents of your cart (which is in the variable fc_json, made available by foxycart_includes.js), removes any item whose … read on »
©2010 Alistair Robinson