Example of API Use
To help simplify how to use our API, let's try an example! In this example, let's say we want to hide UpCart's Sticky Cart Button if there are 0 items in the cart.
Well, we can check the item count of the cart by using the API and using the window.upcartOnCartLoaded() function, which is passed the Shopify Cart Object as a parameter.
Taking a look at Shopify's documentation on the Cart object, we can see that it contains an item_count
variable, seen in yellow in the image below.
Knowing this now, we can use this to check if the cart contains 0 items!
So let's do this together in the video below: