need help Editing variant product code, theme Enterprise

The concept I would like to make is to sell products in single copy (That is to say only one copy per product).
I have a problem with the variants. I would like to offer my customers to choose the size of their product however, if I put variants of sizes, for example 5 sizes, there is no longer a single product but 5 so it is not at all the same concept.
So my question is: Is there a solution so that once the size chosen, the product is sold out even if there are other variants?

I asked to Chatgpt some code to do that but I don’t know where to put them in the code pf my store.

here are the code I have from Chatgpt :

{% assign sizes_inventory = {} %}
{% for variant in product.variants %}
{% assign sizes_inventory[variant.option1] = variant.inventory_quantity %}
{% endfor %}

Sélectionnez la taille :

Acheter

Hi Evaelle,

This code would likely be added to the Liquid section or snippet where the product form is contained - you could reach out to the Clean Canvas support for help with this. Also, I’d recommend being quite careful adding custom code generated by ChatGPT to a fully built theme, as the model won’t be aware of the current theme configuration which means it likely won’t be compatible with styles and settings - so make sure you’re creating a theme back up and not adding generated code to a live theme.

I tried to reach out the Clean Canvas support before doing anything.

I’m actually waiting for their response.