How to use BigCartel “Variables” to Call Different

2019-09-15 15:29发布

I'm wondering if there are any specific "variables" I can use to ask the BigCartel database to generate products from one of the categories you can specify within your inventory?

(Ex: I would like to create a "Featured Items" section that will showcase 4 products from my T-Shirts category, a separate section for Patches, Crewnecks, Koozies, etc.)

I know you can use variables to ask the database to generate all kinds of information (ex: product title, product image, price, etc.), but I cannot seem to find one that will allow you to ask for products of a specific category.

Any help would be most appreciated. Thanks so much!

标签: bigcartel
1条回答
劫难
2楼-- · 2019-09-15 16:23

Use a for loop to retrieve products from specific categories (along with limit if you only want to show 4 products) like so:

{% for product in categories.accessories.products limit:4 %}
  <p>{{ product.name }}: {{ product.price }}</p>
{% endfor %}

Replace "accessories" with whatever permalink represents the category you're trying to pull from and you're all set.

查看更多
登录 后发表回答