In rare cases, the app script may not be running in your theme. To resolve this issue, please follow these steps:
First click on "Edit code" in the dropdown to open the code editor for your theme:
|
There are 2 things to add to your theme:
Step 1
First, on the left hand side, scroll to Snippet section and add a new snippet.
|
Name it smartSize.liquid
|
Next, inside the file, copy the following content:
<script>
window.sizefox = window.sizefox === undefined ? {} : window.sizefox;
sizefox.shop = "{{ shop.permanent_domain }}";
{% assign t = template | prepend: '/' | append: '.' %}
{% if t contains '/product.' %}
console.log("%cSmartSize AppEmbed Extension v20", "background: black; color: yellow")
// Sanitize product name by removing any non-printable or problematic characters
function sanitizeProductName(name) {
return name
.replace(/[\r\n\t"]/g, ' ') // Replace carriage returns, newlines, tabs, and double quotes with a space
.replace(/[^\x20-\x7E]/g, ''); // Remove non-printable ASCII characters
}
// Pass the sanitized product name from Liquid to JavaScript for additional sanitization
const sanitizedProductName = sanitizeProductName({{ product.title | strip_newlines | json }});
sizefox.data = {
collections: "{{ product.collections | map: 'id' | join: ',' }}",
tags: {{ product.tags | join: ',' | json }},
product: "{{ product.id }}",
productname: sanitizedProductName,
type: {{ product.type | json }},
requestLocale: {{ request.locale | json }},
localizationLanguage: {{ localization.language | json }},
localizationAvailableLanguages: {{ localization.available_languages | json }},
smartsizeButtonLabel: "{{ block.settings.smartsize_button_label }}",
smartsizeConversionLabelCM: "{{ block.settings.smartsize_conversion_label_CM }}",
smartsizeConversionLabelIN: "{{ block.settings.smartsize_conversion_label_IN }}"
};
{% endif %}
fetch(https://server.smartsize.io/sizepopupversion?shopname= + sizefox.shop)
.then(response => response.json())
.then(json => {
console.log("SmartSize Script: ", json);
scripturl = json.url;
popupVersion = json.popup_version;
if (popupVersion === 0) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = 'https://cdn.shopify.com/s/files/1/0848/1321/8088/files/jquery-ui.min.css?v=1729803419';
document.head.appendChild(link);
}
const smartScript = document.getElementById("smartsizeScript");
smartScript.src = scripturl;
});
</script>
Then click save. You should have a file that looks like this (see below). Make sure that you SAVE it.
|
Step 2
Open the file called theme.liquid
Find the tag </head>
Enter the following code snippet right above the tag
{% render 'smartSize' %}
Click on Save.