Big Cartel cart

595 views Asked by At

I have made a custom theme on big cartel, and everything is perfect, except one thing. I would like to have the cart update without going to the cart page when adding an item to your cart. I have made my custom template over the "sexy" theme and have no idea how I go about implanting this

I know this can be done, because default themes like "Good Vibes" do this.

2

There are 2 answers

2
Nick Endle On

You'll want to take advantage of the javascript API: https://help.bigcartel.com/developers/themes/#javascript-api

With this, you can drop in the line of code to load the API into your theme and have access to add, update, and remove items from the cart using javascript.

0
Greg Scharf On

You can use the code below. I didn't include the code for the restoreButton function in the addItem callback but I'm sure you get the idea. You'll also need your own means of retrieving the product ID based on however you're displaying your product options. Make sure to also include a reference to Big Cartel's javascript api.

$('#add_to_bag').click(function(evt){
    var productId;
    if($('.options_select').length != 0)
        productId = $( ".options_select option:selected" ).attr('value');
    else
        productId = $('.price_options input').attr('value');

    var quantity = $('.quantity input').attr('value');        
    Cart.addItem(productId, quantity, function(cart) {
        $('#add_to_bag').attr('value', 'Item Added');
        setTimeout(restoreButton, 2000);
    });
});