Adding Custom Fields to the Shopify Dashboard

Shopify Expert
9556 28 1311

I am pushing an update now that should fix field population when using the shorter c_f namespace. I've done limited testing, but looks aok from here. Keep me posted.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
1 Like
Shopify Partner
411 0 51

Hey Jason,

Have you come across a special way to pull in variant metafields at all in bulk? I know product ones you can pull in with the X-Shopify-API-Feature header.

Thanks,

Ryan

 

Want an app but can't find what you need? Let us know we custom build apps for Free
1 Like
Shopify Partner
3 0 3

Works great, thanks! (Wasn't sure if the extension updated yet so I grabbed the js from Github).

Set a (small, I'm afraid) tip - thanks so much for fixing it!

1 Like
Shopify Expert
9556 28 1311

Have you come across a special way to pull in variant metafields at all in bulk?

Nope. Attached resources have to be nabbed on a per object basis so I don't think there's a super magical way to just call up all metafields at once. It's come up before in discussions but in the end having to do a loop is not a major issue - it's just time.

Works great, thanks! (Wasn't sure if the extension updated yet so I grabbed the js from Github).

The extension just grabs it from Github anyway. Not really ideal as a CDN but it makes it simple for people to check out the source javascript that's getting injected into the page. There's a level of trust involved so I don't really want to mask the files behind a non tracked CDN.

 

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
1 Like
Shopify Partner
1 0 1

Incredible work on this, Jason. Are you planning to include support for page metafields?

1 Like
Shopify Expert
9556 28 1311

Are you planning to include support for page metafields?

Yes, including collections and articles.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
1 Like
Shopify Staff
Shopify Staff
5826 0 258

Hey Jason,

In the second post in this thread you show a screenshot of a guide, but the link your provide is not linking to a page where I see that guide available.

Tool and basic and rough user guide is now online for adding custom fields.

Where is that guide ^ ??

Caroline from http://11heavens.com ∴ mllegeorgesand AT gmail DOT com
1 Like
Shopify Staff
Shopify Staff
5826 0 258

Oops, sorry, I just read above that the guide was taken down.

Jason, will you be implementing [p][_p]Label soon? :)

I'd need it for related products.

Caroline from http://11heavens.com ∴ mllegeorgesand AT gmail DOT com
1 Like
Shopify Expert
9556 28 1311

I'm hoping to spend some quality time on both soon. This would included getting the product picker added in.

I am also seriously giving thought to dumping the idea of per product custom fields and just sticking to globals. It would save having to use the bracketing system for marking field types as the settings could be added into the shop level metafield value instead. Don't get lots of user feedback so I'm not sure if this would make people cry or not.

May as well keep rolling down the rabbit hole for now.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
1 Like
Shopify Staff
Shopify Staff
5826 0 258

Hi Jason!

I don't see any use for product-specific metafield, so I'd drop those, yes. Metafields are only useful when output in the theme, and all products are rendered by the same product template. A product can have its Whatever Label field left blank, and a theme can check if it contains anything before it uses it.

I am having some trouble using custom fields for products though.

I have this Ingredients custom field:

This is the namespace and key:

So:

  • Namespace: c_f
  • Key: [p][_t]Ingredients

First problem:

Liquid does not like brackets when accessing Liquid tags. Liquid has a reserved use for brackets.

When using this:

<p>Ingredients: {{ product.metafields.c_f.[p][_t]Ingredients }}</p>

I get this warning when I am staff — you won't see these warnings as they are only visible to Shopify staff now:

Liquid Warning (staff only): Expected id but found open_square in "{{ product.metafields.c_f.[p][_t]Ingredients }}"

I work around this by using an additional variable:

{% assign key = '[p][_t]Ingredients' %}
<p>Ingredients: {{ product.metafields.c_f[key] }}.</p>

Second problem is that I can't read my ingredients directly.

On the product that has the Ingredients metafield set, I get nothing:

Oddly, when I inspect all custom metafields with that code:

<ul>
  {% for field in product.metafields.c_f %}
  <li>{{ field | first }}: {{ field | last }}</li>
  {% endfor %}
</ul>

I do see my metafield:

Weird!

So, there's no way to access the metafield directly that I know of.

Caroline from http://11heavens.com ∴ mllegeorgesand AT gmail DOT com
1 Like