How can I use string values to select array in product quantities?

I have tried several option but I am not able to get this to work.

I have several arrays storing quantity values for products.

{% assign Product1 = “200,500,1000,2000” | split: ‘,’%}
{% assign Product2 = “500,5000,10000,50000” | split: ‘,’ %}

I am trying to match the product name (using current_variant.sku) to the array name to allow me to use the array contents. I am looping through the values of current_variant.sku to add to a string that I can use to lookup quantities in the array of that name of the product.

current_variant.sku = (product1,product2 …

Not sure I am doing this the right way of if I am completely off track. Appreciate any advice.

Thanks

XY problem, ignoring code what is the GOAL you are trying to get to

https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem

Are you not able to use metafield definitions, or product-tags, to put that “array” data directly on the product?

Split created arrays have no hash/key/value accessor method unlike how some native objects allow i.e:

{{ all_products['product-handle-string'].url }}

{%- assign varstring = "product-handle-string" -%}
{{ all_products[varstring ].url }}

trying to match the product name (using current_variant.sku) to the array name

Do you mean you are trying to match variant title to a variable name?

There’s no eval feature in liquid to convert a string to an assigned variable name.

You’d have to manually parse the string in an {%if%} or a {%case%} statement matching the string to then trigger using that variable name.

I think the closest hack is using liquid includes with the filenames as variables holding that string.

am looping through the values of current_variant.sku

The sku is a singular value do you mean you are looping over all the variants in a product?

Otherwise there’s only 1 current_variant at a time per product if you are referring to product.selected_variant https://shopify.dev/api/liquid/objects/product#product-selected_variant .

If you have the current_variant, you should already have access to the containing product object and not have to use a sku to figure out what the product is.

You may want to reread this a few times and re-approach the problem statement for clarity or make a better simplified example.