Code Check

Hello,

On the evening of Sunday 23rd August I noticed customers could not add products to my checkout, it was redirecting to the homepage. After reaching out to Shopify support, they noticed it was the theme I was using. This theme was created by a freelancer I had previously worked with so I switched back to my current theme, however, this was created by the same freelancer. Shopify support suggested I reach out to someone here and ask they check the code for me to ensure nothing else needs adjusting. Can anyone have a quick look over and help with this?

I have not received a sale since I have switched the code back, which is a little odd as I was getting the odd weekly sale. I have also decreased my Google add spend which could have affected this. But any help to do a code check would be much appreciated.

Thanks

post your store URL and one product URL and I will look at the actual page.

In the meantime here is the exact thing to search for, because I reproduced your symptom on a Shopify store

What sends a customer to the homepage after Add to cart

A product form can carry a hidden return_to field that tells Shopify where to send the buyer once the item is added. :

  • No return_to: buyer lands on /cart. Correct.
  • return_to set to /: buyer lands on the homepage. Your exact symptom. The item is in the cart, but they are back on the front page and assume it failed.
  • return_to set to /collections/all: buyer lands on that collection.

Find it

Online Store > Themes, the … button next to your live theme, then Edit code. Duplicate the theme first so you always have a copy to go back to.

In the editor press Ctrl+Shift+F to search every file at once, and search return_to. A clean theme finds nothing. If yours finds it inside a product form, that is your line.

Two more searches in that same box:

  • /cart/add - a hand written theme often hard codes this. It should be {{ routes.cart_add_url }}, otherwise it also breaks on a second language or market.
  • form_type - check the product form is actually wrapped in a proper product form tag.

Use theme new

Add the free Dawn theme, do not publish it, click Preview, and try adding a product to cart. Works on Dawn means the problem is code in the freelancer theme. Fails on Dawn too means it is a setting or an app, and the theme was never the cause.

On the missing sales

Cutting Google spend is a much more likely explanation

Analytics with two weeks before and after. - Fewer sessions at the same conversion rate is the ad budget.

  • Same sessions at a lower conversion rate is the store.

Use backup and restore app for future such issues

Regards,
Ploqo

The return_to check and Dawn comparison are good starting points. I would separate this into two questions:

  1. Does the purchase flow work correctly from product selection through add-to-cart, cart, and checkout?
  2. Did sales fall because the conversion flow is broken, or because traffic decreased after reducing the Google Ads budget?

A focused check should test one representative product on desktop, mobile, and an in-app browser, then compare sessions, add-to-cart events, and checkout starts before and after the theme change.

If you share the store URL, one product URL, and the current theme name, I can first check what is publicly reproducible. Please do not send store credentials.

Hello,

Thank you for your responses!

Ploqo- good point. I will check sessions and conversion rate to nail down the issue for a drop on sales. I will also look at the code as you mentioned.

Lucas Mao I will also check traffic as you’ve suggested. Purchase flow did work correctly from add-to-cart then checkout would redirect to homepage.

Please store information below

Store URL is

https://mywelcove.co.uk/

Product

https://mywelcove.co.uk/collections/clocks-mirrors/products/emi-full-length-black-metal-runway-oval-mirror-180cm-x-80cm

Thanks

Hi @Monique1, thanks. I tested the public product URL. Clicking Add to cart leaves the page in place, but the cart remains empty. The visible /cart/add forms have an empty input[name=“id”], even though the product has an available variant. This means the form is submitting without a variant ID. Please check that the product form uses Shopify’s product form tag and populates the hidden ID with product.selected_or_first_available_variant.id. This is a current theme-form issue and is separate from the traffic drop. If you share the theme name and relevant product-form snippet, I can help identify the exact file and line. No credentials are needed.

Hi @LucasMao

I’ve just learned this is a uploaded theme called Be Yours 4.0.1.

Where can I find the relevant product-form snippet?

Hi Monique. I read the raw HTML that your product page serves (view source, not the inspector) and I can see what Lucas found, along with the reason for it. Both product forms on the page contain the variant field in this form:

<input type="hidden" name="id" value="65831756005725" disabled="disabled">

The variant ID is present, but the field is marked disabled. A disabled field is never sent with the form. Shopify therefore receives an add-to-cart request with no variant and nothing reaches the cart. Your store reports that variant as in stock, so the field should not be disabled. The Shop Pay installment form on the same page has the identical field without the disabled attribute, which is why that path would work while the main button does not.

