How to use BigCartel “Variables” to Call Different Product Categories

久未见 提交于 2020-01-06 17:11:08

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/39479456/how-to-use-bigcartel-variables-to-call-different-product-categories

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!