Shopify/Timber

How to update/reload the Cart Drawer content while it's open?

Closed this issue · 1 comments

Hi!

I've got a question and hope it's okay if I post it here. It would be great to get some help to point me into the right direction on this one – can't figure it out!

What I want to do: add/update a line item of the cart and then update the Cart Drawer while it is open. At the moment I'm simply doing an ajax post on /cart/update.js:

  $.ajax({
    type: 'POST',
    url: '/cart/update.js',
    data: { updates: { {{ my_product_id }}: 1 }, attributes: { 'some-attribute': '' } },
    dataType: 'json',
    success: function() {
      // What should I do here?
    }
  });

While this does add the item to the cart, of course I won't see it inside the Cart Drawer until I refresh the page or do timber.RightDrawer.close(); and then timber.RightDrawer.open();.

Is there a method of Adding items to the Ajaxify Cart so it will update its content automatically? Or a method of simply reloading it?

I found the solution: ajaxCart.load();