- Created an iFrame on the product page with the content 'Loading...' to adjust the styling to fit the page
- Added iFrame to top of product page on Mobile, adjusted properties to collapsed & hidden on page load
- Added custom JS code that will check if: Mobile, Product Page URL contains appropriate model substring.
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';
$w.onReady(function () {
wixLocation.onChange( (location) => {
updateArKitFrame();
});
updateArKitFrame();
});
function updateArKitFrame () {
let iframe = $w('#html1');
if(wixWindow.formFactor !== "Mobile") {
return;
}
let url = wixLocation.url;
var model = null;
if (url.indexOf('1855') !== -1) {
model = '1855';
}
if (url.indexOf('libert') !== -1) {
model = 'liberte';
}
if (url.indexOf('minerali') !== -1) {
model = 'mineralite';
}
if (url.indexOf('decant') !== -1) {
model = 'decanter';
}
if (url.indexOf('versati') !== -1) {
model = 'versatile';
}
if (url.indexOf('water') !== -1) {
model = 'water';
}
if (url.indexOf('carafe') !== -1) {
model = 'carafe';
}
if (url.indexOf('champa') !== -1) {
model = 'champagne';
}
if (url.indexOf('cru') !== -1) {
model = 'cru';
}
if(model) {
iframe.src = 'https://grasslglass.com/api/preview?model=' + model;
iframe.show();
iframe.expand();
} else {
iframe.hide();
iframe.collapsed();
}
}