Where to look: Online Store > Themes > your live theme > Edit code. Open the main product section (Sections > main-product.liquid in most themes built on Dawn) and follow it to the snippet that renders the buy button. Find the line containing name=“id”. The original Dawn line disables the field only when the variant is unavailable. In your copy the condition has most likely been altered so that the field is always disabled. Restore the condition, save, and test Add to cart in a private window.

If you would prefer not to edit the code yourself, send me a message here and I will do it for you at no charge. It is a ten minute change.

Monique, this appears to be a product-form issue rather than a Google Ads problem.

On the EMI mirror page, the hidden variant field contains a valid variant ID but is marked disabled. Browsers do not submit disabled fields, so Shopify receives the add-to-cart request without a variant and the cart remains empty.

Before editing anything, duplicate the theme. In Be Yours 4.0.1, search the theme code for name="id"—likely inside the product-form or buy-buttons snippet—and compare its availability logic with a clean copy of the theme. The field should only remain disabled when the selected variant is genuinely unavailable; don’t remove disabled globally.

After correcting it, test an in-stock item, a sold-out item, variant switching, the cart drawer, and checkout launch on both mobile and desktop.

If you want the wider public storefront checked for similar theme-change regressions, I run a fixed £895 Storefront QA Sprint covering up to 250 public pages, 12 fix-ready findings, a 48-hour turnaround, and a 30-day watch. No Shopify admin access is required. You can book a fit call here: Storefront QA Fit Call | Deniz Izci | Cal.com

I tested the Emi mirror page this morning in a normal browser, and Add to cart worked. But the disabled attribute is still sitting in the raw HTML on two of the three forms, and the theme’s script strips it after the page loads.

So the button only works if that script finishes first, and anything that delays it (a slow phone, an app script erroring ahead of it) breaks add to cart silently. That fits a problem that comes and goes. Worth making @vestfoldhall’s fix anyway, on a duplicate theme.

On the missing sales, before you put it down to the Google budget, a handful of your products are sold out, including four of the black metal mirrors. Paid clicks landing there can’t convert.

Plus, your homepage still shows the theme’s placeholder (“Example product title, £19.99, Sold out”), and the Emi page shows “Couldn’t load pickup availability” under the button.

I noticed the contact is a Gmail address. If you’re handling everything yourself, Carti, my AI sales assistant app might help. It answers pre-sale questions about the weight, fixings, and delivery questions on the page instead of in your inbox the next morning. Should help you convert more. Plus, it’s likely free at your size, with no coding required.

Hi @vestfoldhall

Thanks for the step by steps and offering to help change the code free of charge. I think I’ve found the snippet needed. Does the below look right to you?

          {%- endif -%}

        </div>

        <div class="sticky-cart__content-heading">

          <h3 class="h4 small-hide medium-hide">{{ product.title | escape }}</h3>

          <div class="no-js-hidden" id="price-{{ section.id }}--alt">

            {%- render 'price', product: product, use_variant: true, show_badges: true, price_class: '' -%}

          </div>

        </div>

      </div>

      <product-form class="sticky-cart__form">

        {%- assign sticky_cart_form_id = product_form_id | append: '--alt' -%}

        {%- form 'product', product, id: sticky_cart_form_id, novalidate: 'novalidate', data-type: 'add-to-cart-form' -%}

          <input type="hidden" name="id" value="{{ product.selected_or_first_available_variant.id }}" disabled="disabled">



          <div class="product-form__buttons">

            {%- if sticky_cart.settings.show_quantity_selector -%}

              <div class="product-form__quantity small-hide">

                <label for="Quantity-{{ sticky_cart.id }}" class="visually-hidden">{{ 'products.product.quantity.label' | t }}</label>

                <quantity-input class="quantity">

                  <input class="quantity__input"

                    type="number"

                    name="quantity"

                    id="Quantity-{{ sticky_cart.id }}"

                    min="1"

                    value="1"

                    form="{{ sticky_cart_form_id }}"

                  />

                </quantity-input>

              </div>

            {%- endif -%}

@DanielAnderson Thanks for clarification. I could see product adding to basket, but now I understand everyone is referring to the raw HTML.

Also, thanks for flagging the OOS and missing products, will get onto that and take a look at Carti as this would be a huge help.

Yes, that is the line, and it is one of two. The snippet you pasted is the sticky cart form (its id ends in --alt). The main buy button is rendered by a second form with the same hidden field, and the HTML your store serves shows disabled=“disabled” on both. Change both.

