I want to make my add to cart button change the text according to the inventory quantity

Hey guys, I am new to coding and websitebuilding. I managed to make the follwoing code work in a custom liquid section, but is not connected to the Quantity buttons. Also i would prefer if it wan´t a custom liquid section but integrated into the product-card.liquid, but i can´t seem to make it work. Could you please help me out/ point out my errors? Thanks in advance and have a nice day (: i am using a free theme, but forgot which one, since i changed alot

{% assign card_product = product %} 

{%- if card_product -%} 

{%- else -%}

{{ 'products.product.not_found' | t }}

 
{%- endif -%}

To integrate your custom code into the product-card.liquid file and connect it to the quantity buttons, follow these steps:

Step 1: Access product-card.liquid

  1. Go to Shopify Admin.

  2. Navigate to Online Store > Themes.

  3. Click on Actions > Edit code next to your active theme.

  4. Open the Sections folder and find product-card.liquid.

Step 2: Modify the Code

Insert this code where you want the quantity buttons:

-

+

Step 3: Save and Test

  1. Save your changes.

  2. Test the product cards in your store to ensure the quantity buttons work correctly.

This code allows users to adjust

the product quantity seamlessly within the product card.

Thanks for your help!

the button i made works in differenciating between inventory quantities, but i want to integrate it into my shopify but it doesn´t work, so i wanted to know how i can do it. i tried the quantity selector and it works, but is not connected to the add to cart button, so it doesn´t matter what the input is there