Appearance
JavaScript Events
Here are few JavaScript events API that we have in Go Cart plugin. You can use these events to extend the plugin functionality if you are a developer.
Cart modal opened
When cart model is opened, the gocart__woo-visible
class is added in body & event goCartIsVisible
is triggered in the global window object. You can use this event to trigger your custom JavaScript code.
You can use both vanilla JavaScript or jQuery to listen to this event. Below is the example of both:
js
// Vanilla JavaScript
window.addEventListener('goCartIsVisible', (e) => {
// Your custom code here.
});
// jQuery
$(window).on('goCartIsVisible', (e) => {
// Your custom code here.
});
// Vanilla JavaScript
window.addEventListener('goCartIsVisible', (e) => {
// Your custom code here.
});
// jQuery
$(window).on('goCartIsVisible', (e) => {
// Your custom code here.
});
Cart modal closed
When cart model is closed, the gocart__woo-visible
class is removed from body & event goCartIsHidden
is triggered in the global window object. You can use this event to trigger your custom JavaScript code.
Below is the example:
js
// Vanilla JavaScript
window.addEventListener('goCartIsHidden', (e) => {
// Your custom code here.
});
// jQuery
$(window).on('goCartIsHidden', (e) => {
// Your custom code here.
});
// Vanilla JavaScript
window.addEventListener('goCartIsHidden', (e) => {
// Your custom code here.
});
// jQuery
$(window).on('goCartIsHidden', (e) => {
// Your custom code here.
});
Shopping meter threshold reached
When shopping meter threshold is reached, the goCartShoppingMeterThresholdReached
event is triggered in the global window object. You can use this event to trigger your custom JavaScript code.
Below is the example:
js
// Vanilla JavaScript
window.addEventListener('goCartShoppingMeterThresholdReached', (e) => {
// Your custom code here.
});
// jQuery
$(window).on('goCartShoppingMeterThresholdReached', (e) => {
// Your custom code here.
});
// Vanilla JavaScript
window.addEventListener('goCartShoppingMeterThresholdReached', (e) => {
// Your custom code here.
});
// jQuery
$(window).on('goCartShoppingMeterThresholdReached', (e) => {
// Your custom code here.
});