{%- comment -%} BOLD-COMMON.LIQUID Last updated: 2023-Mar-20 --------------------------- WARNING --------------------------- This file is auto-generated by BOLD and should not be modified. It may be overwritten and any customizations would be lost. --------------------------- WARNING --------------------------- {%- endcomment -%} <script> {%- comment -%} common data {%- endcomment -%} window.BOLD = window.BOLD || {}; window.BOLD.common = window.BOLD.common || {}; window.BOLD.common.Shopify = window.BOLD.common.Shopify || {}; window.BOLD.common.Shopify.shop = { domain: '{{ shop.domain }}', permanent_domain: '{{ shop.permanent_domain }}', url: '{{ shop.url }}', secure_url: '{{ shop.secure_url }}', {%- if settings.currency_code_enabled -%} money_format: {{ shop.money_with_currency_format | json }}, {%- else -%} money_format: {{ shop.money_format | json }}, {%- endif -%} currency: {{ shop.currency | json }} }; window.BOLD.common.Shopify.customer = { id: {{ customer.id | json }}, tags: {{ customer.tags | json }}, }; window.BOLD.common.Shopify.cart = {{ cart | json }}; window.BOLD.common.template = '{{ template | split: "." | first }}'; {%- comment -%} common functions {%- endcomment -%} window.BOLD.common.Shopify.formatMoney = function(money, format) { function n(t, e) { return "undefined" == typeof t ? e : t } function r(t, e, r, i) { if (e = n(e, 2), r = n(r, ","), i = n(i, "."), isNaN(t) || null == t) return 0; t = (t / 100).toFixed(e); var o = t.split(".") , a = o[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1" + r) , s = o[1] ? i + o[1] : ""; return a + s } "string" == typeof money && (money = money.replace(".", "")); var i = "" , o = /\{\{\s*(\w+)\s*\}\}/ , a = format || window.BOLD.common.Shopify.shop.money_format || window.Shopify.money_format || "$ {% raw %}{{ amount }}{% endraw %}"; switch (a.match(o)[1]) { case "amount": i = r(money, 2, ",", "."); break; case "amount_no_decimals": i = r(money, 0, ",", "."); break; case "amount_with_comma_separator": i = r(money, 2, ".", ","); break; case "amount_no_decimals_with_comma_separator": i = r(money, 0, ".", ","); break; case "amount_with_space_separator": i = r(money, 2, " ", ","); break; case "amount_no_decimals_with_space_separator": i = r(money, 0, " ", ","); break; case "amount_with_apostrophe_separator": i = r(money, 2, "'", "."); break; } return a.replace(o, i); }; window.BOLD.common.Shopify.saveProduct = function (handle, product) { if (typeof handle === 'string' && typeof window.BOLD.common.Shopify.products[handle] === 'undefined') { if (typeof product === 'number') { window.BOLD.common.Shopify.handles[product] = handle; product = { id: product }; } window.BOLD.common.Shopify.products[handle] = product; } }; window.BOLD.common.Shopify.saveVariant = function (variant_id, variant) { if (typeof variant_id === 'number' && typeof window.BOLD.common.Shopify.variants[variant_id] === 'undefined') { window.BOLD.common.Shopify.variants[variant_id] = variant; } }; {%- comment -%} product data {%- endcomment -%} window.BOLD.common.Shopify.products = window.BOLD.common.Shopify.products || {}; window.BOLD.common.Shopify.variants = window.BOLD.common.Shopify.variants || {}; window.BOLD.common.Shopify.handles = window.BOLD.common.Shopify.handles || {}; {%- if template == 'product' -%} window.BOLD.common.Shopify.handle = {{ product.handle | json }} {%- endif -%} {%- comment -%} product page {%- endcomment -%} window.BOLD.common.Shopify.saveProduct({{ product.handle | json }}, {{ product.id | json }}); {%- for variant in product.variants -%}{%- assign csp_metafield_namespace = variant.id | prepend: "csp" -%}window.BOLD.common.Shopify.saveVariant({{ variant.id | json }}, { product_id: {{ product.id | json }}, product_handle: {{ product.handle | json }}, price: {{ variant.price | json }}, group_id: '{{variant.metafields.bold_rp.rp_group_id}}', csp_metafield: {{ product.metafields[csp_metafield_namespace] | json }}});{%- endfor -%} {%- comment -%} BOLD APPS INSTALLED {%- endcomment -%} {%- assign bold_apps_installed = shop | map: 'metafields' | map: 'bold_apps_installed' | first -%} window.BOLD.apps_installed = {{ bold_apps_installed | json }} || {}; {%- unless bold_apps_installed contains 'Customer Pricing' or bold_apps_installed contains 'Product Bundles' or bold_apps_installed contains 'Product Discount' or bold_apps_installed contains 'Quantity Breaks' or bold_apps_installed contains 'Custom Order' or bold_apps_installed contains 'Order Manager' or bold_apps_installed contains 'The Motivator'-%} {%- comment -%} collection page {%- endcomment -%} {%- for product in collection.products -%} window.BOLD.common.Shopify.saveProduct({{ product.handle | json }}, {{ product.id | json }}); {%- for variant in product.variants -%}{%- assign csp_metafield_namespace = variant.id | prepend: "csp" -%}window.BOLD.common.Shopify.saveVariant({{ variant.id | json }}, { product_id: {{ product.id | json }}, product_handle: {{ product.handle | json }}, price: {{ variant.price | json }}, group_id: '{{variant.metafields.bold_rp.rp_group_id}}', csp_metafield: {{ product.metafields[csp_metafield_namespace] | json }}});{%- endfor -%} {%- endfor -%} {%- comment -%} search page {%- endcomment -%} {%- for product in search.results -%} window.BOLD.common.Shopify.saveProduct({{ product.handle | json }}, {{ product.id | json }}); {%- for variant in product.variants -%}{%- assign csp_metafield_namespace = variant.id | prepend: "csp" -%}window.BOLD.common.Shopify.saveVariant({{ variant.id | json }}, { product_id: {{ product.id | json }}, product_handle: {{ product.handle | json }}, price: {{ variant.price | json }}, group_id: '{{variant.metafields.bold_rp.rp_group_id}}', csp_metafield: {{ product.metafields[csp_metafield_namespace] | json }}});{%- endfor -%} {%- endfor -%} {%- endunless -%} {%- comment -%} cart page {%- endcomment -%} {%- for item in cart.items -%}{%- assign csp_metafield_namespace = item.variant_id | prepend: "csp" -%}window.BOLD.common.Shopify.saveVariant({{ item.variant_id | json }}, { product_id: {{ item.product.id | json }}, product_handle: {{ item.product.handle | json }}, price: {{ item.variant.price | json }}, group_id: '{{item.variant.metafields.bold_rp.rp_group_id}}', csp_metafield: {{ item.product.metafields[csp_metafield_namespace] | json }}});{%- endfor -%} {%- comment -%} metafields {%- endcomment -%} window.BOLD.common.Shopify.metafields = window.BOLD.common.Shopify.metafields || {}; {%- assign metafield_namespaces_to_load = 'bold_rp,bold_csp_defaults' | split: ',' -%} {%- for namespace in metafield_namespaces_to_load -%} window.BOLD.common.Shopify.metafields[{{ namespace | json }}] = {{ shop.metafields[namespace] | json }}; {%- endfor -%} window.BOLD.common.cacheParams = window.BOLD.common.cacheParams || {}; </script>
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article