Example Shopify Source Script Without Comments

When upgrading to the new Shopify Source reference this for an example of the data layer script you may need to remove

The script in your checkout settings may or may not have opening or closing comments like <!-- Begin Elevar --> and <!-- End Elevar -->. Below is what your Elevar Shopify Source script looks like without the comments. Use this a guide to find the beginning and end of the scripts when needed.

<script type="module">
  try {
    const response = await fetch("https://shopify-gtm-suite.getelevar.com/configs/617bd46625d10a8d734ad3effce11112311231212313123/config.json");
    const config = await response.json();
    const scriptUrl = config.script_src_app_theme_embed;

    if (scriptUrl) {
      const { handler } = await import(scriptUrl);

      await handler(
        config,
        
        {
          cartData: {
  attributes: {{- cart.attributes | json -}},
  cartTotal: "{{- cart.total_price | times: 0.01 | json -}}",
  currencyCode: {{- cart.currency.iso_code | json -}},
  items: [
    {%- for line_item in cart.items -%}
      {
        {%- if line_item.sku != blank -%}
          id: {{- line_item.sku | json -}},
        {%- else -%}
          id: "{{- line_item.product_id | json -}}",
        {%- endif -%}
        name: {{- line_item.product.title | json -}},
        brand: {{- line_item.vendor | json -}},
        category: {{- line_item.product.type | json -}},
        variant: {{- line_item.variant.title | json -}},
        price: "{{- line_item.final_price | times: 0.01 | json -}}",
        position: {{- forloop.index -}},
        quantity: "{{- line_item.quantity | json -}}",
        productId: "{{- line_item.product_id | json -}}",
        variantId: "{{- line_item.variant_id -}}",
        compareAtPrice: "{{- line_item.variant.compare_at_price | times: 0.01 | json -}}",
        image: "{{- line_item.image | image_url -}}"
      },
    {%- endfor -%}
  ]
}
,
          user: {
  {%- if checkout -%}
    cartTotal: "{{- checkout.total_price | times: 0.01 | json -}}",
    currencyCode: {{- checkout.currency | json -}},
  {%- else -%}
    cartTotal: "{{- cart.total_price | times: 0.01 | json -}}",
    currencyCode: {{- cart.currency.iso_code | json -}},
  {%- endif -%}
  {%- if customer -%}
    customer: {
      id: "{{- customer.id | json -}}",
      email: {{- customer.email | json -}},
      firstName: {{- customer.first_name | json -}},
      lastName: {{- customer.last_name | json -}},
      phone: {{- customer.phone | json -}},
      city: {{- customer.default_address.city | json -}},
      zip: {{- customer.default_address.zip | json -}},
      address1: {{- customer.default_address.address1 | json -}},
      address2: {{- customer.default_address.address2 | json -}},
      country: {{- customer.default_address.country | json -}},
      countryCode: {{- customer.default_address.country_code | json -}},
      province: {{- customer.default_address.province | json -}},
      provinceCode: {{- customer.default_address.province_code | json -}},
      tags: {{- customer.tags | join: ', ' | json -}}
    }
  {%- endif -%}
},
          isOnCartPage: false,
          collectionView: null,
          searchResultsView: null,
          productView: null,
          checkoutComplete: {%- if checkout and first_time_accessed -%}
  {
    currencyCode: {{- checkout.currency | json -}},
    actionField: {
      {%- if checkout.order_id -%}
        id: {{- checkout.order_id | json -}},
      {%- else -%}
        id: {{- checkout.id | json -}},
      {%- endif -%}
      {%- if checkout.order_name -%}
        order_name: {{- checkout.order_name | json -}},
      {%- endif -%}
      affiliation: {{- shop.name | json -}},
      revenue: "{{- checkout.total_price | times: 0.01 | json -}}",
      tax: "{{- checkout.tax_price | times: 0.01 | json -}}",
      shipping: "{{- checkout.shipping_price | times: 0.01 | json -}}",
      {%- if checkout.discount_applications -%}
        coupon: {{- checkout.discount_applications[0].title | json -}},
      {%- endif -%}
      {%- if order.subtotal_price -%}
        subTotal: "{{- order.subtotal_price | times: 0.01 | json -}}",
      {%- elsif checkout.subtotal_price -%}
        subTotal: "{{- checkout.subtotal_price | times: 0.01 | json -}}",
      {%- endif -%}
      productSubTotal: "{{- checkout.line_items_subtotal_price | times: 0.01 | json -}}",
      discountAmount: "{{- checkout.discounts_amount | times: 0.01 | json -}}"
    },
    {%- if checkout.customer -%}
      customer: {
        id: "{{- checkout.customer.id | json -}}",
        email: {{- checkout.email | json -}},
        firstName: {{- checkout.billing_address.first_name | json -}},
        lastName: {{- checkout.billing_address.last_name | json -}},
        {%- if checkout.customer.phone -%}
          phone: {{- checkout.customer.phone | json -}},
        {%- elsif checkout.billing_address.phone -%}
          phone: {{- checkout.billing_address.phone | json -}},
        {%- else -%}
          phone: {{- checkout.shipping_address.phone | json -}},
        {%- endif -%}
        city: {{- checkout.billing_address.city | json -}},
        zip: {{- checkout.billing_address.zip | json -}},
        address1: {{- checkout.billing_address.address1 | json -}},
        address2: {{- checkout.billing_address.address2 | json -}},
        country: {{- checkout.billing_address.country | json -}},
        countryCode: {{- checkout.billing_address.country_code | json -}},
        province: {{- checkout.billing_address.province | json -}},
        provinceCode: {{- checkout.billing_address.province_code | json -}},
        tags: {{- checkout.customer.tags | json -}}
      },
    {%- endif -%}
    items: [
      {%- for line_item in checkout.line_items -%}
        {
          {%- if line_item.sku != blank -%}
            id: {{- line_item.sku | json -}},
          {%- else -%}
            id: "{{- line_item.product_id | json -}}",
          {%- endif -%}
          name: {{- line_item.product.title | json -}},
          brand: {{- line_item.vendor | json -}},
          category: {{- line_item.product.type | json -}},
          variant: {{- line_item.variant.title | json -}},
          price: "{{- line_item.final_price | times: 0.01 | json -}}",
          quantity: "{{- line_item.quantity | json -}}",
          productId: "{{- line_item.product_id | json -}}",
          variantId: "{{- line_item.variant_id -}}",
          image: "{{- line_item.image | image_url -}}"
        },
      {%- endfor -%}
    ],
    landingSite: {{- checkout.landing_site | json -}}
  }
{%- else -%}
  null
{%- endif -%}

        }
        
      );
    }
  } catch (error) {
    console.error("Elevar Error:", error);
  }
</script>