Why isn't my custom 'Add to Cart' button working?

Hey everyone,

I’m trying to write a custom theme from scratch, which means coding the “Add to Cart” system from scratch. I don’t want a quantity button on the page, I just want it to add 1 of the product to the cart.

As far as I’m aware, all you need for this to work is to pass the product’s ID and quantity through a form that posts it to “/cart/add”. However, I can’t seem to get it to work, as it always states “Parameter Missing or Invalid: Required parameter missing or invalid: items” whenever I click the “Add to Cart” button.

I’ve provided the code for the form below — is anyone able to tell me where I’m going wrong? I would really appreciate it.

My Code:

{% form 'product', product %}
  
    
    

      {% for variant in product.variants %}
        
        
      {% endfor %}
    

  

  
  
  

  

    {{ form | payment_terms }}
  

{% endform %}
1 Like

@leoprd

Sorry you are facing this issue, it would be my pleasure to help you.

Welcome to the Shopify community! :blush:
Thanks for your good question.

Please share your site URL,
I will check out the issue and provide you a solution here.

1 Like

Hey @KetanKumar ,

My site URL is vintagememories.co .

Thank you for helping me out and I hope to hear from you soon!

1 Like

@leoprd

do you have theme backup?

@KetanKumar

Theme backup? I’m not sure what you mean.

@leoprd

i mean which theme you have used can you please check default code

1 Like

@KetanKumar

Like I said, I’m coding the theme from scratch. I didn’t use any of the default themes.

@leoprd

ok i can’t see that code modification can you back to older version

@KetanKumar

If you’re wondering what specific page the “Add to Cart” button is on, here’s that page’s URL: vintagememories.co/products/hoodie