Docs

JavaScript API

1 min readUpdated November 29, 2026

Mini cart#

MemberDescription
window.nbwtMiniCart.open()Opens the drawer.
window.nbwtMiniCart.close()Closes it.
window.nbwtMiniCart.refresh()Fetches the drawer and every fragment again. Returns a Promise. Call it after your plugin changes the cart without WooCommerce’s add-to-cart.

Any element with the trigger class (default .nbwt-cart-open, set on the Mini cart tab) opens the drawer.

Events#

Plain DOM CustomEvents on document.body. No jQuery needed.

EventWhen
nbwt_mini_cart_openedThe drawer opened.
nbwt_mini_cart_closedThe drawer closed.
nbwt_mini_cart_refreshedNew drawer HTML is in the page. Re-bind anything inside it here.
document.body.addEventListener( 'nbwt_mini_cart_refreshed', function () {
	// Re-init your widgets inside .nbwt-mc
} );

The drawer also listens for WC Currency Switch’s wccs:currency event and fetches itself again in the new currency.

Endpoints#

The drawer posts to these WooCommerce AJAX endpoints. Each returns WooCommerce’s refreshed fragments.

EndpointFields
?wc-ajax=add_to_cartAdd on a recommendation, then fires WooCommerce’s added_to_cart event.
?wc-ajax=nbwt_mc_couponcode, do = apply or remove.
?wc-ajax=nbwt_save_laterkey.
?wc-ajax=nbwt_mc_loadThe drawer’s light first load.

Cart events (tracking)#

With a tracking plugin active, nbwtTrack( type, el, qty, response ) sends add, remove and view events from the mini cart and cart page. Every event also fires nbwt_track on document.body with { type, item, quantity }:

document.body.addEventListener( 'nbwt_track', function ( e ) {
	// e.detail.type: 'add', 'remove' or 'view'
	// e.detail.item: id, name, price, qty...
} );