help: error with debut theme, Random code on product pages wasn't there before

Solved
dauthority
Tourist
9 0 4

Hi! 

 

I randomly noticed that this little piece of code shows up at the bottom of my product images. Any idea how to fix? The code that appears is ", soldOut: "Sold out", unavailable: "Unavailable" onclick="pintrk('track', 'addtocart');""

Screen Shot 2021-09-01 at 2.10.08 PM.png

0 Likes
Trevor
Community Moderator
Community Moderator
2955 385 596

@dauthority 

Typically this is a result of deleting an app from your store that injected code into your product page. Have you recently removed any apps? The code snippet will likely live in either the "product.liquid" or "product-template. liquid" file which can be accessed by going to Online Store/Themes/Actions/Edit Code. If you can share the URL to your store, then I can take a look at the front-facing code to see how it can be removed. 


Trevor | Community Moderator @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Guleria
Shopify Partner
1781 377 532

Hello @dauthority ,

This is because there is broken html in your product page.
I suggest share your store URL so someone can check and confirm where it is. 

Thanks

Want to modify or custom changes on store hire me.
Email: guleriathakur43@gmail.com, Skype: navrocks1
If helpful then please Like and Accept Solution.
Buy me a coffee ☕ My PayPal
0 Likes
dauthority
Tourist
9 0 4

darling-authority.myshopify.com

0 Likes
Trevor
Community Moderator
Community Moderator
2955 385 596

@dauthority 

Looks like it's a script added by an app. If you go to Online Store/Themes/Actions/Edit code, then open the "product.liquid" file, do you see a snippet/script code at the very bottom of the file? If yes, I would try deleting that line then saving the file as I suspect that should resolve the issue. 


Trevor | Community Moderator @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

0 Likes
dauthority
Tourist
9 0 4
{% comment %}
  The contents of the product.liquid template can be found in /sections/product-template.liquid
{% endcomment %}

{% section 'product-template' %}

