1/** 2 * Initialize Cart Preview Integration 3 * 4 * Hooks into the cart preview to display subscription information. 5 * 6 * @since 2.13.8 7 */ 8function initializeCartPreviewIntegration () { 9 10 // Function to set up the hooks - call this when API is available 11 function setupHooks ( api ) { 12 13 /** 14 * Add subscription info to cart items 15 * 16 * Displays subscription billing information (period, frequency, etc) 17 * for items in the cart preview. 18 */ 19 api.hooks.addFilter( 'cartItemMessages', function ( messages, itemData ) { 20 21 if ( itemData.subscription_info && itemData.subscription_info.display ) { 22 messages.push( { 23 text: itemData.subscription_info.display, 24 type: 'recurring' 25 } ); 26 } 27 28 return messages; 29 } ); 30 } 31 32 // Check if cart preview API is already available 33 if ( window.eddSlideoutCart && window.eddSlideoutCart.hooks ) { 34 setupHooks( window.eddSlideoutCart ); 35 } else { 36 // API not ready yet, wait for the event 37 document.addEventListener( 'edd:cart-preview:ready', function ( event ) { 38 setupHooks( event.detail.api ); 39 } ); 40 } 41} 42 43// Initialize when DOM is ready 44if ( document.readyState === 'loading' ) { 45 document.addEventListener( 'DOMContentLoaded', initializeCartPreviewIntegration ); 46} else { 47 initializeCartPreviewIntegration(); 48}
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.