"products.product.foo" -- what is it exactly?

I apologize as I’m a newer developer, but one thing that’s always confused me, is how button labels are defined and whether it’s possible to expand this somehow. For example, I know that {{ products.product.add_to_cart | t }} will return a string that says “Add to cart” and I know that similarly {{ products.product.sold_out | t }} will return “Sold out,” but I’m curious if these returned strings can be modified in any way, or if it’s possible to assign new definitions without metafields – i.e. creating definitions for products.product.item_requires_id for something like alcohol or products.product.additional_confirmation if an item needs additional action by the user before adding to cart.

Main reason I’m interested is because I have two different reasons for products requiring additional confirmation on a test store I’m working on – either the product is marked as a preorder (assigned via a metafield with a month and year), or the selected variant is B-Stock inventory (a separate variant of a given product. The conditional logic for this is easy enough, but if I could just have a globally-defined variable to handle that for me and spit the same string back every time, it’d be convenient.

I think the most general resource is this: https://help.shopify.com/en/manual/online-store/themes/customizing-themes/language/change-wording

Basically you are talking about translations or default theme content

Via code you can add more translations, e.g. products.product.item_requires_id as mentioned. Those are found in the /locales/ folder. Look for the file suffixed with .default.json and add it there.

Edit: Locales

2 Likes

Exactly what I was looking for, thank you!

1 Like