<script>
  // Override default values of shop.strings for each template.
  // Alternate product templates can change values of
  // add to cart button, sold out, and unavailable states here.
  theme.productStrings = {
    addToCart: {{ 'products.product.add_to_cart' | t | json }} <script data-app="esc-out-of-stock" type="text/json">[{% for variant in product.variants %}{"id":{{ variant.id }},"title":"{{ variant.title | escape }}","option1":{% if variant.option1 %}"{{ variant.option1 | escape }}"{% else %}null{% endif %},"option2":{% if variant.option2 %}"{{ variant.option2 | escape }}"{% else %}null{% endif %},"option3":{% if variant.option3 %}"{{ variant.option3 | escape }}"{% else %}null{% endif %},"sku":{% if variant.sku %}"{{ variant.sku | escape }}"{% else %}null{% endif %},"requires_shipping":{{ variant.requires_shipping }},"taxable":{{ variant.taxable }},"featured_image":{% if variant.featured_image %}"{{ variant.featured_image }}"{% else %}null{% endif %},"available":{{ variant.available }},"name":"{{ variant.name }} | escape","public_title":"{{ variant.public_title }} | escape","options":{{ variant.options | json }},"price":{{ variant.price }},"weight":{% if variant.weight %}{{ variant.weight }}{% else %}0{% endif %},"compare_at_price":{% if variant.compare_at_price %}{{ variant.compare_at_price }}{% else %}null{% endif %},"inventory_quantity":{{ variant.inventory_quantity }},"inventory_management":{% if variant.inventory_management %}"{{ variant.inventory_management }}"{% else %}null{% endif %},"inventory_policy":{% if variant.inventory_policy %}"{{ variant.inventory_policy }}"{% else %}null{% endif %},"barcode":{% if variant.barcode %}"{{ variant.barcode }}"{% else %}null{% endif %}}{% unless forloop.last %},{% endunless %}{% endfor %}]</script>,
    soldOut: {{ 'products.product.sold_out' | t | json }},
    unavailable: {{ 'products.product.unavailable' | t | json }}
    onclick="pintrk('track', 'addtocart');"
</script>

{% assign current_variant = product.selected_or_first_available_variant %}

<script type="application/ld+json">
{
  "@context": "http://schema.org/",
  "@type": "Product",
  "name": "{{ product.title | escape }}",
  "url": "{{ shop.url }}{{ product.url }}",
  {%- if product.featured_image -%}
    {%- assign image_size = product.featured_image.width | append: 'x' -%}
    "image": [
      "https:{{ product.featured_image.src | img_url: image_size }}"
    ],
  {%- endif -%}
  "description": "{{ product.description | strip_html | escape }}",
  {%- if current_variant.sku != blank -%}
    "sku": "{{ current_variant.sku }}",
  {%- endif -%}
  "brand": {
    "@type": "Thing",
    "name": "{{ product.vendor | escape }}"
  },
  "offers": [
    {%- for variant in product.variants -%}
      {
        "@type" : "Offer",
        {%- if variant.sku != blank -%}
          "sku": "{{ variant.sku }}",
        {%- endif -%}
        "availability" : "http://schema.org/{% if product.available %}InStock{% else %}OutOfStock{% endif %}",
        "price" : "{{ variant.price | divided_by: 100.00 }}",
        "priceCurrency" : "{{ cart.currency.iso_code }}",
        "url" : "{{ shop.url }}{{ variant.url }}"
      }{% unless forloop.last %},{% endunless %}
    {%- endfor -%}
  ]
}
</script>

{% include 'buddha-crosssell' %}
0 Likes
Trevor
Community Moderator
Community Moderator
2955 385 596

@dauthority 

I would try removing [% include 'buddha-crosssell'' %] as that is likely the cause of the issue. 


Trevor | Community Moderator @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

0 Likes
dauthority
Tourist
9 0 4
Hmm, that didn't seem to work
0 Likes
Trevor
Community Moderator
Community Moderator
2955 385 596

This is an accepted solution.

@dauthority 

Thank you for confirming. This may be outside my level of expertise, however, looking at the code you've provided, it could be the script you have near the top of the file 

<script>
// Override default values of shop.strings for each template.
// Alternate product templates can change values of
// add to cart button, sold out, and unavailable states here.
theme.productStrings = {
addToCart: {{ 'products.product.add_to_cart' | t | json }} <script data-app="esc-out-of-stock" type="text/json">[{% for variant in product.variants %}{"id":{{ variant.id }},"title":"{{ variant.title | escape }}","option1":{% if variant.option1 %}"{{ variant.option1 | escape }}"{% else %}null{% endif %},"option2":{% if variant.option2 %}"{{ variant.option2 | escape }}"{% else %}null{% endif %},"option3":{% if variant.option3 %}"{{ variant.option3 | escape }}"{% else %}null{% endif %},"sku":{% if variant.sku %}"{{ variant.sku | escape }}"{% else %}null{% endif %},"requires_shipping":{{ variant.requires_shipping }},"taxable":{{ variant.taxable }},"featured_image":{% if variant.featured_image %}"{{ variant.featured_image }}"{% else %}null{% endif %},"available":{{ variant.available }},"name":"{{ variant.name }} | escape","public_title":"{{ variant.public_title }} | escape","options":{{ variant.options | json }},"price":{{ variant.price }},"weight":{% if variant.weight %}{{ variant.weight }}{% else %}0{% endif %},"compare_at_price":{% if variant.compare_at_price %}{{ variant.compare_at_price }}{% else %}null{% endif %},"inventory_quantity":{{ variant.inventory_quantity }},"inventory_management":{% if variant.inventory_management %}"{{ variant.inventory_management }}"{% else %}null{% endif %},"inventory_policy":{% if variant.inventory_policy %}"{{ variant.inventory_policy }}"{% else %}null{% endif %},"barcode":{% if variant.barcode %}"{{ variant.barcode }}"{% else %}null{% endif %}}{% unless forloop.last %},{% endunless %}{% endfor %}]</script>,
soldOut: {{ 'products.product.sold_out' | t | json }},
unavailable: {{ 'products.product.unavailable' | t | json }}
onclick="pintrk('track', 'addtocart');"
</script>

This appears directly above the broken string on your product pages when viewing the console code. You could try removing that script and seeing if that resolves the issue. If not, then you can revert the code back by clicking "older versions" in the file you edited which will allow you to revert the file back to how you had it before. 

If this is a Shopify-free theme, then I would recommend contacting Shopify Support so our themes team can take a closer look as they'll have direct access to your store. You can do this by logging into your store through the help center, searching your question/issue, then selecting "continue" at the bottom of the page that displays the search results. 


Trevor | Community Moderator @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

0 Likes
dauthority
Tourist
9 0 4

Removing the script worked!! Thanks