Displaying Product Category field

ciaranhickey
Shopify Partner
2 0 4

Hello,

 

I am new the shopify theme development and have taken the Dawn theme and customised it for my client (who has an existing store with approx 400 products but required a redesign of their online shop). One field they are keen to display on the front-end is the "Product Category" field. This appears underneath "Product Organization" section in shopify just above the Product Type and Vendor fields.

 

Any documentation I can find on this field seems to refer to it as a field used for categorising products for tax purposes and I don't see any way of accessing it within the Product object in liquid. I can see other fields such as product.type and product.vendor but no reference to Product Category in any of the developer documentation. (eg. https://shopify.dev/api/liquid/objects/product)

 

Any help would be appreciated or any links pointing me in the right direction. From reading the forums there seems to be a lot of confusion between, and misuse of, the terms "Collections" and "Product Categories"

 

Thanks

Ciaran

Replies 5 (5)

Litos
Globetrotter
688 169 143

Hi @ciaranhickey,

If your customer class defines Category as Collection containing products, you can display it with the following code:

{% for collection in product.collections %}
  {{ collection.title }}
{% endfor %}

If it is not Collection, you need to create a field for customers to enter Category using Metafields and then display it. Refer https://help.shopify.com/en/manual/metafields/metafield-definitions/creating-custom-metafield-defini...

Hope it helps!

Litos - Shopify Development Service Provider
Need to develop or customize your Shopify store, feel free to contact us here.
ciaranhickey
Shopify Partner
2 0 4

Hi Litos,

Thanks for your reply. No it is not collections. We already use collections throughout the site but Product Category is another field in Shopify — it already exists and it is a taxonomy. See: https://help.shopify.com/en/manual/taxes/shopify-tax/product-categories-tax

My client has already entered the category for a lot of products so creating a new meta field would mean starting again.

 

The Product Category is not a free text field and requires user to select from one of Shopify's predefined categories/taxonomies as listed here: https://help.shopify.com/txt/product_taxonomy/en.txt

 

I've attached a screen recording of this field in action. Maybe it's a new field introduced?

 

Ahmed__
Shopify Partner
2 0 1

I want to know too. No point in having that Product Category Field and we can't use it in the frontend. I've had a look at at the product JSON response for admin and frontend and that value isn't there. Can someone from Shopify shed some light on this please. 

KuznetsEnvy
Shopify Partner
38 0 10

Upvoting this. Same question: wondering if it's possible in theme Liquid, without apps and GraphQL Admin API.

nikunjsavani17
Shopify Partner
1 0 0

Hi Ciaranhickey,

Did you find any solution for this?
If not I think I need to create metafield for it.