Product Information Not Displaying in Custom Section Despite Being Selected in Theme Settings

I’m working on a custom section in my Shopify theme (version 2.0.2, “Refresh” theme by Shopify). I’ve set up a custom product selection feature that allows users to select products from the theme settings, and it displays them in a custom product display section. However, despite selecting products in the theme editor, the front-end still shows “No product selected” placeholders, and the product information (e.g., product name and image) does not display.

Here’s a snippet of my current code:

{% for product_id in section.settings.selected_products %} {% assign product = all_products[product_id] %} {% if product %}
{{ product.title }}
{{ product.title }} {{ product.price | money }}
{% else %}
No product selected
{% endif %} {% endfor %}

I’ve confirmed that the product IDs are being selected properly in the theme settings and that the all_products object should be available.

Questions:

  1. What could be causing the selected products not to display on the front end, even though they’re chosen in the theme settings?
  2. Are there any limitations or known issues with using all_products in a custom section that might prevent product data from rendering correctly?
  3. Would using product metafields be a more reliable solution for accessing product data in this scenario, and if so, how should I implement it?

Any insights or guidance would be greatly appreciated!

If you are open to collaborate i will definitely want to take a look.

Please reach out via mail with your Collab access code for a convenient conversation and collaboration

Best

Shadab

You have not shared the schema, so can only base my suspicions on variable names, but

{% for product_id in section.settings.selected_products %}
{% assign product = all_products[product_id] %}

all_products expects product handle, not id.

https://shopify.dev/docs/api/liquid/objects/all_products