I need help with Shopify Cart refresh problem

I have created a section where i have added a Add to cart below the products details. What i wanted is that once someone Clicks the add to cart it’s should open up the cart drawer but rightnow it’s opening up cart page which is not right.

My store Link: https://pritam7874.myshopify.com/ Password: 123

Here’s the code for the section:

{% comment %}

Featured Products Section

For Horizon Theme v3.2.1

Correctly implements ‘product-form-component’ with required refs.

{% endcomment %}

{% if section.settings.heading != blank %}

  <h2 class="section-heading">{{ section.settings.heading }}</h2>

{% endif %}



<div class="product-grid">

  {% for block in section.blocks %}

    {% if block.settings.product != blank %}

      {% assign product = block.settings.product %}

      <div class="product-card" {{ block.shopify_attributes }}>

        {% if block.settings.show_new_badge %}

          <span class="new-badge">NEW</span>

        {% endif %}

        

        <div class="product-image">

          {% if product.featured_image %}

            <img 

              src="{{ product.featured_image | image_url: width: 400 }}" 

              alt="{{ product.featured_image.alt | escape }}"

              width="400"

              height="400"

              loading="lazy"

            >

          {% else %}

            {{ 'product-1' | placeholder_svg_tag: 'placeholder-svg' }}

          {% endif %}

        </div>

        

        <div class="product-info">

          <h3 class="product-title">

            <a href="{{ product.url }}">{{ product.title }}</a>

          </h3>

          

          <div class="product-price">

            {% if product.compare_at_price > product.price %}

              <span class="price-compare">{{ product.compare_at_price | money }}</span>

            {% endif %}

            <span class="price">{{ product.price | money }}</span>

          </div>

          

          {% comment %} 

            Horizon Native Form Component 

            Required Refs: variantId, liveRegion

          {% endcomment %}

          <product-form-component>

            <form action="{{ routes.cart_add_url }}" method="post" class="product-form" enctype="multipart/form-data">

              

              <!-- COMPONENT REQUIREMENT 1: ref="variantId" -->

              <input type="hidden" name="id" value="{{ product.variants.first.id }}" ref="variantId">

              <input type="hidden" name="quantity" value="1">

              

              <!-- COMPONENT REQUIREMENT 2: ref="liveRegion" -->

              <div class="sr-only" ref="liveRegion" aria-live="polite"></div>

              

              <!-- COMPONENT REQUIREMENT 3: ref="addToCartTextError" (Optional but recommended) -->

              <div class="form-error-message-wrapper hidden" ref="addToCartTextError" role="alert"></div>

              <add-to-cart-component

                ref="addToCartButtonContainer"

                data-product-variant-media="{{ product.featured_image | image_url: width: 100 }}"

              >

                <button 

                  type="submit" 

                  name="add"

                  ref="addToCartButton"

                  class="add-to-cart-btn button"

                  {% unless product.available %}disabled{% endunless %}

                >

                  <span class="add-to-cart-text">

                    {% if product.available %}

                      Add to Cart

                    {% else %}

                      Sold Out

                    {% endif %}

                  </span>

                </button>

              </add-to-cart-component>

            </form>

          </product-form-component>

        </div>

      </div>

    {% endif %}

  {% endfor %}

</div>
.featured-products-section { padding: 60px 0; background-color: {{ section.settings.background_color }}; } .page-width { max-width: 1400px; margin: 0 auto; padding: 0 20px; } .section-heading { text-align: center; font-size: 36px; margin-bottom: 40px; font-weight: 600; } .product-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 30px; max-width: 1200px; margin: 0 auto; } @media (min-width: 768px) { .product-grid { grid-template-columns: repeat(4, 1fr); } } .product-card { position: relative; background: white; border-radius: 12px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); transition: transform 0.3s ease, box-shadow 0.3s ease; text-align: center; display: flex; flex-direction: column; } .product-card:hover { transform: translateY(-5px); box-shadow: 0 4px 16px rgba(0,0,0,0.12); } .new-badge { position: absolute; top: 15px; right: 15px; background: #ff0000; color: white; padding: 6px 12px; border-radius: 4px; font-size: 12px; font-weight: bold; z-index: 1; } .product-image { width: 100%; height: 250px; display: flex; align-items: center; justify-content: center; margin-bottom: 20px; overflow: hidden; border-radius: 8px; } .product-image img { max-width: 100%; max-height: 100%; object-fit: contain; } .product-info { padding-top: 10px; flex-grow: 1; display: flex; flex-direction: column; justify-content: flex-end; } .product-title { font-size: 18px; margin-bottom: 10px; min-height: 50px; display: flex; align-items: center; justify-content: center; } .product-title a { color: #333; text-decoration: none; font-weight: 500; } .product-title a:hover { color: #666; } .product-price { margin-bottom: 15px; font-size: 20px; font-weight: 600; color: #333; } .price-compare { text-decoration: line-through; color: #999; margin-right: 8px; font-size: 16px; } .product-form { width: 100%; margin-top: auto; } .add-to-cart-btn { width: 100%; background: #000; color: #ffd700; border: none; padding: 12px 24px; border-radius: 6px; font-size: 16px; font-weight: 600; cursor: pointer; transition: background-color 0.3s ease; } .add-to-cart-btn:hover:not(:disabled) { background: #333; } .add-to-cart-btn:disabled { background: #ccc; cursor: not-allowed; color: #666; } .add-to-cart-btn.adding { opacity: 0.7; pointer-events: none; } .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; } .hidden { display: none !important; }

{% schema %}

{

“name”: “Featured Products”,

“tag”: “section”,

“class”: “section”,

“settings”: [

{

  "type": "text",

  "id": "heading",

  "label": "Section Heading",

  "default": "Featured Products"

},

{

  "type": "color",

  "id": "background_color",

  "label": "Background Color",

  "default": "#ffffff"

}

],

“blocks”: [

{

  "type": "product",

  "name": "Product",

  "settings": \[

    {

      "type": "product",

      "id": "product",

      "label": "Select Product"

    },

    {

      "type": "checkbox",

      "id": "show_new_badge",

      "label": "Show NEW Badge",

      "default": true

    }

  \]

}

],

“presets”: [

{

  "name": "Featured Products"

}

],

“max_blocks”: 8

}

{% endschema %}

Doesn’t Horizon already has Quick-add functionality?
Just relocate the button, or, if it does work, copy the existing code?

This already exists in Horizon. You don’t need any special code or custom section. Just add a featured collection section, add the “buy buttons” block and make sure this setting is turned on.

Yh, I have been using his functionality already but it’s not working for the new section that i created.

That works for a inbuilt product grid and not for when you create a section From Scratch. Can you Check the code if i am missing something in there that i can’t figure out?

Why not re-use existing product-card block/snippet ?

Have you sought the help of the Sidekick helper? You could also check your theme’s add-to-cart.liquid file in the snippets folder and compare it with your product-form-component.