How to Customize the Widget Integration (Client)
A Guide to Customizing Widget Integration Functionality for Technical Support Teams
How to Customize the Widget Integration (Client)
Overview
This guide provides Technical Support teams with comprehensive instructions for customizing Widget Integration functionality using the window.boostWidgetIntegration API. All customizations are made through the customization.js file, which is accessible via the Code Editor in the Boost Admin App.
Prerequisites
- Access to Boost Admin App
- Basic understanding of JavaScript
- Familiarity with the shop's theme and requirements
Getting Started
Accessing the Customization File
- Log into the Boost Admin App
- Navigate to Code Editor
- Open or create the
customization.jsfile - All customizations must be wrapped in
window.boostWidgetIntegration.onBeforeAppBootstrap
Basic Structure
window.boostWidgetIntegration.onBeforeAppBootstrap = () => {
// All your customization code goes here
window.boostWidgetIntegration.extend('ClassName', (BaseClass) => {
return class CustomClass extends BaseClass {
// Your custom implementation
};
});
};
Common Customization Scenarios
1. Customize the return value of a class method
Scenario: The customer wants to change the number of slides to show in the Recommendation carousel to 6
Problem: We need to change the slidesToShow setting of the RecommendationWidgetController
Reference:
Solution:
window.boostWidgetIntegration.onBeforeAppBootstrap = () => {
window.boostWidgetIntegration.extend(
'RecommendationWidgetController',
(RecommendationWidgetController) => {
return class CustomRecommendationWidgetController extends RecommendationWidgetController {
getCarouselConfig(model) {
// IMPORTANT: Call the parent method to get the base configuration
const config = super.getCarouselConfig(model);
// Modify the slidesToShow property
config.slidesToShow = 6;
// Return the modified configuration
return config;
}
};
},
);
};
Explanation:
- We extend
RecommendationWidgetControllerto create a custom class - We override the
getCarouselConfig()method - We call
super.getCarouselConfig(model)to get the default configuration - We modify the
slidesToShowproperty to 6 - We return the modified configuration
How to Test:
- Save the customization code
- Open browser DevTools → Network tab
- Load a page with recommendation widgets
- Scroll to the recommendation widget and verify that it shows 6 slides
2. Customize the parameters of a class method
Scenario: The customer wants to change the currency to "USD" for all Recommendation widgets
Problem: We need to change the currency parameter for Recommendation API calls
Reference:
Solution:
window.boostWidgetIntegration.onBeforeAppBootstrap = () => {
window.boostWidgetIntegration.extend('RecommendationAPI', (RecommendationAPI) => {
return class CustomRecommendationAPI extends RecommendationAPI {
getRecommendation(params, bodyPayload) {
params.currency = 'USD'; // Force currency to USD
// IMPORTANT: Call the parent method with modified params
return super.getRecommendation(params, bodyPayload);
}
};
});
};
Explanation:
- We extend
RecommendationAPIto create a custom class - We override the
getRecommendation()method - We modify the
paramsobject to setcurrencyto "USD" - We call
super.getRecommendation(params, bodyPayload)to execute the original method with modified parameters
How to Test:
- Save the customization
- Open browser DevTools → Network tab
- Load a page with recommendation widgets
- Verify that the
currencyparameter in the API request is set to "USD"
Customization Reference
For complete API documentation including all available classes, methods, and properties, refer to the Widget Integration (Client) API Reference.
Troubleshooting
Widget Not Showing Customizations
Solution: Verify that the code is wrapped in window.boostWidgetIntegration.onBeforeAppBootstrap() and that there are no JavaScript errors in the console.
Best Practices
- Always call parent methods: Use
super.methodName()to preserve the base functionality - Handle edge cases: Add null checks and fallback values
- Keep it simple: Start with small customizations and gradually build complexity
Getting Help
If you need assistance with customizations:
- Check the browser console for error messages
- Review this guide for similar examples
- Contact Boost support with your customization code and the specific issue
Last Updated: January 2025 Version: 1.0