empty cart redux

drwagner13drwagner13 Member
in Bugs & Feature Requests edited April 2011
It's been awhile since I sent up a site using foxycart. A couple of years ago this script to empty the cart worked great:

$(document).ready(function(){

$('a.emptyCart').click(function() {

// fire the JSONP call

$.getJSON(jQuery(this).attr('href') + '&output=json&callback=?' + fc_AddSession(), function(data){

fc_UpdateCart(FoxyDomain);

});

alert('Your cart has been emptied.');
return false;

});

});


Now it doesn't work. I wonder if something fundamental has changed. I hope it isn't too hard to get this working again.
Comments
  • lancelance Member, Community Support Member
    @drwagner13 -

    Try something like this:
    $(document).ready(function() {
    $("a.emptyCart").click(function() {
    $.getJSON('https://FOXYDOMAIN/cart?output=json&cart=empty&callback=?' + fc_AddSession(), function(data) {
    fc_json = data;
    fc_UpdateCart("FOXYDOMAIN");
    });
    alert('Your cart has been emptied.');
    return false;
    });
    });
    
    Does that work for you?

    Lance
  • Unfortunately this does not work for me. I can verify the function fires off, but nothing happens except the default link behavior: empties the cart and takes me to a blank page. I'm trying to empty the cart silently, stay on the same page, and have the minicart disappear. I had this working once upon a time on another site, and in a prior version of foxycart.

    If I understand correctly, I should replace "FOXYDOMAIN" with "MYDOMAIN.foxycart.com". Correct?
  • lancelance Member, Community Support Member
    @drwagner13 -

    Can you provide a link to your store where you are trying this code?

    Thanks,
    Lance
  • brettbrett FoxyCart Team
    Hey @drwagner13.
    The FoxyCart javascript that used to have fc_AddSession() has been rewritten, so instead of that you'll need to take a look at this page:
    http://wiki.foxycart.com/v/0.7.0/advanced/javascript#session_get_appending_the_fcsid_to_requests

    Replace the fc_AddSession() with fcc.session_get().

    Also, I'd recommend re-grabbing the jQuery and foxycart.complete.js from your store's "sample code" section, as depending on your version it may have been slightly updated for better compatibility with things (jQuery + Colorbox, specifically).

    The fc_UpdateCart() confuses me though. Without seeing the context I'm not sure what that'd be used for, but I don't think that's going to be what you want.
Sign In or Register to comment.