💫Variant Integration
It's as easy as walking!
Integration Example
Step 1: Add Mazing script to the <head> element of your website
Step 2: Add your own script at the end of the <body> element
Create a new File and name it 'mazing-integration.js'. Place the script of this File at the end of your body element:
Step 3: Fill your mazing-integration.js File Logic
Copy and paste this blueprint into your empty mazing-integration.js File:
You should now see the "mazing configuration is active :)" log when opening the console on your website. This means the script is working!
Step 4: Get SKU and create iFrame
Call await mazingProjectAailable() to get the iFrameSrc. This could look similar to this example:
To learn more about getSKU, take a look at -> Script Integration
Step 5: Use postMessage to switch between Variants
Remember the ID/Trigger that we applied to each Variant? Because this becomes important now. Let's say you are using your own User Interface for example where you can choose between different Variations of your Product:
In this case we need to add an event listener on each variation inside the dropdown menu and call the postMessage whenever an option is clicked.
As you can see, when calling the postMessage we send the newDataValue as Trigger. By clicking on the "All-Black" Option, the newDataValue would have an value of "all-black". And by sending that value as trigger, we can activate the Variant that has the same ID/Trigger as the value we send.
Here we create the Variant:
Here we send the postMessage with the Trigger Value 'all-black' from the shop website:
Congrats! You integrated the configurator to your website!
Last updated