@whatmore-repo/whatmore-reactnative-sdk 1.0.8

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.
Files changed (37) hide show
  1. package/commands.txt +34 -0
  2. package/index.d.ts +1 -0
  3. package/index.js +31 -0
  4. package/package.json +29 -0
  5. package/pre-integration-steps.txt +3 -0
  6. package/src/api/cart-commands/CartCommands.js +26 -0
  7. package/src/api/navigation-commands/NavigationCommands.js +17 -0
  8. package/src/api/partners/PartnerUtils.js +11 -0
  9. package/src/api/partners/appbrew/AppbrewCommands.js +27 -0
  10. package/src/api/product-details-commands/ProductDetailsCommands.js +390 -0
  11. package/src/api/shopify-commands/ShopifyCommands.js +29 -0
  12. package/src/api/whatmore-backend/WhatmoreMetricCommands.js +159 -0
  13. package/src/components/EventClickComponent.js +31 -0
  14. package/src/components/EventShoppingOverlay.js +75 -0
  15. package/src/components/EventShoppingView.js +32 -0
  16. package/src/components/EventsVerticalSwipeView.js +60 -0
  17. package/src/components/EventsVerticalSwipeViewNoModal.js +52 -0
  18. package/src/components/WhatmoreRootComponent.js +89 -0
  19. package/src/components/commons/AppMuteUnmuteIcon.js +36 -0
  20. package/src/components/cta-buttons/AddToCartButton.jsx +346 -0
  21. package/src/components/product-tiles/ProductPriceBadge.js +52 -0
  22. package/src/components/product-tiles/ProductTileV1.js +205 -0
  23. package/src/components/product-tiles/SelectVariantComponent.js +117 -0
  24. package/src/components/video-player/AppVideoPlayer.js +26 -0
  25. package/src/constants/AppGlobalVars.js +12 -0
  26. package/src/globals/useAppState_APP.js +18 -0
  27. package/src/hooks/useAddToCartStates.js +195 -0
  28. package/src/icons/icon-components/CartIcon.jsx +27 -0
  29. package/src/icons/icon-components/LoadingIcon.jsx +18 -0
  30. package/src/icons/icon-components/MuteIcon.jsx +23 -0
  31. package/src/icons/icon-components/PlusIcon.jsx +27 -0
  32. package/src/icons/icon-components/UnmuteIcon.jsx +23 -0
  33. package/src/icons/svg-utils.txt +6 -0
  34. package/src/utils/ColorUtils.js +40 -0
  35. package/src/utils/EventSanityUtils.js +21 -0
  36. package/src/utils/PriceUtils.js +28 -0
  37. package/src/utils/ProductUtils.js +6 -0
