获取 Shopify 集合中可用产品的数量

Get number of available products in a Shopify collection

我知道我可以使用 collection.products_count 来计算某个系列的产品数量,但是是否有可能获得 可用 产品的数量,例如没卖?

您需要迭代产品并检查它们的可用性:

{% assign available_products = 0 %}

{% for product in collection.products %}
  {% if product.available %}
    {% assign available_products = available_products | plus: 1 %}
  {% endif %}
{% endfor %}

{{ available_products }}