Skip to main content

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:

<div>
{% catalog itemID %}
{{ catalog_item.metadata.$price }}
{% endcatalog %}
</div>

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

Nevermind. There is a `lookup` filter:

 

<div>
{% catalog itemID %}
{{ catalog_item.metadata|lookup:'$price' }}
{% endcatalog %}
</div>

 


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 
{{ catalog_item.id }}  Id The Product ID of the item.

 

David


Reply