forked from Shopify/dawn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
examples.liquid
114 lines (85 loc) · 3.09 KB
/
examples.liquid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
{% assign authors shop.metaobjects.authors | where: "id", "53685026934" %}
{% for author in authors %}
Yo
{% endfor %}
{% assign authors2 %}
{% for author in authors2 %}
Yo {{ author.id }}
{{ author.handle }}
{% endfor %}
{% for author in shop.metaobjects.author.values %}
{{ testimonial.author.value }}
{% endfor %}
{% for testimonial in shop.metaobjects.testimonials.values %}
{{ testimonial.author.value }}
{% endfor %}
{{ shop.metaobjects.testimonials.home_page.system.id }}
WORKS:
{{ product.metafields.test.testmeta.value.first_name.value }}
{{ product.metafields.test.testmeta.value.system.handle }}
{{ collections[collection.metafields.test.test].title }}
{{ collections[collection.metafields.test.test].value.title }}
{{ product.metafields.test.testmeta.value.metafields.test.first_name }}
<section>
<h2>Collection Only</h2>
<p>Product only gets a collection...</p>
<div>
<strong>PRODUCT PAGE REFERENCING AUTHOR</strong>
{{ product.metafields.godine.author_collection.value.title }} (LIQUID-ONLY)
{{ product.metafields.godine.author_collection.value.metafields.godine.title }} (LIQUID-ONLY)
{{ product.metafields.godine.author_collection.value.metafields.godine.first_name }} (LIQUID-ONLY)
</div>
Limitations: - Liquid-only on product page - Lots of collections...
</section>
<section>
<h2>Product and Metaobject both Reference Eachother</h2>
<div>
<strong>PRODUCT PAGE REFERENCING AUTHOR</strong>
{{ product.metafields.godine.author.value.first_name.value }} (WORKS IN TEXT)
OR
{{ collections[product.metafields.godine.author].metafields.godine.first_name }} (LIQUID-ONLY)
</div>
<div>
<strong>AUTHOR (METAOBJECT PAGE) REFERENCING PRODUCTS</strong>
{% for myprod in metaobject.products.value %}
{{ myprod.title }}
{% endfor %}
</div>
</section>
<section>
<h2>Collection and Metaobject</h2>
<p>Product gets an author metaobject *and* a collection...</p>
No apparent advantages!
</section>
<section>
<h2>Metaobject Only...</h2>
WORKS, but can't filter on array of products...
{% assign authors = shop.metaobjects.author.values | where: 'first_name', 'Charles' | where: 'last_name' includes 'Dickens' %}
{% for author in authors %}
{{ author.first_name.value }}
{{ author.last_name.value }}
{% endfor %}
WON'T WORK!
https://stackoverflow.com/questions/57748892/is-it-possible-to-use-a-liquid-where-array-filter-with-nested-properties
{% assign cat = collections.all.products
| map: 'metafields'
| map: 'test'
| map: 'testmeta'
| map: 'value'
| map: 'system'
| where: 'id', 53685026934
%}
{% for ca in cat %}
YO! {{ ca.handle }}
{% endfor %}
<hr>
{% assign cateogry_products = products | map: 'metafields.test.testmeta' %}
{% for cateogry_product of cateogry_products %}
Yo
{% endfor %}
{% for product in collections.all.products %}
YO
{% endfor %}
{% assign cat = collections.all.products | map: 'metafields' | map: 'test' | map: 'test' %}
{% assign cat = collections.all.products | map: 'metafields' | map: 'test' | where: 'text-collection', 'Bar' %}
</section>