Skip to content

Instantly share code, notes, and snippets.

@NicolaBizzoca
Last active July 19, 2023 09:04
Show Gist options
  • Save NicolaBizzoca/d8c8b2280628dcbbcbd344615bd963ac to your computer and use it in GitHub Desktop.
Save NicolaBizzoca/d8c8b2280628dcbbcbd344615bd963ac to your computer and use it in GitHub Desktop.
{% unless product.content contains 'zakeke-design-tag' %}
{% if product.tags contains 'zakeke-product' or product.content contains 'zakeke-product-tag' %}
<button id="zakeke-product-button-custom" class="btn button">
<span>Customize</span>
</button>
<script>
(function () {
const btn = document.querySelector("#zakeke-product-button-custom");
btn.addEventListener("click", function (event) {
event.preventDefault();
event.stopPropagation();
const url = new URL(window.location.href);
const variant = url.searchParams.get('variant');
let rootUrl = '{{ routes.root_url }}';
if (rootUrl === '/') {
rootUrl = '';
}
const zakekeUrl = new URL(rootUrl + (window.zakekeUrl || "/apps/zakeke") + '?pid={{ product.id }}', document.location);
if (variant) {
zakekeUrl.searchParams.set('id', variant);
}
window.location.href = zakekeUrl.toString();
});
})();
</script>
<style>
#zakeke-product-button {
display: none;
}
</style>
{% endif %}
{% endunless %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment