In this section you will learn how to preselect the matching framesize on the new product page right away when a user clicks on an alternative bike.
When the Recommendation Engine shows alternative bikes and the customer clicks on one of these bikes this will open in a new tab/window based on the URL given in the product feed. Often times this URL does not include information about the selected size, instead all sizes of one model have the same URL. As the product will be opened in a new tab we can't use a callback function to select the recommended size as in the Online Sizing.
Instead you can add additional URL parameters to the links that can be read on page load and then create a custom function that uses this information to preselect the recommended size for the customer.
Add additional URL parameters
Once parameters have been mapped links to new tabs from your Recommendation Engine will include these parameters. This might look the following:
Create custom functions
Read URL parameters
The following code saves the value of the
variationId in the URL parameter, in this case
const url = new URL(document.URL);
const gtin = url.hash.substring(1);
const variationId = url.searchParams.get("variationId");
With the data from the URL parameters you now need to select the recommended size. Therefore you may use the same function that is used in the confirm size callback.