package/commands.txt ADDED
@@ -0,0 +1,34 @@
1
+ ## starting server
2
+ npm start --reset-cache
3
+ npm run android
4
+
5
+
6
+ ## Starting android emulator
7
+ adb start-server
8
+ adb kill-server
9
+
10
+
11
+ ## publishing npm package
12
+ npm publish --access public
13
+
14
+
15
+ ## Clear cache and reinstall
16
+ rmdir /s /q node_modules
17
+ del /F /Q package-lock.json
18
+ npm cache clean --force
19
+ npm install
20
+ npm link ./whatmore-reactnative-sdk
21
+
22
+
23
+ # Windows
24
+ ## Stop process at port
25
+ netstat -ano | findstr :19000
26
+ taskkill /PID 4584 /F
27
+
28
+ ## Recursively delete folder
29
+ rmdir /s /q folder-name
30
+ del /F /Q package-lock.json
31
+
32
+
33
+ ## Link node_modules from local
34
+ npm link ./whatmore-reactnative-sdk # solves no module found errors
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ declare module '*';
package/index.js ADDED
@@ -0,0 +1,31 @@
1
+ import { useEffect } from "react";
2
+ import WhatmoreRootComponent from "./src/components/WhatmoreRootComponent.js";
3
+ import { setGlobalState } from "./src/globals/useAppState_APP.js";
4
+ import { View } from "react-native";
5
+
6
+ export function WhatmoreBase(props){
7
+
8
+ useEffect(() => {
9
+ setGlobalState('whatmoreShopId', props.shopId);
10
+ setGlobalState('brandDomainContext', props.domainContext);
11
+ setGlobalState('commandsObject', props.commandsObject);
12
+ setGlobalState('template', props.template);
13
+ setGlobalState('modalUsed', props.modalUsed);
14
+ setGlobalState('activateMock', props.activateMock);
15
+ }, []);
16
+
17
+ // return (
18
+ // <View style={{
19
+ // width: '100%', height: '100%',
20
+ // backgroundColor: 'red'
21
+ // }}>
22
+
23
+ // </View>
24
+ // );
25
+
26
+ return (
27
+ <WhatmoreRootComponent shopId={props.shopId} />
28
+ );
29
+ }
30
+
31
+
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@whatmore-repo/whatmore-reactnative-sdk",
3
+ "version": "1.0.8",
4
+ "description": "",
5
+ "private": false,
6
+ "main": "index.js",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1"
9
+ },
10
+ "keywords": [
11
+ "whatmore"
12
+ ],
13
+ "dependencies": {
14
+ "currency-symbol-map": "^5.1.0",
15
+ "react": "18.2.0",
16
+ "react-hooks-global-state": "^2.1.0",
17
+ "react-native": "0.72.3",
18
+ "react-native-animatable": "^1.3.3",
19
+ "react-native-intersection-observer": "^0.0.9",
20
+ "react-native-svg": "^13.10.0",
21
+ "react-native-swiper": "^1.6.0",
22
+ "react-native-video": "^5.2.1"
23
+ },
24
+ "devDependencies": {
25
+ "@babel/core": "^7.20.0"
26
+ },
27
+ "author": "Shyam",
28
+ "license": "ISC"
29
+ }
@@ -0,0 +1,3 @@
1
+ 1. Libraries for react-native linking
2
+ -> react-native-video
3
+ -> react-native-svg
@@ -0,0 +1,26 @@
1
+ import { getGlobalState } from "../../globals/useAppState_APP";
2
+ import { isAppBrew, isAppMaker, isPlobalApps } from "../partners/PartnerUtils.js";
3
+ import { appbrewAddToCartCommand } from "../partners/appbrew/AppbrewCommands";
4
+
5
+ /**
6
+ *
7
+ * @param {*} variantId
8
+ * @param {*} itemQuantity
9
+ * @param {*} product
10
+ * @param {*} brandDomainContext
11
+ * @param {*} whatmoreShopId
12
+ * @returns Promise => true if command is executed successfully, false otherwise
13
+ */
14
+ export async function addToCartCommand(variantId, itemQuantity, product, brandDomainContext, whatmoreShopId){
15
+ const _ACTIVATE_MOCK_ = getGlobalState("activateMock");
16
+
17
+ if(_ACTIVATE_MOCK_){
18
+ return Promise.resolve(true);
19
+ }
20
+
21
+ if(isAppBrew(brandDomainContext)){
22
+ return await appbrewAddToCartCommand(variantId, itemQuantity, product, whatmoreShopId);
23
+ }
24
+
25
+ return Promise.resolve(false);
26
+ }
@@ -0,0 +1,17 @@
1
+
2
+ import { getGlobalState } from "../../globals/useAppState_APP.js";
3
+ import { isAppBrew, isAppMaker, isPlobalApps } from "../partners/PartnerUtils.js";
4
+ import { appbrewNavigateToProductPageCommand } from "../partners/appbrew/AppbrewCommands.js";
5
+
6
+ export async function navigateToProductPage(product, brandDomainContext, whatmoreShopId) {
7
+ const _ACTIVATE_MOCK_ = getGlobalState("activateMock");
8
+ if (_ACTIVATE_MOCK_) {
9
+ return Promise.resolve(true);
10
+ }
11
+
12
+ if(isAppBrew(brandDomainContext)){
13
+ return await appbrewNavigateToProductPageCommand(product, whatmoreShopId);
14
+ }
15
+
16
+ return Promise.resolve(false);
17
+ }
@@ -0,0 +1,11 @@
1
+ export function isAppBrew(brandDomainContext){
2
+ return brandDomainContext == "appbrew";
3
+ }
4
+
5
+ export function isAppMaker(brandDomainContext){
6
+ return brandDomainContext == "appmaker";
7
+ }
8
+
9
+ export function isPlobalApps(brandDomainContext){
10
+ return brandDomainContext == "plobalapps";
11
+ }
@@ -0,0 +1,27 @@
1
+ import { getGlobalState } from "../../../globals/useAppState_APP";
2
+ import { getProductHandle } from "../../../utils/ProductUtils";
3
+
4
+
5
+ export async function appbrewNavigateToProductPageCommand(product, whatmoreShopId){
6
+ const appbrewCommands = getGlobalState("commandsObject");
7
+ if(appbrewCommands && appbrewCommands.navigate){
8
+ appbrewCommands.navigate({
9
+ kind: 'screen',
10
+ screenId: 'product',
11
+ options: {
12
+ productHandle: getProductHandle(product)
13
+ }
14
+ });
15
+ return Promise.resolve(true);
16
+ }
17
+ return Promise.resolve(false);
18
+ }
19
+
20
+ export async function appbrewAddToCartCommand(productVariantId, itemQuantity, product, whatmoreShopId){
21
+ const appbrewCommands = getGlobalState("commandsObject");
22
+ if(appbrewCommands && appbrewCommands.addToCart){
23
+ appbrewCommands.addToCart(productVariantId,itemQuantity);
24
+ return Promise.resolve(true);
25
+ }
26
+ return Promise.resolve(false);
27
+ }
@@ -0,0 +1,390 @@
1
+ import { productDetailsShopify, productDetailsShopifyJS } from "../shopify-commands/ShopifyCommands.js";
2
+
3
+
4
+ function _isAppBrew(brandDomainContext){
5
+ return brandDomainContext == "appbrew";
6
+ }
7
+
8
+ function _isAppMaker(brandDomainContext){
9
+ return brandDomainContext == "appmaker";
10
+ }
11
+
12
+ function _isPlobalApps(brandDomainContext){
13
+ return brandDomainContext == "plobalapps";
14
+ }
15
+
16
+ /**
17
+ *
18
+ * @returns
19
+ *
20
+ * {
21
+ "product":{
22
+ "id":6780184559682,
23
+ "title":"Surkh Shibori Cotton Dress",
24
+ "body_html":"\u003cp\u003eBold, beautiful and glamorous, our Surkh Shibori Cotton Dress is perfect for those who like to make a statement wiith their every day style. \u003cbr\u003eColor: Red\/Blue\u003cbr\u003eDress Fabric: Cotton\u003c\/p\u003e\n\u003cp\u003eNeckline: Shirt Collar\u003cbr\u003eSleeve: Balloon\u003cbr\u003eCARE: Dry Clean Only \u003cbr\u003eModel Size: Model is wearing S Size \u003cbr\u003eModel Height: 5'4\"\u003cbr\u003e \u003cbr\u003eDISCLAIMER: Slight Color variations may occur due to different screen resolutions.\u003c\/p\u003e",
25
+ "vendor":"Aachho",
26
+ "product_type":"Dress",
27
+ "created_at":"2022-07-30T14:57:03+05:30",
28
+ "handle":"surkh-shibori-cotton-dress",
29
+ "updated_at":"2023-03-09T18:22:56+05:30",
30
+ "published_at":"2022-08-04T19:05:13+05:30",
31
+ "template_suffix":"",
32
+ "published_scope":"global",
33
+ "tags":"__label:NEW, category_express shipping, category_high, Category_Womenswear, Collection_Dress, Collection_Phulwari, Color_Blue, Color_Red, dress_collection, Fabric_Cotton, High, Neckline_Shirt Collar, OCCASSION_CASUAL, Pattern_Kalidaar, Phulwari, print_tie-\u0026-dye, Sleeves_Balloon, subcategory_dress, Technique_Tie \u0026 Dye",
34
+ "variants":[
35
+ {
36
+ "id":39873050804290,
37
+ "product_id":6780184559682,
38
+ "title":"XS",
39
+ "price":"3250.00",
40
+ "sku":"ACHSSJUL18-XS",
41
+ "position":1,
42
+ "compare_at_price":"3250.00",
43
+ "fulfillment_service":"manual",
44
+ "inventory_management":"shopify",
45
+ "option1":"XS",
46
+ "option2":null,
47
+ "option3":null,
48
+ "created_at":"2022-07-30T14:57:04+05:30",
49
+ "updated_at":"2023-02-22T18:02:08+05:30",
50
+ "taxable":true,
51
+ "barcode":"6814335325661",
52
+ "grams":800,
53
+ "image_id":null,
54
+ "weight":0.8,
55
+ "weight_unit":"kg",
56
+ "requires_shipping":true
57
+ },
58
+ {
59
+ "id":39873050837058,
60
+ "product_id":6780184559682,
61
+ "title":"S",
62
+ "price":"3250.00",
63
+ "sku":"ACHSSJUL18-S",
64
+ "position":2,
65
+ "compare_at_price":"3250.00",
66
+ "fulfillment_service":"manual",
67
+ "inventory_management":"shopify",
68
+ "option1":"S",
69
+ "option2":null,
70
+ "option3":null,
71
+ "created_at":"2022-07-30T14:57:04+05:30",
72
+ "updated_at":"2023-03-09T18:22:56+05:30",
73
+ "taxable":true,
74
+ "barcode":"3565335325661",
75
+ "grams":800,
76
+ "image_id":null,
77
+ "weight":0.8,
78
+ "weight_unit":"kg",
79
+ "requires_shipping":true
80
+ },
81
+ {
82
+ "id":39873050869826,
83
+ "product_id":6780184559682,
84
+ "title":"M",
85
+ "price":"3250.00",
86
+ "sku":"ACHSSJUL18-M",
87
+ "position":3,
88
+ "compare_at_price":"3250.00",
89
+ "fulfillment_service":"manual",
90
+ "inventory_management":"shopify",
91
+ "option1":"M",
92
+ "option2":null,
93
+ "option3":null,
94
+ "created_at":"2022-07-30T14:57:04+05:30",
95
+ "updated_at":"2023-03-04T13:05:45+05:30",
96
+ "taxable":true,
97
+ "barcode":"1707335325661",
98
+ "grams":800,
99
+ "image_id":null,
100
+ "weight":0.8,
101
+ "weight_unit":"kg",
102
+ "requires_shipping":true
103
+ }
104
+ ],
105
+ "options":[
106
+ {
107
+ "id":8825212633154,
108
+ "product_id":6780184559682,
109
+ "name":"Size",
110
+ "position":1,
111
+ "values":[
112
+ "XS",
113
+ "S",
114
+ "M",
115
+ "L",
116
+ "XL",
117
+ "XXL",
118
+ "XXXL",
119
+ "4XL",
120
+ "5XL"
121
+ ]
122
+ }
123
+ ],
124
+ "images":[
125
+ {
126
+ "id":29273280905282,
127
+ "product_id":6780184559682,
128
+ "position":1,
129
+ "created_at":"2022-08-04T18:51:06+05:30",
130
+ "updated_at":"2022-08-04T22:11:03+05:30",
131
+ "alt":"Surkh Shibori Cotton Dress",
132
+ "width":2702,
133
+ "height":3377,
134
+ "src":"https:\/\/cdn.shopify.com\/s\/files\/1\/2542\/7564\/products\/40_8146ee2f-7a8a-43b3-9b1d-d170823cf30b.png?v=1659631263",
135
+ "variant_ids":[
136
+
137
+ ]
138
+ },
139
+ {
140
+ "id":29273280839746,
141
+ "product_id":6780184559682,
142
+ "position":2,
143
+ "created_at":"2022-08-04T18:51:06+05:30",
144
+ "updated_at":"2022-08-04T22:11:03+05:30",
145
+ "alt":"Surkh Shibori Cotton Dress",
146
+ "width":2702,
147
+ "height":3377,
148
+ "src":"https:\/\/cdn.shopify.com\/s\/files\/1\/2542\/7564\/products\/38_673c4d81-d87f-4260-a819-2c3b93d7b9fa.png?v=1659631263",
149
+ "variant_ids":[
150
+
151
+ ]
152
+ },
153
+ {
154
+ "id":29273280872514,
155
+ "product_id":6780184559682,
156
+ "position":3,
157
+ "created_at":"2022-08-04T18:51:06+05:30",
158
+ "updated_at":"2022-08-04T22:11:03+05:30",
159
+ "alt":"Surkh Shibori Cotton Dress",
160
+ "width":2702,
161
+ "height":3377,
162
+ "src":"https:\/\/cdn.shopify.com\/s\/files\/1\/2542\/7564\/products\/39_2e96c511-8984-4576-b6b6-530374b63d47.png?v=1659631263",
163
+ "variant_ids":[
164
+
165
+ ]
166
+ }
167
+ ],
168
+ "image":{
169
+ "id":29273280905282,
170
+ "product_id":6780184559682,
171
+ "position":1,
172
+ "created_at":"2022-08-04T18:51:06+05:30",
173
+ "updated_at":"2022-08-04T22:11:03+05:30",
174
+ "alt":"Surkh Shibori Cotton Dress",
175
+ "width":2702,
176
+ "height":3377,
177
+ "src":"https:\/\/cdn.shopify.com\/s\/files\/1\/2542\/7564\/products\/40_8146ee2f-7a8a-43b3-9b1d-d170823cf30b.png?v=1659631263",
178
+ "variant_ids":[
179
+
180
+ ]
181
+ }
182
+ }
183
+ }
184
+ *
185
+ */
186
+
187
+ export async function productDetails(product, brandDomainContext, whatmoreShopId){
188
+
189
+ if(_isAppBrew(brandDomainContext) || _isAppMaker(brandDomainContext) || _isPlobalApps(brandDomainContext)){
190
+ return productDetailsShopify(product);
191
+ }
192
+
193
+ // brandDomainContext == "whatmore"
194
+ return {};
195
+ }
196
+
197
+
198
+
199
+ /**
200
+ *
201
+ * @returns
202
+ *
203
+ * {
204
+ "id":6780184559682,
205
+ "title":"Surkh Shibori Cotton Dress",
206
+ "handle":"surkh-shibori-cotton-dress",
207
+ "description":"\u003cp\u003eBold, beautiful and glamorous, our Surkh Shibori Cotton Dress is perfect for those who like to make a statement wiith their every day style. \u003cbr\u003eColor: Red\/Blue\u003cbr\u003eDress Fabric: Cotton\u003c\/p\u003e\n\u003cp\u003eNeckline: Shirt Collar\u003cbr\u003eSleeve: Balloon\u003cbr\u003eCARE: Dry Clean Only \u003cbr\u003eModel Size: Model is wearing S Size \u003cbr\u003eModel Height: 5'4\"\u003cbr\u003e \u003cbr\u003eDISCLAIMER: Slight Color variations may occur due to different screen resolutions.\u003c\/p\u003e",
208
+ "published_at":"2022-08-04T19:05:13+05:30",
209
+ "created_at":"2022-07-30T14:57:03+05:30",
210
+ "vendor":"Aachho",
211
+ "type":"Dress",
212
+ "tags":[
213
+ "__label:NEW",
214
+ "category_express shipping",
215
+ "category_high",
216
+ "Category_Womenswear",
217
+ "Collection_Dress",
218
+ "Collection_Phulwari",
219
+ "Color_Blue",
220
+ "Color_Red",
221
+ "dress_collection",
222
+ "Fabric_Cotton",
223
+ "High",
224
+ "Neckline_Shirt Collar",
225
+ "OCCASSION_CASUAL",
226
+ "Pattern_Kalidaar",
227
+ "Phulwari",
228
+ "print_tie-\u0026-dye",
229
+ "Sleeves_Balloon",
230
+ "subcategory_dress",
231
+ "Technique_Tie \u0026 Dye"
232
+ ],
233
+ "price":325000,
234
+ "price_min":325000,
235
+ "price_max":325000,
236
+ "available":true,
237
+ "price_varies":false,
238
+ "compare_at_price":325000,
239
+ "compare_at_price_min":325000,
240
+ "compare_at_price_max":325000,
241
+ "compare_at_price_varies":false,
242
+ "variants":[
243
+ {
244
+ "id":39873050804290,
245
+ "title":"XS",
246
+ "option1":"XS",
247
+ "option2":null,
248
+ "option3":null,
249
+ "sku":"ACHSSJUL18-XS",
250
+ "requires_shipping":true,
251
+ "taxable":true,
252
+ "featured_image":null,
253
+ "available":true,
254
+ "name":"Surkh Shibori Cotton Dress - XS",
255
+ "public_title":"XS",
256
+ "options":[
257
+ "XS"
258
+ ],
259
+ "price":325000,
260
+ "weight":800,
261
+ "compare_at_price":325000,
262
+ "inventory_management":"shopify",
263
+ "barcode":"6814335325661",
264
+ "requires_selling_plan":false,
265
+ "selling_plan_allocations":[
266
+
267
+ ]
268
+ },
269
+ {
270
+ "id":39873050837058,
271
+ "title":"S",
272
+ "option1":"S",
273
+ "option2":null,
274
+ "option3":null,
275
+ "sku":"ACHSSJUL18-S",
276
+ "requires_shipping":true,
277
+ "taxable":true,
278
+ "featured_image":null,
279
+ "available":true,
280
+ "name":"Surkh Shibori Cotton Dress - S",
281
+ "public_title":"S",
282
+ "options":[
283
+ "S"
284
+ ],
285
+ "price":325000,
286
+ "weight":800,
287
+ "compare_at_price":325000,
288
+ "inventory_management":"shopify",
289
+ "barcode":"3565335325661",
290
+ "requires_selling_plan":false,
291
+ "selling_plan_allocations":[
292
+
293
+ ]
294
+ }
295
+ ],
296
+ "images":[
297
+ "\/\/cdn.shopify.com\/s\/files\/1\/2542\/7564\/products\/40_8146ee2f-7a8a-43b3-9b1d-d170823cf30b.png?v=1659631263",
298
+ "\/\/cdn.shopify.com\/s\/files\/1\/2542\/7564\/products\/38_673c4d81-d87f-4260-a819-2c3b93d7b9fa.png?v=1659631263",
299
+ "\/\/cdn.shopify.com\/s\/files\/1\/2542\/7564\/products\/39_2e96c511-8984-4576-b6b6-530374b63d47.png?v=1659631263",
300
+ "\/\/cdn.shopify.com\/s\/files\/1\/2542\/7564\/products\/41_0a2700f3-e376-4d09-a646-9f93bfd44653.png?v=1659619266",
301
+ "\/\/cdn.shopify.com\/s\/files\/1\/2542\/7564\/products\/42_00bb615d-361a-4964-bae2-ff35e8111c25.png?v=1659619266",
302
+ "\/\/cdn.shopify.com\/s\/files\/1\/2542\/7564\/products\/43_26802366-7c42-42db-a467-ba417fde4fe6.png?v=1659619271",
303
+ "\/\/cdn.shopify.com\/s\/files\/1\/2542\/7564\/products\/44_8d0268e9-e6c7-4913-81f5-a4ba90435199.png?v=1659619271"
304
+ ],
305
+ "featured_image":"\/\/cdn.shopify.com\/s\/files\/1\/2542\/7564\/products\/40_8146ee2f-7a8a-43b3-9b1d-d170823cf30b.png?v=1659631263",
306
+ "options":[
307
+ {
308
+ "name":"Size",
309
+ "position":1,
310
+ "values":[
311
+ "XS",
312
+ "S",
313
+ "M",
314
+ "L",
315
+ "XL",
316
+ "XXL",
317
+ "XXXL",
318
+ "4XL",
319
+ "5XL"
320
+ ]
321
+ }
322
+ ],
323
+ "url":"\/products\/surkh-shibori-cotton-dress",
324
+ "media":[
325
+ {
326
+ "alt":"Surkh Shibori Cotton Dress",
327
+ "id":21594143588418,
328
+ "position":1,
329
+ "preview_image":{
330
+ "aspect_ratio":0.8,
331
+ "height":3377,
332
+ "width":2702,
333
+ "src":"https:\/\/cdn.shopify.com\/s\/files\/1\/2542\/7564\/products\/40_8146ee2f-7a8a-43b3-9b1d-d170823cf30b.png?v=1659631263"
334
+ },
335
+ "aspect_ratio":0.8,
336
+ "height":3377,
337
+ "media_type":"image",
338
+ "src":"https:\/\/cdn.shopify.com\/s\/files\/1\/2542\/7564\/products\/40_8146ee2f-7a8a-43b3-9b1d-d170823cf30b.png?v=1659631263",
339
+ "width":2702
340
+ },
341
+ {
342
+ "alt":"Surkh Shibori Cotton Dress",
343
+ "id":21594143522882,
344
+ "position":2,
345
+ "preview_image":{
346
+ "aspect_ratio":0.8,
347
+ "height":3377,
348
+ "width":2702,
349
+ "src":"https:\/\/cdn.shopify.com\/s\/files\/1\/2542\/7564\/products\/38_673c4d81-d87f-4260-a819-2c3b93d7b9fa.png?v=1659631263"
350
+ },
351
+ "aspect_ratio":0.8,
352
+ "height":3377,
353
+ "media_type":"image",
354
+ "src":"https:\/\/cdn.shopify.com\/s\/files\/1\/2542\/7564\/products\/38_673c4d81-d87f-4260-a819-2c3b93d7b9fa.png?v=1659631263",
355
+ "width":2702
356
+ }
357
+ ],
358
+ "requires_selling_plan":false,
359
+ "selling_plan_groups":[]
360
+ }
361
+ */
362
+ export async function productDetailsDetailed(product, brandDomainContext, whatmoreShopId){
363
+
364
+ if(_isAppBrew(brandDomainContext) || _isAppMaker(brandDomainContext) || _isPlobalApps(brandDomainContext)){
365
+ return productDetailsShopifyJS(product);
366
+ }
367
+
368
+ // brandDomainContext == "whatmore"
369
+ return {};
370
+ }
371
+
372
+ /**
373
+ * Currently used only for external stores
374
+ *
375
+ * Sample response:
376
+ * {
377
+ * 'price': 1234,
378
+ * 'compare_at_price': 1355,
379
+ * 'currency_code': USD
380
+ * }
381
+ */
382
+ export async function getProductPriceAndCurrencyDetails(product, brandDomainContext, whatmoreShopId){
383
+
384
+ if(_isAppBrew(brandDomainContext) || _isAppMaker(brandDomainContext) || _isPlobalApps(brandDomainContext)){
385
+ return {};
386
+ }
387
+
388
+ // brandDomainContext == "whatmore"
389
+ return {}
390
+ }
@@ -0,0 +1,29 @@
1
+ export async function productDetailsShopify(product){
2
+ const url = product.product_link + '.json';
3
+ const response = await fetch(url , {
4
+ method: 'GET',
5
+ });
6
+
7
+ if (!response.ok) {
8
+ throw new Error(`Error! status: ${response.status}`);
9
+ }
10
+
11
+ const result = await response.json();
12
+
13
+ return result;
14
+ }
15
+
16
+ export async function productDetailsShopifyJS(product){
17
+ const url = product.product_link + '.js';
18
+ const response = await fetch(url , {
19
+ method: 'GET',
20
+ });
21
+
22
+ if (!response.ok) {
23
+ throw new Error(`Error! status: ${response.status}`);
24
+ }
25
+
26
+ const result = await response.json();
27
+
28
+ return result;
29
+ }