Confirm Size
To automatically select the frame size suggested in the widget on the product page (e.g. in a dropdown menu), you can set up a custom function triggered by the confirmSize callback.
We also got that example covered in our CodePen example as well. Here how you would configure that:
- Code
- Payload
- Example
const myVariantSelectionFunction = (payload) => {
const { code, id, displaySize01, codeType } = payload;
// here goes YOUR code that will select the recommended size.
// you can use the payload variables to identify the correct bike in your shop.
};
const OZ_CONFIG = {
settings: {
// config options here
},
events: {
confirmSize: {
callback: myVariantSelectionFunction, // don't add parentheses here, otherwise the funtion will execute immediately instead of waiting for invocation
},
},
};
Object {
bestIndex: 2
bestIndicator: 89
code: "8053323623816", // will be in the same format as you passed it to the widget.
codeType: 1
displaySize01: "M-L",
displaySize02: "50cm",
id: "oz-button-generic-default" // this is the ID of the widget that triggered this callback. Useful if you have more than one widget on a page
stock: null
}
const myVariantSelectionFunction = (payload) => {
const { code } = payload;
// productUrl and variantId are available from another function in this example
return (window.location = `${productUrl}?variant=${variantId[code]}`);
};
const OZ_CONFIG = {
settings: {
apiKey: "YOUR API-KEY",
// more config options
},
events: {
confirmSize: {
callback: myVariantSelectionFunction,
},
},
};
We explicitely recommend that you use the product code passed in the payload to your function to select the correct bike in your shop. Passed size information is not consistent and should not be used as an identifier.
Depending on your function you may want to change the label of the result button from Select size to something else. Here you find how you can do this in the global configuration for every widget on the page or in the local configuration for single widgets.