JS API

This section is a kind of developer’s handbook. There are JavaScript functions available for a developer to utilize the floating cart form in its own way. Let’s examine each available function and its usage.

Toggle Cart: The toggle cart function toggle the cart through this function. It means, calling this function on an open cart will close it and calling it while the cart is closed, will open the cart. This function can be used to bind any custom button with the cart and hide the default floating cart icon. 

xt_woofc_toggle_cart();

Open Cart: The open cart function simply open the cart and does nothing if the cart is already open.

xt_woofc_open_cart();

Close Cart:  This works similar to the open cart function. The only difference is that it closes the cart if its open.

xt_woofc_close_cart();




Refresh Cart: If you are utilizing the woocommerce javascript hooks, you may want to refresh the floating cart at some point. This function comes in handy in such situations. You can simply call it on the success of an AJAX callback or when a JS promise is fulfilled.

xt_woofc_refresh_cart();

Is Cart Open: If you play with JavaScript a lot, you might want to check if the cart is open or not to perform a few of your own operations accordingly. This can be checked through this simple JS function anytime. 

xt_woofc_is_cart_open();

Is Cart Empty: The last JS function is very important. It is wise not to perform any operation on an empty cart. This function is quite straightforward. You can call it at any point in time and it will let you know if the cart is empty or not.

xt_woofc_is_cart_empty();

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.