How do I access a property with a dollar sing `$` in it's name?

  • 15 September 2022
  • 2 replies

Badge +2

We are using the `catalog` lookup tag to display items from a users wishlist. However, some of the properties have a `$` in them, which breaks the dot.syntax when accessing properties.

"metadata": {
"$price": 24.99,
"$inventory_policy": 1,
"$inventory_quantity": 5,

When I use the following syntax, I get an error message in the template editor and cannot save the template:

{% catalog itemID %}
{{ catalog_item.metadata.$price }}
{% endcatalog %}

Is there a way to escape the dollar sing `$` somehow?


Best answer by Aram Becker 15 September 2022, 10:46

View original

2 replies

Badge +2

Nevermind. There is a `lookup` filter:


{% catalog itemID %}
{{ catalog_item.metadata|lookup:'$price' }}
{% endcatalog %}


Userlevel 7
Badge +60

Hey @Aram Becker,

Glad you found the answer! 

Just to add some more color for others who run into a similar question, we actually offer an overview of our catalog lookup function and provide some of the syntaxes you can use in our Overview of the Catalog Lookup Tag Help Center article. I’ve also gone ahead and included some of the most commonly used template tags and their use cases below found in the very same article:

Template Tag Name Description
{{ catalog_item.description }} Description The description of the item.
{{ catalog_item.tags }} Tags Any tags added to the item.
{{ catalog_item.url }} URL The url for accessing the item in your store.
{{ catalog_item.title}} Title The title of the item.
{% currency_format catalog_item.metadata|lookup:"$price" %} Price The price of an item. This tag formats the item price with the correct currency prefix.
{{ catalog_item.featured_image.full.src }} Full image The url for the full image of the item. Use this inside of an image block, or an <img> tag.
{{ catalog_item.featured_image.thumbnail.src }} Thumbnail The url for the full image of the item. Use this in an <img> tag in custom HTML, or use it as a dynamic image placeholder URL surrounded by the opening and closing {% catalog %} tags 
{{ }}  Id The Product ID of the item.