@okendo/shopify-hydrogen 2.2.4 → 2.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +174 -225
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/types/components/OkendoReviews/OkendoReviews.d.ts +1 -1
- package/dist/cjs/types/internal/OkendoWidget/OkendoWidget.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/types/components/OkendoReviews/OkendoReviews.d.ts +1 -1
- package/dist/esm/types/internal/OkendoWidget/OkendoWidget.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -42,19 +42,16 @@ unauthenticated_read_product_tags
|
|
|
42
42
|
|
|
43
43
|
Follow the instructions on [this page](https://help.shopify.com/en/manual/apps/app-types/custom-apps#create-and-install-a-custom-app) to create it.
|
|
44
44
|
|
|
45
|
-
#### Note
|
|
46
|
-
|
|
47
|
-
Shopify is in the process of deprecating `metafieldStorefrontVisibilityCreate` in favour of `metafieldDefinitionCreate`. The following method uses `metafieldDefinitionCreate`. If you're having trouble with it, you will find below the deprecated method using `metafieldStorefrontVisibilityCreate`.
|
|
48
45
|
|
|
49
46
|
#### Using Curl
|
|
50
47
|
|
|
51
48
|
Open a new terminal or PowerShell window, then:
|
|
52
49
|
|
|
53
|
-
1. Run the following command to expose the `
|
|
50
|
+
1. Run the following command to expose the `widget_pre_render_style_tags` shop metafield:
|
|
54
51
|
|
|
55
52
|
```bash
|
|
56
53
|
curl -X POST \
|
|
57
|
-
https://{shop}.myshopify.com/admin/api/
|
|
54
|
+
https://{shop}.myshopify.com/admin/api/2024-10/graphql.json \
|
|
58
55
|
-H 'Content-Type: application/graphql' \
|
|
59
56
|
-H 'X-Shopify-Access-Token: {access_token}' \
|
|
60
57
|
-d '
|
|
@@ -62,11 +59,14 @@ mutation {
|
|
|
62
59
|
metafieldDefinitionCreate(
|
|
63
60
|
definition: {
|
|
64
61
|
name: "WidgetPreRenderStyleTags"
|
|
65
|
-
namespace: "
|
|
66
|
-
key: "
|
|
62
|
+
namespace: "$app:review"
|
|
63
|
+
key: "widget_pre_render_style_tags"
|
|
67
64
|
type: "multi_line_text_field"
|
|
68
65
|
ownerType: SHOP
|
|
69
|
-
|
|
66
|
+
access: {
|
|
67
|
+
admin: PUBLIC_READ
|
|
68
|
+
storefront: PUBLIC_READ
|
|
69
|
+
}
|
|
70
70
|
}
|
|
71
71
|
) {
|
|
72
72
|
createdDefinition { id name }
|
|
@@ -76,11 +76,11 @@ mutation {
|
|
|
76
76
|
'
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
2. Run the following command to expose the `
|
|
79
|
+
2. Run the following command to expose the `widget_pre_render_body_style_tags` shop metafield:
|
|
80
80
|
|
|
81
81
|
```bash
|
|
82
82
|
curl -X POST \
|
|
83
|
-
https://{shop}.myshopify.com/admin/api/
|
|
83
|
+
https://{shop}.myshopify.com/admin/api/2024-10/graphql.json \
|
|
84
84
|
-H 'Content-Type: application/graphql' \
|
|
85
85
|
-H 'X-Shopify-Access-Token: {access_token}' \
|
|
86
86
|
-d '
|
|
@@ -88,11 +88,14 @@ mutation {
|
|
|
88
88
|
metafieldDefinitionCreate(
|
|
89
89
|
definition: {
|
|
90
90
|
name: "WidgetPreRenderBodyStyleTags"
|
|
91
|
-
namespace: "
|
|
92
|
-
key: "
|
|
91
|
+
namespace: "$app:review"
|
|
92
|
+
key: "widget_pre_render_body_style_tags"
|
|
93
93
|
type: "multi_line_text_field"
|
|
94
94
|
ownerType: SHOP
|
|
95
|
-
|
|
95
|
+
access: {
|
|
96
|
+
admin: PUBLIC_READ
|
|
97
|
+
storefront: PUBLIC_READ
|
|
98
|
+
}
|
|
96
99
|
}
|
|
97
100
|
) {
|
|
98
101
|
createdDefinition { id name }
|
|
@@ -102,11 +105,11 @@ mutation {
|
|
|
102
105
|
'
|
|
103
106
|
```
|
|
104
107
|
|
|
105
|
-
3. Run the following command to expose the `
|
|
108
|
+
3. Run the following command to expose the `reviews_widget_snippet` product metafield:
|
|
106
109
|
|
|
107
110
|
```bash
|
|
108
111
|
curl -X POST \
|
|
109
|
-
https://{shop}.myshopify.com/admin/api/
|
|
112
|
+
https://{shop}.myshopify.com/admin/api/2024-10/graphql.json \
|
|
110
113
|
-H 'Content-Type: application/graphql' \
|
|
111
114
|
-H 'X-Shopify-Access-Token: {access_token}' \
|
|
112
115
|
-d '
|
|
@@ -114,11 +117,14 @@ mutation {
|
|
|
114
117
|
metafieldDefinitionCreate(
|
|
115
118
|
definition: {
|
|
116
119
|
name: "ReviewsWidgetSnippet"
|
|
117
|
-
namespace: "
|
|
118
|
-
key: "
|
|
120
|
+
namespace: "$app:reviews"
|
|
121
|
+
key: "reviews_widget_snippet"
|
|
119
122
|
type: "multi_line_text_field"
|
|
120
123
|
ownerType: PRODUCT
|
|
121
|
-
|
|
124
|
+
access: {
|
|
125
|
+
admin: PUBLIC_READ
|
|
126
|
+
storefront: PUBLIC_READ
|
|
127
|
+
}
|
|
122
128
|
}
|
|
123
129
|
) {
|
|
124
130
|
createdDefinition { id name }
|
|
@@ -128,11 +134,11 @@ mutation {
|
|
|
128
134
|
'
|
|
129
135
|
```
|
|
130
136
|
|
|
131
|
-
4. Run the following command to expose the `
|
|
137
|
+
4. Run the following command to expose the `star_rating_snippet` product metafield:
|
|
132
138
|
|
|
133
139
|
```bash
|
|
134
140
|
curl -X POST \
|
|
135
|
-
https://{shop}.myshopify.com/admin/api/
|
|
141
|
+
https://{shop}.myshopify.com/admin/api/2024-10/graphql.json \
|
|
136
142
|
-H 'Content-Type: application/graphql' \
|
|
137
143
|
-H 'X-Shopify-Access-Token: {access_token}' \
|
|
138
144
|
-d '
|
|
@@ -140,11 +146,72 @@ mutation {
|
|
|
140
146
|
metafieldDefinitionCreate(
|
|
141
147
|
definition: {
|
|
142
148
|
name: "StarRatingSnippet"
|
|
143
|
-
namespace: "
|
|
144
|
-
key: "
|
|
149
|
+
namespace: "$app:reviews"
|
|
150
|
+
key: "star_rating_snippet"
|
|
145
151
|
type: "multi_line_text_field"
|
|
146
152
|
ownerType: PRODUCT
|
|
147
|
-
|
|
153
|
+
access: {
|
|
154
|
+
admin: PUBLIC_READ
|
|
155
|
+
storefront: PUBLIC_READ
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
) {
|
|
159
|
+
createdDefinition { id name }
|
|
160
|
+
userErrors { field message code }
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
'
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
5. Run the following command to expose the `review_count` product metafield:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
curl -X POST \
|
|
170
|
+
https://{shop}.myshopify.com/admin/api/2024-10/graphql.json \
|
|
171
|
+
-H 'Content-Type: application/graphql' \
|
|
172
|
+
-H 'X-Shopify-Access-Token: {access_token}' \
|
|
173
|
+
-d '
|
|
174
|
+
mutation {
|
|
175
|
+
metafieldDefinitionCreate(
|
|
176
|
+
definition: {
|
|
177
|
+
name: "ReviewCount"
|
|
178
|
+
namespace: "$app:reviews"
|
|
179
|
+
key: "review_count"
|
|
180
|
+
type: "number_integer"
|
|
181
|
+
ownerType: PRODUCT
|
|
182
|
+
access: {
|
|
183
|
+
admin: PUBLIC_READ
|
|
184
|
+
storefront: PUBLIC_READ
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
) {
|
|
188
|
+
createdDefinition { id name }
|
|
189
|
+
userErrors { field message code }
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
'
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
6. Run the following command to expose the `average_rating` product metafield:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
curl -X POST \
|
|
199
|
+
https://{shop}.myshopify.com/admin/api/2024-10/graphql.json \
|
|
200
|
+
-H 'Content-Type: application/graphql' \
|
|
201
|
+
-H 'X-Shopify-Access-Token: {access_token}' \
|
|
202
|
+
-d '
|
|
203
|
+
mutation {
|
|
204
|
+
metafieldDefinitionCreate(
|
|
205
|
+
definition: {
|
|
206
|
+
name: "AverageRating"
|
|
207
|
+
namespace: "$app:reviews"
|
|
208
|
+
key: "average_rating"
|
|
209
|
+
type: "rating"
|
|
210
|
+
ownerType: PRODUCT
|
|
211
|
+
access: {
|
|
212
|
+
admin: PUBLIC_READ
|
|
213
|
+
storefront: PUBLIC_READ
|
|
214
|
+
}
|
|
148
215
|
}
|
|
149
216
|
) {
|
|
150
217
|
createdDefinition { id name }
|
|
@@ -158,21 +225,24 @@ mutation {
|
|
|
158
225
|
|
|
159
226
|
Open your GraphQL IDE (such as Postman) and make `POST` requests with the following details:
|
|
160
227
|
|
|
161
|
-
- **URL:** https://{shop}.myshopify.com/admin/api/
|
|
228
|
+
- **URL:** https://{shop}.myshopify.com/admin/api/2024-10/graphql.json
|
|
162
229
|
- **Headers:** - X-Shopify-Access-Token: {access_token} - Content-Type: application/json
|
|
163
230
|
|
|
164
|
-
1. Execute the following request to expose the `
|
|
231
|
+
1. Execute the following request to expose the `widget_pre_render_style_tags` shop metafield:
|
|
165
232
|
|
|
166
233
|
```graphql
|
|
167
234
|
mutation {
|
|
168
235
|
metafieldDefinitionCreate(
|
|
169
236
|
definition: {
|
|
170
237
|
name: "WidgetPreRenderStyleTags"
|
|
171
|
-
namespace: "
|
|
172
|
-
key: "
|
|
238
|
+
namespace: "$app:reviews"
|
|
239
|
+
key: "widget_pre_render_style_tags"
|
|
173
240
|
type: "multi_line_text_field"
|
|
174
241
|
ownerType: SHOP
|
|
175
|
-
|
|
242
|
+
access: {
|
|
243
|
+
admin: PUBLIC_READ
|
|
244
|
+
storefront: PUBLIC_READ
|
|
245
|
+
}
|
|
176
246
|
}
|
|
177
247
|
) {
|
|
178
248
|
createdDefinition {
|
|
@@ -188,18 +258,21 @@ mutation {
|
|
|
188
258
|
}
|
|
189
259
|
```
|
|
190
260
|
|
|
191
|
-
2. Execute the following request to expose the `
|
|
261
|
+
2. Execute the following request to expose the `widget_pre_render_body_style_tags` shop metafield:
|
|
192
262
|
|
|
193
263
|
```graphql
|
|
194
264
|
mutation {
|
|
195
265
|
metafieldDefinitionCreate(
|
|
196
266
|
definition: {
|
|
197
267
|
name: "WidgetPreRenderBodyStyleTags"
|
|
198
|
-
namespace: "
|
|
199
|
-
key: "
|
|
268
|
+
namespace: "$app:reviews"
|
|
269
|
+
key: "widget_pre_render_body_style_tags"
|
|
200
270
|
type: "multi_line_text_field"
|
|
201
271
|
ownerType: SHOP
|
|
202
|
-
|
|
272
|
+
access: {
|
|
273
|
+
admin: PUBLIC_READ
|
|
274
|
+
storefront: PUBLIC_READ
|
|
275
|
+
}
|
|
203
276
|
}
|
|
204
277
|
) {
|
|
205
278
|
createdDefinition {
|
|
@@ -215,18 +288,21 @@ mutation {
|
|
|
215
288
|
}
|
|
216
289
|
```
|
|
217
290
|
|
|
218
|
-
3. Execute the following request to expose the `
|
|
291
|
+
3. Execute the following request to expose the `reviews_widget_snippet` product metafield:
|
|
219
292
|
|
|
220
293
|
```graphql
|
|
221
294
|
mutation {
|
|
222
295
|
metafieldDefinitionCreate(
|
|
223
296
|
definition: {
|
|
224
297
|
name: "ReviewsWidgetSnippet"
|
|
225
|
-
namespace: "
|
|
226
|
-
key: "
|
|
298
|
+
namespace: "$app:reviews"
|
|
299
|
+
key: "reviews_widget_snippet"
|
|
227
300
|
type: "multi_line_text_field"
|
|
228
301
|
ownerType: PRODUCT
|
|
229
|
-
|
|
302
|
+
access: {
|
|
303
|
+
admin: PUBLIC_READ
|
|
304
|
+
storefront: PUBLIC_READ
|
|
305
|
+
}
|
|
230
306
|
}
|
|
231
307
|
) {
|
|
232
308
|
createdDefinition {
|
|
@@ -242,18 +318,21 @@ mutation {
|
|
|
242
318
|
}
|
|
243
319
|
```
|
|
244
320
|
|
|
245
|
-
4. Execute the following request to expose the `
|
|
321
|
+
4. Execute the following request to expose the `star_rating_snippet` product metafield:
|
|
246
322
|
|
|
247
323
|
```graphql
|
|
248
324
|
mutation {
|
|
249
325
|
metafieldDefinitionCreate(
|
|
250
326
|
definition: {
|
|
251
327
|
name: "StarRatingSnippet"
|
|
252
|
-
namespace: "
|
|
253
|
-
key: "
|
|
328
|
+
namespace: "$app:reviews"
|
|
329
|
+
key: "star_rating_snippet"
|
|
254
330
|
type: "multi_line_text_field"
|
|
255
331
|
ownerType: PRODUCT
|
|
256
|
-
|
|
332
|
+
access: {
|
|
333
|
+
admin: PUBLIC_READ
|
|
334
|
+
storefront: PUBLIC_READ
|
|
335
|
+
}
|
|
257
336
|
}
|
|
258
337
|
) {
|
|
259
338
|
createdDefinition {
|
|
@@ -269,223 +348,70 @@ mutation {
|
|
|
269
348
|
}
|
|
270
349
|
```
|
|
271
350
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
- [https://shopify.dev/api/examples/metafields#step-1-expose-metafields](https://shopify.dev/api/examples/metafields#step-1-expose-metafields)
|
|
275
|
-
- [https://shopify.dev/api/admin-graphql/2023-07/mutations/metafieldDefinitionCreate](https://shopify.dev/api/admin-graphql/2023-07/mutations/metafieldDefinitionCreate)
|
|
276
|
-
|
|
277
|
-
<details>
|
|
278
|
-
|
|
279
|
-
<summary>If you're having trouble with `metafieldDefinitionCreate`, click here to see the deprecated method, using `metafieldStorefrontVisibilityCreate`.</summary>
|
|
280
|
-
|
|
281
|
-
#### Using Curl
|
|
282
|
-
|
|
283
|
-
Open a new terminal or PowerShell window, then:
|
|
284
|
-
|
|
285
|
-
1. Run the following command to expose the `WidgetPreRenderStyleTags` shop metafield:
|
|
286
|
-
|
|
287
|
-
```bash
|
|
288
|
-
curl -X POST \
|
|
289
|
-
https://{shop}.myshopify.com/admin/api/2023-07/graphql.json \
|
|
290
|
-
-H 'Content-Type: application/graphql' \
|
|
291
|
-
-H 'X-Shopify-Access-Token: {access_token}' \
|
|
292
|
-
-d '
|
|
293
|
-
mutation {
|
|
294
|
-
metafieldStorefrontVisibilityCreate(
|
|
295
|
-
input: {
|
|
296
|
-
namespace: "okendo"
|
|
297
|
-
key: "WidgetPreRenderStyleTags"
|
|
298
|
-
ownerType: SHOP
|
|
299
|
-
}
|
|
300
|
-
) {
|
|
301
|
-
metafieldStorefrontVisibility {
|
|
302
|
-
id
|
|
303
|
-
}
|
|
304
|
-
userErrors {
|
|
305
|
-
field
|
|
306
|
-
message
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
'
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
2. Run the following command to expose the `WidgetPreRenderBodyStyleTags` shop metafield:
|
|
314
|
-
|
|
315
|
-
```bash
|
|
316
|
-
curl -X POST \
|
|
317
|
-
https://{shop}.myshopify.com/admin/api/2023-07/graphql.json \
|
|
318
|
-
-H 'Content-Type: application/graphql' \
|
|
319
|
-
-H 'X-Shopify-Access-Token: {access_token}' \
|
|
320
|
-
-d '
|
|
321
|
-
mutation {
|
|
322
|
-
metafieldStorefrontVisibilityCreate(
|
|
323
|
-
input: {
|
|
324
|
-
namespace: "okendo"
|
|
325
|
-
key: "WidgetPreRenderBodyStyleTags"
|
|
326
|
-
ownerType: SHOP
|
|
327
|
-
}
|
|
328
|
-
) {
|
|
329
|
-
metafieldStorefrontVisibility {
|
|
330
|
-
id
|
|
331
|
-
}
|
|
332
|
-
userErrors {
|
|
333
|
-
field
|
|
334
|
-
message
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
'
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
3. Run the following command to expose the `ReviewsWidgetSnippet` product metafield:
|
|
342
|
-
|
|
343
|
-
```bash
|
|
344
|
-
curl -X POST \
|
|
345
|
-
https://{shop}.myshopify.com/admin/api/2023-07/graphql.json \
|
|
346
|
-
-H 'Content-Type: application/graphql' \
|
|
347
|
-
-H 'X-Shopify-Access-Token: {access_token}' \
|
|
348
|
-
-d '
|
|
349
|
-
mutation {
|
|
350
|
-
metafieldStorefrontVisibilityCreate(
|
|
351
|
-
input: {
|
|
352
|
-
namespace: "okendo"
|
|
353
|
-
key: "ReviewsWidgetSnippet"
|
|
354
|
-
ownerType: PRODUCT
|
|
355
|
-
}
|
|
356
|
-
) {
|
|
357
|
-
metafieldStorefrontVisibility {
|
|
358
|
-
id
|
|
359
|
-
}
|
|
360
|
-
userErrors {
|
|
361
|
-
field
|
|
362
|
-
message
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
'
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
4. Run the following command to expose the `StarRatingSnippet` the product metafield:
|
|
370
|
-
|
|
371
|
-
```bash
|
|
372
|
-
curl -X POST \
|
|
373
|
-
https://{shop}.myshopify.com/admin/api/2023-07/graphql.json \
|
|
374
|
-
-H 'Content-Type: application/graphql' \
|
|
375
|
-
-H 'X-Shopify-Access-Token: {access_token}' \
|
|
376
|
-
-d '
|
|
377
|
-
mutation {
|
|
378
|
-
metafieldStorefrontVisibilityCreate(
|
|
379
|
-
input: {
|
|
380
|
-
namespace: "okendo"
|
|
381
|
-
key: "StarRatingSnippet"
|
|
382
|
-
ownerType: PRODUCT
|
|
383
|
-
}
|
|
384
|
-
) {
|
|
385
|
-
metafieldStorefrontVisibility {
|
|
386
|
-
id
|
|
387
|
-
}
|
|
388
|
-
userErrors {
|
|
389
|
-
field
|
|
390
|
-
message
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
'
|
|
395
|
-
```
|
|
396
|
-
|
|
397
|
-
### Using GraphQL IDE
|
|
398
|
-
|
|
399
|
-
Open your GraphQL IDE (such as Postman) and make `POST` requests with the following details:
|
|
400
|
-
|
|
401
|
-
- **URL:** https://{shop}.myshopify.com/admin/api/2023-07/graphql.json
|
|
402
|
-
- **Headers:** - X-Shopify-Access-Token: {access_token} - Content-Type: application/json
|
|
403
|
-
|
|
404
|
-
1. Execute the following request to expose the `WidgetPreRenderStyleTags` shop metafield:
|
|
351
|
+
5. Execute the following request to expose the `review_count` product metafield:
|
|
405
352
|
|
|
406
353
|
```graphql
|
|
407
354
|
mutation {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
field
|
|
420
|
-
message
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
2. Execute the following request to expose the `WidgetPreRenderBodyStyleTags` shop metafield:
|
|
427
|
-
|
|
428
|
-
```graphql
|
|
429
|
-
mutation {
|
|
430
|
-
metafieldStorefrontVisibilityCreate(
|
|
431
|
-
input: {
|
|
432
|
-
namespace: "okendo"
|
|
433
|
-
key: "WidgetPreRenderBodyStyleTags"
|
|
434
|
-
ownerType: SHOP
|
|
355
|
+
metafieldDefinitionCreate(
|
|
356
|
+
definition: {
|
|
357
|
+
name: "ReviewCount"
|
|
358
|
+
namespace: "$app:reviews"
|
|
359
|
+
key: "review_count"
|
|
360
|
+
type: "number_integer"
|
|
361
|
+
ownerType: PRODUCT
|
|
362
|
+
access: {
|
|
363
|
+
admin: PUBLIC_READ
|
|
364
|
+
storefront: PUBLIC_READ
|
|
365
|
+
}
|
|
435
366
|
}
|
|
436
367
|
) {
|
|
437
|
-
|
|
368
|
+
createdDefinition {
|
|
438
369
|
id
|
|
370
|
+
name
|
|
439
371
|
}
|
|
440
372
|
userErrors {
|
|
441
373
|
field
|
|
442
374
|
message
|
|
375
|
+
code
|
|
443
376
|
}
|
|
444
377
|
}
|
|
445
378
|
}
|
|
446
379
|
```
|
|
447
380
|
|
|
448
|
-
|
|
381
|
+
6. Execute the following request to expose the `average_rating` product metafield:
|
|
449
382
|
|
|
450
383
|
```graphql
|
|
451
384
|
mutation {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
385
|
+
metafieldDefinitionCreate(
|
|
386
|
+
definition: {
|
|
387
|
+
name: "AverageRating"
|
|
388
|
+
namespace: "$app:reviews"
|
|
389
|
+
key: "average_rating"
|
|
390
|
+
type: "rating"
|
|
456
391
|
ownerType: PRODUCT
|
|
392
|
+
access: {
|
|
393
|
+
admin: PUBLIC_READ
|
|
394
|
+
storefront: PUBLIC_READ
|
|
395
|
+
}
|
|
457
396
|
}
|
|
458
397
|
) {
|
|
459
|
-
|
|
398
|
+
createdDefinition {
|
|
460
399
|
id
|
|
400
|
+
name
|
|
461
401
|
}
|
|
462
402
|
userErrors {
|
|
463
403
|
field
|
|
464
404
|
message
|
|
405
|
+
code
|
|
465
406
|
}
|
|
466
407
|
}
|
|
467
408
|
}
|
|
468
409
|
```
|
|
469
410
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
```graphql
|
|
473
|
-
mutation {
|
|
474
|
-
metafieldStorefrontVisibilityCreate(
|
|
475
|
-
input: { namespace: "okendo", key: "StarRatingSnippet", ownerType: PRODUCT }
|
|
476
|
-
) {
|
|
477
|
-
metafieldStorefrontVisibility {
|
|
478
|
-
id
|
|
479
|
-
}
|
|
480
|
-
userErrors {
|
|
481
|
-
field
|
|
482
|
-
message
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
```
|
|
411
|
+
**References**
|
|
487
412
|
|
|
488
|
-
|
|
413
|
+
- [https://shopify.dev/api/examples/metafields#step-1-expose-metafields](https://shopify.dev/api/examples/metafields#step-1-expose-metafields)
|
|
414
|
+
- [https://shopify.dev/docs/api/admin-graphql/2024-10/mutations/metafieldDefinitionCreate](https://shopify.dev/docs/api/admin-graphql/2024-10/mutations/metafieldDefinitionCreate)
|
|
489
415
|
|
|
490
416
|
</details>
|
|
491
417
|
|
|
@@ -920,3 +846,26 @@ For instance, we can add it below the product title, like this:
|
|
|
920
846
|
We now have the Okendo Star Rating and Reviews widgets visible on our product page:
|
|
921
847
|
|
|
922
848
|

|
|
849
|
+
|
|
850
|
+
### All Reviews Widget - Client Side Only
|
|
851
|
+
If you would like to include a copy of the Okendo Reviews Widget which displays all reviews for a given store (to be used on a reviews page for example), please add the OkendoReviewsWidget without supplying the `productId`.
|
|
852
|
+
|
|
853
|
+
Please note the all reviews widget loads on the client not the server.
|
|
854
|
+
|
|
855
|
+
```tsx
|
|
856
|
+
import { type MetaFunction } from '@remix-run/react';
|
|
857
|
+
import { OkendoReviews } from '@okendo/shopify-hydrogen';
|
|
858
|
+
|
|
859
|
+
export const meta: MetaFunction = () => {
|
|
860
|
+
return [{title: `Hydrogen | Okendo All Reviews`}];
|
|
861
|
+
};
|
|
862
|
+
|
|
863
|
+
export default function ReviewsPage() {
|
|
864
|
+
return (
|
|
865
|
+
<div className="all-reviews">
|
|
866
|
+
<h1>All Reviews Widget</h1>
|
|
867
|
+
<OkendoReviews />
|
|
868
|
+
</div>
|
|
869
|
+
);
|
|
870
|
+
}
|
|
871
|
+
```
|
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react"),t=require("@remix-run/react");const n=e.createContext(void 0),r=({children:t})=>{const[r,o]=e.useState(!1);return e.createElement(n.Provider,{value:{okendoDataLoaded:r,setOkendoDataLoaded:o}},t)},o=()=>{const t=e.useContext(n);return void 0===t?null:t},a="cdn-static.okendo.io",i=({nonce:t="",okendoProviderData:n,productUrlFormatter:r,awaited:i,cdnDomain:s})=>{const d=o(),c=e.useRef(!1);if(e.useEffect((()=>{if(n&&d?.setOkendoDataLoaded(!0),n&&i&&!c.current){const e=document.createElement("script");e.src=`https://${s||a}/reviews-widget-plus/js/okendo-reviews.js`,document.head.appendChild(e),c.current=!0}}),[n,d,i,s]),!n)return null;const{reviewsHeaderConfig:l,cssVariables:u,customCss:p,initScriptContents:m,preRenderStyleTags:g,starSymbols:v}=n,k=(u??"").replace('<style id="oke-css-vars">',"").replace("</style>",""),w=p?p.replace('<style id="oke-reviews-custom-css">',"").replace("</style>",""):"";return e.createElement(e.Fragment,null,e.createElement("script",{nonce:t,id:"oke-reviews-settings",type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify(l)}}),e.createElement("style",{nonce:t,id:"oke-css-vars",dangerouslySetInnerHTML:{__html:k}}),w&&e.createElement("style",{nonce:t,id:"oke-reviews-custom-css",dangerouslySetInnerHTML:{__html:w}}),!i&&m&&e.createElement("script",{nonce:t,dangerouslySetInnerHTML:{__html:m}}),e.createElement("script",{nonce:t,type:"text/javascript",dangerouslySetInnerHTML:{__html:`window.okeProductUrlFormatter = ${"function"==typeof r?r.toString():"string"==typeof r?r:"(product) =>\n product && product.productHandle\n ? \"/products/\" + product.productHandle + \"/\" + (product.variantId ? '?variantId=' + product.variantId : '')\n : undefined"}`}}),g&&e.createElement("div",{dangerouslySetInnerHTML:{__html:g}}),v&&e.createElement("div",{dangerouslySetInnerHTML:{__html:v}}))};const s=({dataAttributes:t,metafieldContent:n=""})=>{const r=e.useRef(null),o=e.useRef(!1),a=function(t){const n=e.useRef();return e.useEffect((()=>{n.current=t})),n.current}(t),i=()=>{r.current&&(window.okeWidgetApi.initWidget(r.current),o.current=!0)};return e.useEffect((()=>{if(!a||t["data-oke-widget"]!==a["data-oke-widget"]||t["data-oke-star-rating"]!==a["data-oke-star-rating"]||t["data-oke-reviews-product-id"]!==a["data-oke-reviews-product-id"]||!o.current)return window.okeWidgetApi&&r.current?i():document.addEventListener("oke-script-loaded",i),()=>{document.removeEventListener("oke-script-loaded",i)}}),[t,a]),e.createElement("div",{ref:r,key:JSON.stringify(t),...t,dangerouslySetInnerHTML:n?{__html:n}:void 0})},d=/^[0-9]*$/;function c(e){if(e)return`shopify-${d.test(e)?e:e.split("/").slice(-1)[0]}`}exports.OKENDO_PRODUCT_REVIEWS_FRAGMENT='#graphql\n\tfragment OkendoReviewsSnippet on Product {\n\t\tokendoReviewsSnippet: metafield(\n\t\t\tnamespace: "okendo"\n\t\t\tkey: "ReviewsWidgetSnippet"\n\t\t) {\n\t\t\tvalue\n\t\t}\n\t}\n',exports.OKENDO_PRODUCT_STAR_RATING_FRAGMENT='#graphql\n\tfragment OkendoStarRatingSnippet on Product {\n\t\tokendoStarRatingSnippet: metafield(\n\t\t\tnamespace: "okendo"\n\t\t\tkey: "StarRatingSnippet"\n\t\t) {\n\t\t\tvalue\n\t\t}\n\t}\n',exports.OkendoProvider=({nonce:n="",okendoProviderData:o,productUrlFormatter:a,cdnDomain:s,children:d})=>e.createElement(r,null,o&&"then"in o?e.createElement(e.Suspense,null,e.createElement(t.Await,{resolve:o},(t=>e.createElement(i,{nonce:n,okendoProviderData:t,productUrlFormatter:a,cdnDomain:s,awaited:!0})))):e.createElement(i,{nonce:n,okendoProviderData:o,productUrlFormatter:a,cdnDomain:s}),d),exports.OkendoReviews=({productId:t,okendoReviewsSnippet:n,placeholder:r})=>{const a=o(),i={"data-oke-widget":"","data-oke-reviews-product-id":
|
|
1
|
+
"use strict";var e=require("react"),t=require("@remix-run/react");const n=e.createContext(void 0),r=({children:t})=>{const[r,o]=e.useState(!1);return e.createElement(n.Provider,{value:{okendoDataLoaded:r,setOkendoDataLoaded:o}},t)},o=()=>{const t=e.useContext(n);return void 0===t?null:t},a="cdn-static.okendo.io",i=({nonce:t="",okendoProviderData:n,productUrlFormatter:r,awaited:i,cdnDomain:s})=>{const d=o(),c=e.useRef(!1);if(e.useEffect((()=>{if(n&&d?.setOkendoDataLoaded(!0),n&&i&&!c.current){const e=document.createElement("script");e.src=`https://${s||a}/reviews-widget-plus/js/okendo-reviews.js`,document.head.appendChild(e),c.current=!0}}),[n,d,i,s]),!n)return null;const{reviewsHeaderConfig:l,cssVariables:u,customCss:p,initScriptContents:m,preRenderStyleTags:g,starSymbols:v}=n,k=(u??"").replace('<style id="oke-css-vars">',"").replace("</style>",""),w=p?p.replace('<style id="oke-reviews-custom-css">',"").replace("</style>",""):"";return e.createElement(e.Fragment,null,e.createElement("script",{nonce:t,id:"oke-reviews-settings",type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify(l)}}),e.createElement("style",{nonce:t,id:"oke-css-vars",dangerouslySetInnerHTML:{__html:k}}),w&&e.createElement("style",{nonce:t,id:"oke-reviews-custom-css",dangerouslySetInnerHTML:{__html:w}}),!i&&m&&e.createElement("script",{nonce:t,dangerouslySetInnerHTML:{__html:m}}),e.createElement("script",{nonce:t,type:"text/javascript",dangerouslySetInnerHTML:{__html:`window.okeProductUrlFormatter = ${"function"==typeof r?r.toString():"string"==typeof r?r:"(product) =>\n product && product.productHandle\n ? \"/products/\" + product.productHandle + \"/\" + (product.variantId ? '?variantId=' + product.variantId : '')\n : undefined"}`}}),g&&e.createElement("div",{dangerouslySetInnerHTML:{__html:g}}),v&&e.createElement("div",{dangerouslySetInnerHTML:{__html:v}}))};const s=({dataAttributes:t,metafieldContent:n=""})=>{const r=e.useRef(null),o=e.useRef(!1),a=function(t){const n=e.useRef();return e.useEffect((()=>{n.current=t})),n.current}(t),i=()=>{r.current&&(window.okeWidgetApi.initWidget(r.current),o.current=!0)};return e.useEffect((()=>{if(!a||t["data-oke-widget"]!==a["data-oke-widget"]||t["data-oke-star-rating"]!==a["data-oke-star-rating"]||t["data-oke-reviews-product-id"]!==a["data-oke-reviews-product-id"]||!o.current)return window.okeWidgetApi&&r.current?i():document.addEventListener("oke-script-loaded",i),()=>{document.removeEventListener("oke-script-loaded",i)}}),[t,a]),e.createElement("div",{ref:r,key:JSON.stringify(t),...t,dangerouslySetInnerHTML:n?{__html:n}:void 0})},d=/^[0-9]*$/;function c(e){if(e)return`shopify-${d.test(e)?e:e.split("/").slice(-1)[0]}`}exports.OKENDO_PRODUCT_REVIEWS_FRAGMENT='#graphql\n\tfragment OkendoReviewsSnippet on Product {\n\t\tokendoReviewsSnippet: metafield(\n\t\t\tnamespace: "okendo"\n\t\t\tkey: "ReviewsWidgetSnippet"\n\t\t) {\n\t\t\tvalue\n\t\t}\n\t}\n',exports.OKENDO_PRODUCT_STAR_RATING_FRAGMENT='#graphql\n\tfragment OkendoStarRatingSnippet on Product {\n\t\tokendoStarRatingSnippet: metafield(\n\t\t\tnamespace: "okendo"\n\t\t\tkey: "StarRatingSnippet"\n\t\t) {\n\t\t\tvalue\n\t\t}\n\t}\n',exports.OkendoProvider=({nonce:n="",okendoProviderData:o,productUrlFormatter:a,cdnDomain:s,children:d})=>e.createElement(r,null,o&&"then"in o?e.createElement(e.Suspense,null,e.createElement(t.Await,{resolve:o},(t=>e.createElement(i,{nonce:n,okendoProviderData:t,productUrlFormatter:a,cdnDomain:s,awaited:!0})))):e.createElement(i,{nonce:n,okendoProviderData:o,productUrlFormatter:a,cdnDomain:s}),d),exports.OkendoReviews=({productId:t,okendoReviewsSnippet:n,placeholder:r})=>{const a=o(),i=t?.length?c(t):null,d=t?.length?n:null,l={"data-oke-widget":"","data-oke-reviews-product-id":i};return null===a||a.okendoDataLoaded?e.createElement(s,{dataAttributes:l,metafieldContent:d?.value}):r||e.createElement("div",{style:{height:"350px"}})},exports.OkendoStarRating=({productId:t,okendoStarRatingSnippet:n,placeholder:r})=>{const a=o(),i={"data-oke-star-rating":"","data-oke-reviews-product-id":c(t)};return null===a||a.okendoDataLoaded?e.createElement(s,{dataAttributes:i,metafieldContent:n?.value}):r||e.createElement("div",{style:{height:"20px"}})},exports.getOkendoProviderData=async({context:e,subscriberId:t,apiDomain:n,cdnDomain:r})=>{const o=`https://${n||"api.okendo.io/v1"}/stores/${t}/widget_plus_settings`,i=await fetch(o);if(!i.ok)return console.error(`Failed to retrieve subscriber settings for subscriber ID '${t}'.`),null;const{reviewsHeaderConfig:s,cssVariables:d,customCss:c,starSymbols:l}=await i.json(),u=await fetch(`https://${r||a}/reviews-widget-plus/js/okendo-reviews.js`);if(!u.ok)return console.error("Failed to retrieve widget initialisation script."),null;const p=await u.text(),{shop:{widgetPreRenderStyleTags:m}}=await e.storefront.query('#graphql\n\t\tquery metafields {\n\t\t\tshop {\n\t\t\t\twidgetPreRenderStyleTags: metafield(\n\t\t\t\t\tnamespace: "okendo"\n\t\t\t\t\tkey: "WidgetPreRenderStyleTags"\n\t\t\t\t) {\n\t\t\t\t\tvalue\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t'),g=m?.value??"";return g||console.warn("Failed to retrieve pre-rendered widget style settings."),{reviewsHeaderConfig:s,cssVariables:d,customCss:c,initScriptContents:p,preRenderStyleTags:g,starSymbols:l}};
|
|
@@ -4,7 +4,7 @@ export interface WithOkendoReviewsSnippet {
|
|
|
4
4
|
okendoReviewsSnippet?: MetafieldValue | null;
|
|
5
5
|
}
|
|
6
6
|
interface OkendoReviewsProps {
|
|
7
|
-
productId
|
|
7
|
+
productId?: string;
|
|
8
8
|
okendoReviewsSnippet?: MetafieldValue | null;
|
|
9
9
|
/**
|
|
10
10
|
* Only used if the promise returned by `getOkendoProviderData` is given to the OkendoProvider
|
|
@@ -4,7 +4,7 @@ export interface OkendoWidgetProps {
|
|
|
4
4
|
dataAttributes: {
|
|
5
5
|
'data-oke-widget'?: string;
|
|
6
6
|
'data-oke-star-rating'?: string;
|
|
7
|
-
'data-oke-reviews-product-id': string | undefined;
|
|
7
|
+
'data-oke-reviews-product-id': string | null | undefined;
|
|
8
8
|
};
|
|
9
9
|
metafieldContent?: string;
|
|
10
10
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e,{createContext as t,useState as n,useContext as r,Suspense as o,useRef as a,useEffect as i}from"react";import{Await as d}from"@remix-run/react";const s=t(void 0),c=({children:t})=>{const[r,o]=n(!1);return e.createElement(s.Provider,{value:{okendoDataLoaded:r,setOkendoDataLoaded:o}},t)},l=()=>{const e=r(s);return void 0===e?null:e},u="cdn-static.okendo.io",p=async({context:e,subscriberId:t,apiDomain:n,cdnDomain:r})=>{const o=`https://${n||"api.okendo.io/v1"}/stores/${t}/widget_plus_settings`,a=await fetch(o);if(!a.ok)return console.error(`Failed to retrieve subscriber settings for subscriber ID '${t}'.`),null;const{reviewsHeaderConfig:i,cssVariables:d,customCss:s,starSymbols:c}=await a.json(),l=await fetch(`https://${r||u}/reviews-widget-plus/js/okendo-reviews.js`);if(!l.ok)return console.error("Failed to retrieve widget initialisation script."),null;const p=await l.text(),{shop:{widgetPreRenderStyleTags:m}}=await e.storefront.query('#graphql\n\t\tquery metafields {\n\t\t\tshop {\n\t\t\t\twidgetPreRenderStyleTags: metafield(\n\t\t\t\t\tnamespace: "okendo"\n\t\t\t\t\tkey: "WidgetPreRenderStyleTags"\n\t\t\t\t) {\n\t\t\t\t\tvalue\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t'),g=m?.value??"";return g||console.warn("Failed to retrieve pre-rendered widget style settings."),{reviewsHeaderConfig:i,cssVariables:d,customCss:s,initScriptContents:p,preRenderStyleTags:g,starSymbols:c}},m=({nonce:t="",okendoProviderData:n,productUrlFormatter:r,cdnDomain:a,children:i})=>e.createElement(c,null,n&&"then"in n?e.createElement(o,null,e.createElement(d,{resolve:n},(n=>e.createElement(g,{nonce:t,okendoProviderData:n,productUrlFormatter:r,cdnDomain:a,awaited:!0})))):e.createElement(g,{nonce:t,okendoProviderData:n,productUrlFormatter:r,cdnDomain:a}),i),g=({nonce:t="",okendoProviderData:n,productUrlFormatter:r,awaited:o,cdnDomain:d})=>{const s=l(),c=a(!1);if(i((()=>{if(n&&s?.setOkendoDataLoaded(!0),n&&o&&!c.current){const e=document.createElement("script");e.src=`https://${d||u}/reviews-widget-plus/js/okendo-reviews.js`,document.head.appendChild(e),c.current=!0}}),[n,s,o,d]),!n)return null;const{reviewsHeaderConfig:p,cssVariables:m,customCss:g,initScriptContents:v,preRenderStyleTags:k,starSymbols:w}=n,y=(m??"").replace('<style id="oke-css-vars">',"").replace("</style>",""),f=g?g.replace('<style id="oke-reviews-custom-css">',"").replace("</style>",""):"";return e.createElement(e.Fragment,null,e.createElement("script",{nonce:t,id:"oke-reviews-settings",type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify(p)}}),e.createElement("style",{nonce:t,id:"oke-css-vars",dangerouslySetInnerHTML:{__html:y}}),f&&e.createElement("style",{nonce:t,id:"oke-reviews-custom-css",dangerouslySetInnerHTML:{__html:f}}),!o&&v&&e.createElement("script",{nonce:t,dangerouslySetInnerHTML:{__html:v}}),e.createElement("script",{nonce:t,type:"text/javascript",dangerouslySetInnerHTML:{__html:`window.okeProductUrlFormatter = ${"function"==typeof r?r.toString():"string"==typeof r?r:"(product) =>\n product && product.productHandle\n ? \"/products/\" + product.productHandle + \"/\" + (product.variantId ? '?variantId=' + product.variantId : '')\n : undefined"}`}}),k&&e.createElement("div",{dangerouslySetInnerHTML:{__html:k}}),w&&e.createElement("div",{dangerouslySetInnerHTML:{__html:w}}))};const v=({dataAttributes:t,metafieldContent:n=""})=>{const r=a(null),o=a(!1),d=function(e){const t=a();return i((()=>{t.current=e})),t.current}(t),s=()=>{r.current&&(window.okeWidgetApi.initWidget(r.current),o.current=!0)};return i((()=>{if(!d||t["data-oke-widget"]!==d["data-oke-widget"]||t["data-oke-star-rating"]!==d["data-oke-star-rating"]||t["data-oke-reviews-product-id"]!==d["data-oke-reviews-product-id"]||!o.current)return window.okeWidgetApi&&r.current?s():document.addEventListener("oke-script-loaded",s),()=>{document.removeEventListener("oke-script-loaded",s)}}),[t,d]),e.createElement("div",{ref:r,key:JSON.stringify(t),...t,dangerouslySetInnerHTML:n?{__html:n}:void 0})},k=/^[0-9]*$/;function w(e){if(e)return`shopify-${k.test(e)?e:e.split("/").slice(-1)[0]}`}const y=({productId:t,okendoReviewsSnippet:n,placeholder:r})=>{const o=l(),a={"data-oke-widget":"","data-oke-reviews-product-id":
|
|
1
|
+
import e,{createContext as t,useState as n,useContext as r,Suspense as o,useRef as a,useEffect as i}from"react";import{Await as d}from"@remix-run/react";const s=t(void 0),c=({children:t})=>{const[r,o]=n(!1);return e.createElement(s.Provider,{value:{okendoDataLoaded:r,setOkendoDataLoaded:o}},t)},l=()=>{const e=r(s);return void 0===e?null:e},u="cdn-static.okendo.io",p=async({context:e,subscriberId:t,apiDomain:n,cdnDomain:r})=>{const o=`https://${n||"api.okendo.io/v1"}/stores/${t}/widget_plus_settings`,a=await fetch(o);if(!a.ok)return console.error(`Failed to retrieve subscriber settings for subscriber ID '${t}'.`),null;const{reviewsHeaderConfig:i,cssVariables:d,customCss:s,starSymbols:c}=await a.json(),l=await fetch(`https://${r||u}/reviews-widget-plus/js/okendo-reviews.js`);if(!l.ok)return console.error("Failed to retrieve widget initialisation script."),null;const p=await l.text(),{shop:{widgetPreRenderStyleTags:m}}=await e.storefront.query('#graphql\n\t\tquery metafields {\n\t\t\tshop {\n\t\t\t\twidgetPreRenderStyleTags: metafield(\n\t\t\t\t\tnamespace: "okendo"\n\t\t\t\t\tkey: "WidgetPreRenderStyleTags"\n\t\t\t\t) {\n\t\t\t\t\tvalue\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t'),g=m?.value??"";return g||console.warn("Failed to retrieve pre-rendered widget style settings."),{reviewsHeaderConfig:i,cssVariables:d,customCss:s,initScriptContents:p,preRenderStyleTags:g,starSymbols:c}},m=({nonce:t="",okendoProviderData:n,productUrlFormatter:r,cdnDomain:a,children:i})=>e.createElement(c,null,n&&"then"in n?e.createElement(o,null,e.createElement(d,{resolve:n},(n=>e.createElement(g,{nonce:t,okendoProviderData:n,productUrlFormatter:r,cdnDomain:a,awaited:!0})))):e.createElement(g,{nonce:t,okendoProviderData:n,productUrlFormatter:r,cdnDomain:a}),i),g=({nonce:t="",okendoProviderData:n,productUrlFormatter:r,awaited:o,cdnDomain:d})=>{const s=l(),c=a(!1);if(i((()=>{if(n&&s?.setOkendoDataLoaded(!0),n&&o&&!c.current){const e=document.createElement("script");e.src=`https://${d||u}/reviews-widget-plus/js/okendo-reviews.js`,document.head.appendChild(e),c.current=!0}}),[n,s,o,d]),!n)return null;const{reviewsHeaderConfig:p,cssVariables:m,customCss:g,initScriptContents:v,preRenderStyleTags:k,starSymbols:w}=n,y=(m??"").replace('<style id="oke-css-vars">',"").replace("</style>",""),f=g?g.replace('<style id="oke-reviews-custom-css">',"").replace("</style>",""):"";return e.createElement(e.Fragment,null,e.createElement("script",{nonce:t,id:"oke-reviews-settings",type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify(p)}}),e.createElement("style",{nonce:t,id:"oke-css-vars",dangerouslySetInnerHTML:{__html:y}}),f&&e.createElement("style",{nonce:t,id:"oke-reviews-custom-css",dangerouslySetInnerHTML:{__html:f}}),!o&&v&&e.createElement("script",{nonce:t,dangerouslySetInnerHTML:{__html:v}}),e.createElement("script",{nonce:t,type:"text/javascript",dangerouslySetInnerHTML:{__html:`window.okeProductUrlFormatter = ${"function"==typeof r?r.toString():"string"==typeof r?r:"(product) =>\n product && product.productHandle\n ? \"/products/\" + product.productHandle + \"/\" + (product.variantId ? '?variantId=' + product.variantId : '')\n : undefined"}`}}),k&&e.createElement("div",{dangerouslySetInnerHTML:{__html:k}}),w&&e.createElement("div",{dangerouslySetInnerHTML:{__html:w}}))};const v=({dataAttributes:t,metafieldContent:n=""})=>{const r=a(null),o=a(!1),d=function(e){const t=a();return i((()=>{t.current=e})),t.current}(t),s=()=>{r.current&&(window.okeWidgetApi.initWidget(r.current),o.current=!0)};return i((()=>{if(!d||t["data-oke-widget"]!==d["data-oke-widget"]||t["data-oke-star-rating"]!==d["data-oke-star-rating"]||t["data-oke-reviews-product-id"]!==d["data-oke-reviews-product-id"]||!o.current)return window.okeWidgetApi&&r.current?s():document.addEventListener("oke-script-loaded",s),()=>{document.removeEventListener("oke-script-loaded",s)}}),[t,d]),e.createElement("div",{ref:r,key:JSON.stringify(t),...t,dangerouslySetInnerHTML:n?{__html:n}:void 0})},k=/^[0-9]*$/;function w(e){if(e)return`shopify-${k.test(e)?e:e.split("/").slice(-1)[0]}`}const y=({productId:t,okendoReviewsSnippet:n,placeholder:r})=>{const o=l(),a=t?.length?w(t):null,i=t?.length?n:null,d={"data-oke-widget":"","data-oke-reviews-product-id":a};return null===o||o.okendoDataLoaded?e.createElement(v,{dataAttributes:d,metafieldContent:i?.value}):r||e.createElement("div",{style:{height:"350px"}})},f=({productId:t,okendoStarRatingSnippet:n,placeholder:r})=>{const o=l(),a={"data-oke-star-rating":"","data-oke-reviews-product-id":w(t)};return null===o||o.okendoDataLoaded?e.createElement(v,{dataAttributes:a,metafieldContent:n?.value}):r||e.createElement("div",{style:{height:"20px"}})},S='#graphql\n\tfragment OkendoStarRatingSnippet on Product {\n\t\tokendoStarRatingSnippet: metafield(\n\t\t\tnamespace: "okendo"\n\t\t\tkey: "StarRatingSnippet"\n\t\t) {\n\t\t\tvalue\n\t\t}\n\t}\n',h='#graphql\n\tfragment OkendoReviewsSnippet on Product {\n\t\tokendoReviewsSnippet: metafield(\n\t\t\tnamespace: "okendo"\n\t\t\tkey: "ReviewsWidgetSnippet"\n\t\t) {\n\t\t\tvalue\n\t\t}\n\t}\n';export{h as OKENDO_PRODUCT_REVIEWS_FRAGMENT,S as OKENDO_PRODUCT_STAR_RATING_FRAGMENT,m as OkendoProvider,y as OkendoReviews,f as OkendoStarRating,p as getOkendoProviderData};
|
|
@@ -4,7 +4,7 @@ export interface WithOkendoReviewsSnippet {
|
|
|
4
4
|
okendoReviewsSnippet?: MetafieldValue | null;
|
|
5
5
|
}
|
|
6
6
|
interface OkendoReviewsProps {
|
|
7
|
-
productId
|
|
7
|
+
productId?: string;
|
|
8
8
|
okendoReviewsSnippet?: MetafieldValue | null;
|
|
9
9
|
/**
|
|
10
10
|
* Only used if the promise returned by `getOkendoProviderData` is given to the OkendoProvider
|
|
@@ -4,7 +4,7 @@ export interface OkendoWidgetProps {
|
|
|
4
4
|
dataAttributes: {
|
|
5
5
|
'data-oke-widget'?: string;
|
|
6
6
|
'data-oke-star-rating'?: string;
|
|
7
|
-
'data-oke-reviews-product-id': string | undefined;
|
|
7
|
+
'data-oke-reviews-product-id': string | null | undefined;
|
|
8
8
|
};
|
|
9
9
|
metafieldContent?: string;
|
|
10
10
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ interface WithOkendoReviewsSnippet {
|
|
|
51
51
|
okendoReviewsSnippet?: MetafieldValue | null;
|
|
52
52
|
}
|
|
53
53
|
interface OkendoReviewsProps {
|
|
54
|
-
productId
|
|
54
|
+
productId?: string;
|
|
55
55
|
okendoReviewsSnippet?: MetafieldValue | null;
|
|
56
56
|
/**
|
|
57
57
|
* Only used if the promise returned by `getOkendoProviderData` is given to the OkendoProvider
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@okendo/shopify-hydrogen",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.6",
|
|
4
4
|
"description": "Okendo React components for Shopify Hydrogen 2 (Remix)",
|
|
5
5
|
"author": "Okendo",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"eslint": "eslint src"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@okendo/reviews-common": "^
|
|
23
|
-
"@okendo/reviews-widget-plus": "^0.
|
|
22
|
+
"@okendo/reviews-common": "^7.14.0",
|
|
23
|
+
"@okendo/reviews-widget-plus": "^0.70.23",
|
|
24
24
|
"@okendo/tsconfig": "0.0.2",
|
|
25
25
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
26
26
|
"@rollup/plugin-node-resolve": "^15.2.3",
|