Skip to content

Instantly share code, notes, and snippets.

@joostdevries
Last active December 6, 2016 17:12
Show Gist options
  • Save joostdevries/2d112faa5789aa3b2c5ce204d72cbfd7 to your computer and use it in GitHub Desktop.
Save joostdevries/2d112faa5789aa3b2c5ce204d72cbfd7 to your computer and use it in GitHub Desktop.
publitas-send-product-parent.js
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="publitas-embed-9gux2kcj2a2lula9m82vwe9udi"></div><script publitas-embed data-wrapperId="publitas-embed-9gux2kcj2a2lula9m82vwe9udi" data-cfasync="false" data-publication="https://integration1-view.publitas.com/acme-sprockets/test-234-upload-me-2/" data-responsive="true" type="text/javascript" src="https://integration1-view.publitas.com/embed.js"></script>
<script type="text/javascript">
// This needs to be implemented in the prAna site
function openMagentoQuickViewBySKU(sku) {
console.log('Opening Magento Quickview for SKU ' + sku);
launchLightboxAjax('/catalog/quicklook/view/id/' + sku, 0, 'quickLookColorPreSelect("' + sku + '")');
}
window.addEventListener('message', function(message) {
var event = JSON.parse(message.data);
var eventType = event[0];
var eventData = event[1];
if ( eventType == 'productOpened' ) {
openMagentoQuickViewBySKU(eventData.webshopIdentifier);
}
});
</script>
</body>
</html>
// This will be implemented in the Publitas reader by Publitas
window.viewerReady = function (api, platform) {
api.setProductAction(function (products, onOpen, onClose) {
if (!window.parent) {
return;
}
var product = products[0];
var message = JSON.stringify(['productOpened', {
webshopIdentifier: product.webshopIdentifier,
webshopUrl: product.webshopUrl
}]);
window.parent.postMessage(message, '*');
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment