Bundle Hooks
Bundle hooks let you customize the behavior of Glood.AI bundles at key lifecycle points. There are five hooks available, each called at a specific stage of the bundle’s lifecycle.Hook Lifecycle Flow
1. Configuration Phase
OnConfigLoadis called when bundle data is first loaded- Modify or enrich bundle configuration
- Set up initial state
2. Rendering Phase
OnBundleRendertransforms bundle data for the Liquid template- Map products with options and variants
- Calculate pricing
- Resolve translations
3. Interaction Phase
OnVariantChangehandles variant selection changes- Update URL parameters
- Trigger UI updates
4. Cart Operations Phase
OnAddToCartfires before the cart API request- Validate cart operations
- Pre-cart UI updates
OnAddedToCartfires after successful cart addition- Post-cart confirmations
- Analytics tracking
Available Hooks
1. OnConfigLoad
Purpose: Modify bundle data when it is first loaded, before any rendering occurs. Parameters:
Returns: The modified (or unmodified) bundle object.
Example:
- Filter products before rendering
- Enrich bundle data with additional information
- Override default configuration
2. OnBundleRender
Purpose: Transform raw bundle data into the format consumed by the Liquid template. This is the primary hook for controlling what gets rendered. Parameters:
Returns: An object with
products (array) and translations (object).
Example:
- Custom product mapping and data transformation
- Price calculation logic
- Custom translation resolution
- Adding computed fields to products
3. OnVariantChange
Purpose: Handle variant selection changes when a customer picks a different option. Parameters:
Returns: void
Example:
- Update URL query parameters
- Trigger custom analytics events
- Update external UI elements
- Sync variant selection with other page components
4. OnAddToCart
Purpose: Called immediately when the add-to-cart button is clicked, before the cart API request is made. Parameters:
Returns: void
Example:
- Pre-cart validation
- Loading state UI updates
- Analytics event firing
- Custom cart payload modifications
5. OnAddedToCart
Purpose: Called after a successful add-to-cart API response. Parameters:
Returns: void
Example:
- Show success notifications
- Open mini-cart or cart drawer
- Redirect to cart page
- Fire conversion tracking events
- Update cart count in header
Available Utilities
Theutils object passed to each hook provides these functions: