Adding custom info messages when triggering a custom cart event

Hey guys,

I have a custom event to save a cart item for later, similar to how Amazon does it. When the event is triggered, I post some data to an endpoint, then remove the cart item. What I'm struggling with is adding a notification that it was successful. I see that we have a method for FC.util.addError, but not for addInfo. I added a custom method for that, but when I add an item to and then remove a cart item, the message is cleared. What's the right way to do this?



FC.client.wrap("save-item", function (params) {
var cart = FC.cart;

type: "post",
dataType: "json",
data: {
action: 'save_item_for_later',
product: params.product,
}).always(function (data) {
*** FC.util.addInfo('save-for-later', data.msg); ***


jQuery('[data-fc-id="item-save-link"]').on('click', function() {
var $this = jQuery(this),
item_id = $"fc-item-id"),
product = FC.json.items.find(function(item) {
return == item_id

id : $"fc-item-id"),
product : product
  • fc_adamfc_adam FoxyCart Team

    Without seeing it in action, I think what you're seeing is your custom message is being blown away when the removeItem function call returns and updates the JSON from serverside. You could switch out the removeItem call for a FC.client.request(...).done(function() {...}); call - setting the add to cart URL to remove the product in the request, and then adding your custom message in the done callback function. That should let your custom message persist until the next call updates the JSON.
  • That worked great. If you're interested in the code, let me know.
Sign In or Register to comment.