16. {%- assign tabs = product.metafields.tabs -%}
<ul class="tabs">
<li>{{ product.description }}</li>
{%- for field in tabs -%}
<li>{{ field | first }}: {{ field | last }}</li>
{%- endfor -%}
</ul>
Basic code example.
Product code would be prettier and
check for valid metafield namespaces
17. 1. Extends data fields, to complement or override
2. Avoids alternate templates to simplify theme files
3. Avoids abusing tags (remember the 1000 limit)
4. Avoids adding hacks in the description*
5. Maintains a pretty content structure
6. Keeps content hidden away**
7. They're awesome.
* sometimes these hacks are a good thing
** not always a good thing
19. Migrations. Other platforms
may have custom fields that
show on the storefront.
Knowing you can map this data in the migration
makes for an easier project win.
20. Design touches like colour
theming. Blue product has
blue buttons, blue text.
A metafield can store a hex code that's
then used to output an inline style
https://www.covetnation.com/products/occ-cosmetic-pencil-pool-boy
24. Tabs and extra content.
Basic extra content, in different places
25. {%- assign tabs = product.metafields.tabs -%}
<ul class="tabs">
{% include 'product-description' %}
{%- for field in tabs -%}
<li><h2>{{ field | first }}</h2>{{ field | last }}</li>
{%- endfor -%}
{% include 'related-products' %}
</ul>
Basic code example.
Product code would be prettier and
check for valid metafield namespaces
40. {%- assign r = product.metafields.related.items | split:"," -%}
<div class="related-products">
{%- for p in r -%}
{% assign relatedProduct = all_products[p] %}
{%- include 'some-snippet' product: relatedProduct -%}
{%- endfor -%}
</div>
This could be easier to read.
41.
42. {%- assign cParent = product.metafields.col.parent -%}
{%- assign cChild = product.metafields.col.child -%}
<div>
{%- if collections[cChild].products.size > 0 -%}
{%- include 'collection-loop' with collections[cChild] -%}
{%- endif -%}
</div>
This could be easier to read.
43. SEO control. Set custom
canonical urls and meta
tags with metafields.
Related products. Related collections.
Nested collections. Products in articles.
44. Hide items from the
sitemap.
Related products. Related collections.
Nested collections. Products in articles.
45. To add noindex and nofollow
meta tags to an object's
pages, create a new
metafield for the object with
the following attributes:
https://help.shopify.com/api/tutorials/updating-seo-data
"namespace" : "seo"
"key" : "hidden"
"value" : 1
"value_type" : "integer"
46. Cost of Goods.
I see a few people asking for a way to store COGs.
This can help.
49. Should the metafield even
live in Shopify?
Think smart about the data usage and how you're going to store it. Many things
would be better in their own offsite database. Others in built in options.
50. Not well supported in the
Admin. You must rely on
apps and third party tools.
Only the bulk product editor has the
ability to edit metafields
https://www.shopify.com/partners/blog/53573123-secrets-of-the-shopify-bulk-editor
51. Metafields are not
returned in Admin or
Storefront search.
Storefront can be helped with apps,
or AJAX search methods (if the SKU count is small)
52. API call limits are a real
thing. Are you considering
that in your dev flow?
How many metafields are you saving?
How many per object? How often will you update?
100 values in 1 metafield faster than 100 individual metafields
53. Metafields don't work in
Shopify Scripts.
How many metafields are you saving?
How many per object? How often will you update?
55. Document your usage for
the merchant and fellow
dev in the theme.
Nothing worse than digging through some complex theme to find there's a pile of
custom content being pulled in from a metafield.
56. More
1. Shopify Bulk Editor (built in metafield editing)
2. Shopify Apps (search for metafields)
3. Extensions like ShopifyFD or Custom Fields
4. xporter app
5. https://help.shopify.com/themes/liquid/objects/metafield
6. https://help.shopify.com/api/reference/metafield
7. https://www.shopify.com/partners/blog/110057030-using-metafiel
ds-in-your-shopify-theme
77. Autocomplete
• Provide value in results
• Remove clutter
• Obsess about relevance
• Refine synonyms
• Analyse data
• Modify results
78. Filters
• Use existing data, if possible
• Survey customers about how
they refine searches
• Set realistic min max
boundaries
• Test for speed
• Customise sort order on a per-
result set basis
• Boost the results you want
• Push down the results you
don’t
• Decide between OR / AND
• Allow easy toggling of
selections
• Make good use of UI elements
79. Information / Guides
• Separate results in different
categories within the same
collection
• Index informational results
alongside shopping results
80. Results Picker
• Guide by selection for people
who need prompting
• Think like your customers
• Provide quick, contextual
updates
• Show counts with selects
82. Advanced Filtering
• Consider your audience
• Show relevant data in results
• Contextual searches with
dropdowns
• Advanced filtering based on
category