PageSourceSearch

https://www.golfbluecypress.com/wp-content/themes/cet-wp-theme-indigo/js/cart-count-sync.js?ver=1.0.78

js golfbluecypress.com collected 2026-10-04 10:49:18 UTC 1,486 bytes, 52 lines download raw bytes

1( function( window ) {
2	function getSelectors() {
3		const cartStore = ( function() {
4			if ( ! window.wp || ! window.wp.data || ! window.wc || ! window.wc.wcBlocksData ) {
5				return null;
6			}
7			return window.wc.wcBlocksData.cartStore || null;
8		} )();
9		return cartStore ? window.wp.data.select( cartStore ) : null;
10	}
11
12	function updateHeaderCount() {
13		const selector = getSelectors();
14		if ( ! selector || ! selector.getCartData ) {
15			return;
16		}
17
18		const cart = selector.getCartData();
19		const countElement = document.querySelector( '.cart-count' );
20		if ( ! cart || ! countElement ) {
21			return;
22		}
23
24		const count = cart.itemsCount || 0,
25			icon = document.querySelector( '.header-cart .material-symbols-outlined' );
26
27		countElement.textContent = count;
28		countElement.classList.toggle( 'is-empty', count === 0 );
29		countElement.setAttribute( 'aria-hidden', count ? 'false' : 'true' );
30		icon.textContent = ( count ? 'add_' : '' ) + 'shopping_cart';
31	}
32	const readyInterval = setInterval( function() {
33		// Initial render
34		clearInterval( readyInterval );
35		updateHeaderCount();
36
37		// Re-render whenever the cart store changes
38		let lastCount = null;
39		window.wp.data.subscribe( function() {
40			const sel = getSelectors(),
41				data = sel.getCartData(),
42				current = data.itemsCount || 0;
43			if ( ! sel || ! sel.getCartData || ! data ) {
44				return;
45			}
46			if ( current !== lastCount ) {
47				lastCount = current;
48				updateHeaderCount();
49			}
50		} );
51	}, 100 );
52} )( window );

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.