On a duplicate of the theme, replace this line:

<input type="hidden" name="id" value="{{ product.selected_or_first_available_variant.id }}" disabled="disabled">

with this one:

<input type="hidden" name="id" value="{{ product.selected_or_first_available_variant.id }}" {% if product.selected_or_first_available_variant.available == false %}disabled{% endif %}>

Do it in the sticky cart snippet you found and in the main product form (search the theme files for name=“id”; it sits in the buy-buttons or product-form snippet). Save, preview the duplicate, test Add to cart on an in-stock product, then on a sold out one (the button should stay disabled there), then publish.

Daniel is right about why it comes and goes: your theme’s script removes the disabled attribute after the page loads, so the button works when that script runs in time and fails when anything delays it. With the condition in the Liquid, the field is correct before any script runs, and the race is gone.

If you would rather I make the change, say so here and I will walk you through it line by line.

I made a copy of the theme and made the changes. Does the below look correct to you?

{%- form 'product', product, id: product_form_id, novalidate: 'novalidate', data-type: 'add-to-cart-form' -%}

            <input type="hidden" name="id" value="{{ product.selected_or_first_available_variant.id }}" {% if product.selected_or_first_available_variant.available == false %}disabled{% endif %}>

            <div class="product-form__buttons">

              {%- if block.settings.show_quantity_selector -%}

                <div class="product-form__quantity">

                  <label for="Quantity-{{ section.id }}" class="visually-hidden">{{ 'products.product.quantity.label' | t }}</label>

                  <quantity-input class="quantity">

                    <button class="quantity__button no-js-hidden" name="minus" type="button">

                      <span class="visually-hidden">{{ 'products.product.quantity.decrease' | t: product: product.title | escape }}</span>

                      {% render 'icon', icon: 'minus' %}

                    </button>

                    <input class="quantity__input"

                      type="number"

                      name="quantity"

                      id="Quantity-{{ section.id }}"

                      min="1"

                      value="1"

                      form="{{ product_form_id }}"

                    />

Yes, that is exactly right, and that is the main form. Two things remain, then you are done:

  1. The same line in the sticky cart snippet, the one you pasted this afternoon (its form id ends in --alt). Same replacement, so both forms carry the condition.
  2. Test in the duplicate before you publish: open the theme preview, pick an in-stock product and press Add to cart (it should land in the cart), then a sold out product (the button should stay disabled), then a product with options and switch between them. If all three behave, publish the duplicate.
    When it is live, say so here and I will read the page from outside to confirm the disabled attribute is gone on in-stock products.

Thank you!

I tested and all seemed to be working correctly so I published the the duplicate - https://mywelcove.co.uk/

This product has in and out of stock variants

That did it. I read both pages from outside just now: on the Danforth and the Dundas pages every form carries the variant field enabled, and in a fresh browser Add to cart put the Danforth set in the cart, then the Dundas chairs in Blue. The Dundas page is a good test because three of its six colours are out of stock: pick Grey and the button turns to Sold out, pick Blue again and it is back to Add to cart.

Since the sold out products came up earlier and you said a list would help: I read your catalogue the way a shopper’s browser does, and it is more than a handful. I found these by running the same daily check I built for my own store over your catalogue. Twelve products are sold out in every option and still live, so a shopper or an ad click can land on a page with nothing to buy:

  • Takara, Akiko, Aimi and Mio full length mirrors
  • 3 Piece Rattan Bistro Set, Grey
  • Rattan Garden Corner Sofa Set, Grey
  • Extendable White Dining Table With Storage
  • Extendable Dining Table and 4 Velvet Chairs Set
  • Compact Square Dining Table and 4 Chairs Set
  • Round Marble Effect Dining Table and 4 Velvet Chair Set, White
  • Set Of Two Relaxed Tub Bar Stools, Orange
  • Acoustic Wall Panels in Petal Pink

Nineteen more are sold out in some options. For the twelve, either take the product off the online store until stock returns (and pause any ad that points at it), or keep it live with a back in stock sign-up rather than a bare Sold out button. Two smaller things while you are in there: the homepage has no meta description tag and no share image tag (your product pages have both), so Google writes its own line for the homepage and a shared link to the store carries no picture.

Let me know here if anything else misbehaves. Glad the button is back in business.

This is so helpful. Thanks so much for this and your previous help! I’ll remove those products