@gem-sdk/components 2.0.0-staging.154 → 2.0.0-staging.159
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/dist/cjs/banner/components/hero-banner/index.liquid.js +1 -1
- package/dist/cjs/builder.js +4 -0
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/index.liquid.js +4 -0
- package/dist/cjs/post-purchase/product/components/ProductDiscountTag.js +5 -2
- package/dist/cjs/post-purchase/product/components/ProductOffer.js +16 -3
- package/dist/cjs/post-purchase/product/components/ProductPrice.js +3 -1
- package/dist/cjs/post-purchase/product/components/ProductPriceBreakdown.js +9 -21
- package/dist/cjs/post-purchase/product/constants/ProductOfferPlaceholder.js +149 -0
- package/dist/cjs/post-purchase/product/hooks/useDynamicProduct.js +28 -0
- package/dist/cjs/post-purchase/product/settings/ProductOffer.js +26 -0
- package/dist/cjs/product/components/ProductBundleDiscountItem.liquid.js +3 -3
- package/dist/cjs/third-party/components/EssentialAnnouncementBar.js +33 -0
- package/dist/cjs/third-party/components/EssentialAnnouncementBar.liquid.js +12 -0
- package/dist/cjs/third-party/components/EssentialCountdownTimerBar.js +33 -0
- package/dist/cjs/third-party/components/EssentialCountdownTimerBar.liquid.js +12 -0
- package/dist/cjs/third-party/configs/EssentialAnnouncementBar.js +12 -0
- package/dist/cjs/third-party/configs/EssentialCountdownTimerBar.js +12 -0
- package/dist/cjs/third-party/helpers/thirdParty.js +1 -1
- package/dist/cjs/third-party/next.js +10 -0
- package/dist/cjs/third-party/setting/EssentialAnnouncementBar.js +142 -0
- package/dist/cjs/third-party/setting/EssentialCountdownTimerBar.js +142 -0
- package/dist/cjs/third-party/setting/index.js +4 -0
- package/dist/esm/banner/components/hero-banner/index.liquid.js +1 -1
- package/dist/esm/builder.js +4 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.liquid.js +2 -0
- package/dist/esm/post-purchase/product/components/ProductDiscountTag.js +5 -2
- package/dist/esm/post-purchase/product/components/ProductOffer.js +16 -3
- package/dist/esm/post-purchase/product/components/ProductPrice.js +3 -1
- package/dist/esm/post-purchase/product/components/ProductPriceBreakdown.js +9 -21
- package/dist/esm/post-purchase/product/constants/ProductOfferPlaceholder.js +147 -0
- package/dist/esm/post-purchase/product/hooks/useDynamicProduct.js +26 -0
- package/dist/esm/post-purchase/product/settings/ProductOffer.js +26 -0
- package/dist/esm/product/components/ProductBundleDiscountItem.liquid.js +3 -3
- package/dist/esm/third-party/components/EssentialAnnouncementBar.js +29 -0
- package/dist/esm/third-party/components/EssentialAnnouncementBar.liquid.js +8 -0
- package/dist/esm/third-party/components/EssentialCountdownTimerBar.js +29 -0
- package/dist/esm/third-party/components/EssentialCountdownTimerBar.liquid.js +8 -0
- package/dist/esm/third-party/configs/EssentialAnnouncementBar.js +8 -0
- package/dist/esm/third-party/configs/EssentialCountdownTimerBar.js +8 -0
- package/dist/esm/third-party/helpers/thirdParty.js +1 -1
- package/dist/esm/third-party/next.js +10 -0
- package/dist/esm/third-party/setting/EssentialAnnouncementBar.js +138 -0
- package/dist/esm/third-party/setting/EssentialCountdownTimerBar.js +138 -0
- package/dist/esm/third-party/setting/index.js +206 -202
- package/dist/types/index.d.ts +38 -1
- package/package.json +2 -2
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var EssentialAnnouncementBar = require('../configs/EssentialAnnouncementBar.js');
|
|
6
|
+
|
|
7
|
+
const config = {
|
|
8
|
+
tag: EssentialAnnouncementBar.default.tag,
|
|
9
|
+
label: EssentialAnnouncementBar.default.label,
|
|
10
|
+
icon: '<img class="gp-w-6 gp-border gp-border-[#494949] gp-rounded-[3px]" src="https://cdn.shopify.com/app-store/listing_images/15e8255158a042a1eab34a4c45c72aa5/icon/CMK1jPv9uoADEAE=.png">',
|
|
11
|
+
editorConfigs: {
|
|
12
|
+
component: {
|
|
13
|
+
isThirdParty: true
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
presets: [
|
|
17
|
+
{
|
|
18
|
+
id: EssentialAnnouncementBar.default.id,
|
|
19
|
+
name: {
|
|
20
|
+
en: EssentialAnnouncementBar.default.label
|
|
21
|
+
},
|
|
22
|
+
hideTextContent: true,
|
|
23
|
+
icon: {
|
|
24
|
+
desktop: `<div class="w-full flex flex-col items-center">
|
|
25
|
+
<img class="w-24 border border-dark-200 rounded-medium" src="https://cdn.shopify.com/app-store/listing_images/15e8255158a042a1eab34a4c45c72aa5/icon/CMK1jPv9uoADEAE=.png">
|
|
26
|
+
<span class="preset-item-title">Essential Announcement Bar</span>
|
|
27
|
+
</div>`
|
|
28
|
+
},
|
|
29
|
+
components: [
|
|
30
|
+
{
|
|
31
|
+
tag: EssentialAnnouncementBar.default.tag
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
settings: [
|
|
37
|
+
{
|
|
38
|
+
id: 'setting',
|
|
39
|
+
controls: [
|
|
40
|
+
{
|
|
41
|
+
id: 'appBlockId',
|
|
42
|
+
type: 'input',
|
|
43
|
+
default: ''
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: 'widgetType',
|
|
47
|
+
label: 'Choose widget',
|
|
48
|
+
type: 'select',
|
|
49
|
+
options: [
|
|
50
|
+
{
|
|
51
|
+
label: 'App Block',
|
|
52
|
+
value: 'app-block'
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
default: 'app-block'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: 'install',
|
|
59
|
+
type: 'open-link',
|
|
60
|
+
target: '_blank',
|
|
61
|
+
linkType: 'install',
|
|
62
|
+
href: 'https://apps.shopify.com/essential-announcement-bar?utm_source=gempages',
|
|
63
|
+
appName: EssentialAnnouncementBar.default.label
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 'announcementId',
|
|
67
|
+
type: 'input',
|
|
68
|
+
default: ''
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'openApp',
|
|
72
|
+
type: 'open-link',
|
|
73
|
+
target: '_blank',
|
|
74
|
+
linkType: 'openApp',
|
|
75
|
+
href: 'https://admin.shopify.com/?redirect=/apps/essential-announcement-bar',
|
|
76
|
+
appName: EssentialAnnouncementBar.default.label
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: 'align',
|
|
80
|
+
label: 'Alignment',
|
|
81
|
+
type: 'segment',
|
|
82
|
+
options: [
|
|
83
|
+
{
|
|
84
|
+
label: 'Left',
|
|
85
|
+
value: 'left',
|
|
86
|
+
type: 'align'
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
label: 'Center',
|
|
90
|
+
value: 'center',
|
|
91
|
+
type: 'align'
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
label: 'Right',
|
|
95
|
+
value: 'right',
|
|
96
|
+
type: 'align'
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
devices: {
|
|
100
|
+
desktop: {
|
|
101
|
+
default: 'left'
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
ui: [
|
|
109
|
+
{
|
|
110
|
+
type: 'control',
|
|
111
|
+
setting: {
|
|
112
|
+
id: 'install'
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
type: 'control',
|
|
117
|
+
label: {
|
|
118
|
+
en: 'Announcement id'
|
|
119
|
+
},
|
|
120
|
+
setting: {
|
|
121
|
+
id: 'announcementId'
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
type: 'control',
|
|
126
|
+
setting: {
|
|
127
|
+
id: 'openApp'
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
type: 'control',
|
|
132
|
+
label: {
|
|
133
|
+
en: 'Align'
|
|
134
|
+
},
|
|
135
|
+
setting: {
|
|
136
|
+
id: 'align'
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
exports.default = config;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var EssentialCountdownTimerBar = require('../configs/EssentialCountdownTimerBar.js');
|
|
6
|
+
|
|
7
|
+
const config = {
|
|
8
|
+
tag: EssentialCountdownTimerBar.default.tag,
|
|
9
|
+
label: EssentialCountdownTimerBar.default.label,
|
|
10
|
+
icon: '<img class="gp-w-6 gp-border gp-border-[#494949] gp-rounded-[3px]" src="https://cdn.shopify.com/app-store/listing_images/f84bf9e49eca8bd84c2af7488461363b/icon/CPzKxLTD4_UCEAE=.png">',
|
|
11
|
+
editorConfigs: {
|
|
12
|
+
component: {
|
|
13
|
+
isThirdParty: true
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
presets: [
|
|
17
|
+
{
|
|
18
|
+
id: EssentialCountdownTimerBar.default.id,
|
|
19
|
+
name: {
|
|
20
|
+
en: EssentialCountdownTimerBar.default.label
|
|
21
|
+
},
|
|
22
|
+
hideTextContent: true,
|
|
23
|
+
icon: {
|
|
24
|
+
desktop: `<div class="w-full flex flex-col items-center">
|
|
25
|
+
<img class="w-24 border border-dark-200 rounded-medium" src="https://cdn.shopify.com/app-store/listing_images/f84bf9e49eca8bd84c2af7488461363b/icon/CPzKxLTD4_UCEAE=.png">
|
|
26
|
+
<span class="preset-item-title">Essential Countdown Timer Bar</span>
|
|
27
|
+
</div>`
|
|
28
|
+
},
|
|
29
|
+
components: [
|
|
30
|
+
{
|
|
31
|
+
tag: EssentialCountdownTimerBar.default.tag
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
settings: [
|
|
37
|
+
{
|
|
38
|
+
id: 'setting',
|
|
39
|
+
controls: [
|
|
40
|
+
{
|
|
41
|
+
id: 'appBlockId',
|
|
42
|
+
type: 'input',
|
|
43
|
+
default: ''
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: 'widgetType',
|
|
47
|
+
label: 'Choose widget',
|
|
48
|
+
type: 'select',
|
|
49
|
+
options: [
|
|
50
|
+
{
|
|
51
|
+
label: 'App Block',
|
|
52
|
+
value: 'app-block'
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
default: 'app-block'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: 'install',
|
|
59
|
+
type: 'open-link',
|
|
60
|
+
target: '_blank',
|
|
61
|
+
linkType: 'install',
|
|
62
|
+
href: 'https://apps.shopify.com/essential-countdown-timer?utm_source=gempages',
|
|
63
|
+
appName: EssentialCountdownTimerBar.default.label
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 'timerId',
|
|
67
|
+
type: 'input',
|
|
68
|
+
default: ''
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'openApp',
|
|
72
|
+
type: 'open-link',
|
|
73
|
+
target: '_blank',
|
|
74
|
+
linkType: 'openApp',
|
|
75
|
+
href: 'https://admin.shopify.com/?redirect=/apps/countdown-timer-30',
|
|
76
|
+
appName: EssentialCountdownTimerBar.default.label
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: 'align',
|
|
80
|
+
label: 'Alignment',
|
|
81
|
+
type: 'segment',
|
|
82
|
+
options: [
|
|
83
|
+
{
|
|
84
|
+
label: 'Left',
|
|
85
|
+
value: 'left',
|
|
86
|
+
type: 'align'
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
label: 'Center',
|
|
90
|
+
value: 'center',
|
|
91
|
+
type: 'align'
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
label: 'Right',
|
|
95
|
+
value: 'right',
|
|
96
|
+
type: 'align'
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
devices: {
|
|
100
|
+
desktop: {
|
|
101
|
+
default: 'left'
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
ui: [
|
|
109
|
+
{
|
|
110
|
+
type: 'control',
|
|
111
|
+
setting: {
|
|
112
|
+
id: 'install'
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
type: 'control',
|
|
117
|
+
label: {
|
|
118
|
+
en: 'Timer id'
|
|
119
|
+
},
|
|
120
|
+
setting: {
|
|
121
|
+
id: 'timerId'
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
type: 'control',
|
|
126
|
+
setting: {
|
|
127
|
+
id: 'openApp'
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
type: 'control',
|
|
132
|
+
label: {
|
|
133
|
+
en: 'Align'
|
|
134
|
+
},
|
|
135
|
+
setting: {
|
|
136
|
+
id: 'align'
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
exports.default = config;
|
|
@@ -103,8 +103,12 @@ var MyappgurusProductReviews = require('./MyappgurusProductReviews.js');
|
|
|
103
103
|
var HulkProductOptions = require('./HulkProductOptions.js');
|
|
104
104
|
var TrustshopProductReviews = require('./TrustshopProductReviews.js');
|
|
105
105
|
var StellarDeliveryDatePickup = require('./StellarDeliveryDatePickup.js');
|
|
106
|
+
var EssentialCountdownTimerBar = require('./EssentialCountdownTimerBar.js');
|
|
107
|
+
var EssentialAnnouncementBar = require('./EssentialAnnouncementBar.js');
|
|
106
108
|
|
|
107
109
|
var thirdPartySetting = {
|
|
110
|
+
EssentialAnnouncementBar: EssentialAnnouncementBar.default,
|
|
111
|
+
EssentialCountdownTimerBar: EssentialCountdownTimerBar.default,
|
|
108
112
|
StellarDeliveryDatePickup: StellarDeliveryDatePickup.default,
|
|
109
113
|
TrustshopProductReviews: TrustshopProductReviews.default,
|
|
110
114
|
HulkProductOptions: HulkProductOptions.default,
|
|
@@ -262,7 +262,6 @@ const HeroBanner = ({ builderAttrs, builderProps, setting, styles, style, childr
|
|
|
262
262
|
}}">
|
|
263
263
|
<gp-hero-banner
|
|
264
264
|
gp-data='${dataStringify({
|
|
265
|
-
href: urlData?.href ?? '',
|
|
266
265
|
target: urlData?.target ?? '_blank',
|
|
267
266
|
background: backgroundResponsive,
|
|
268
267
|
uid: builderProps?.uid,
|
|
@@ -275,6 +274,7 @@ const HeroBanner = ({ builderAttrs, builderProps, setting, styles, style, childr
|
|
|
275
274
|
contentPosition2Col: styles?.contentPosition2Col,
|
|
276
275
|
aspectRatio: setting?.aspectRatio
|
|
277
276
|
}).replaceAll("'", ''')}'
|
|
277
|
+
gp-href="${urlData.href}"
|
|
278
278
|
${{
|
|
279
279
|
...builderAttrs
|
|
280
280
|
}}
|
package/dist/esm/builder.js
CHANGED
|
@@ -108,6 +108,8 @@ import MyappgurusProductReviews from './third-party/components/MyappgurusProduct
|
|
|
108
108
|
import HulkProductOptions from './third-party/components/HulkProductOptions.js';
|
|
109
109
|
import TrustshopProductReviews from './third-party/components/TrustshopProductReviews.js';
|
|
110
110
|
import StellarDeliveryDatePickup from './third-party/components/StellarDeliveryDatePickup.js';
|
|
111
|
+
import EssentialCountdownTimerBar from './third-party/components/EssentialCountdownTimerBar.js';
|
|
112
|
+
import EssentialAnnouncementBar from './third-party/components/EssentialAnnouncementBar.js';
|
|
111
113
|
import CartLineVariant from './cart/components/CartLineVariant.js';
|
|
112
114
|
import Cart from './cart/components/Cart.js';
|
|
113
115
|
import CartList from './cart/components/CartList.js';
|
|
@@ -244,6 +246,8 @@ import Link$1 from './post-purchase/link/components/PostPurchaseLink.js';
|
|
|
244
246
|
import Text$1 from './post-purchase/text/Text.js';
|
|
245
247
|
|
|
246
248
|
var builder = {
|
|
249
|
+
EssentialAnnouncementBar,
|
|
250
|
+
EssentialCountdownTimerBar,
|
|
247
251
|
StellarDeliveryDatePickup,
|
|
248
252
|
TrustshopProductReviews,
|
|
249
253
|
HulkProductOptions,
|
package/dist/esm/index.js
CHANGED
|
@@ -205,6 +205,8 @@ export { default as MyappgurusProductReviews } from './third-party/components/My
|
|
|
205
205
|
export { default as HulkProductOptions } from './third-party/components/HulkProductOptions.js';
|
|
206
206
|
export { default as TrustshopProductReviews } from './third-party/components/TrustshopProductReviews.js';
|
|
207
207
|
export { default as StellarDeliveryDatePickup } from './third-party/components/StellarDeliveryDatePickup.js';
|
|
208
|
+
export { default as EssentialCountdownTimerBar } from './third-party/components/EssentialCountdownTimerBar.js';
|
|
209
|
+
export { default as EssentialAnnouncementBar } from './third-party/components/EssentialAnnouncementBar.js';
|
|
208
210
|
export { default as thirdPartyInstantSetting } from './third-party-instant/setting/index.js';
|
|
209
211
|
export { default as InstantJudgemeReviews } from './third-party-instant/components/InstantJudgemeReviews.js';
|
|
210
212
|
export { default as InstantLooxReviews } from './third-party-instant/components/InstantLooxReviews.js';
|
package/dist/esm/index.liquid.js
CHANGED
|
@@ -159,6 +159,8 @@ export { default as DiscountyBulkDiscountSales } from './third-party/components/
|
|
|
159
159
|
export { default as TrustreviewsProductReviews } from './third-party/components/TrustreviewsProductReviews.liquid.js';
|
|
160
160
|
export { default as MyappgurusProductReviews } from './third-party/components/MyappgurusProductReviews.liquid.js';
|
|
161
161
|
export { default as HulkProductOptions } from './third-party/components/HulkProductOptions.liquid.js';
|
|
162
|
+
export { default as EssentialCountdownTimerBar } from './third-party/components/EssentialCountdownTimerBar.liquid.js';
|
|
163
|
+
export { default as EssentialAnnouncementBar } from './third-party/components/EssentialAnnouncementBar.liquid.js';
|
|
162
164
|
export { default as TrustshopProductReviews } from './third-party/components/TrustshopProductReviews.liquid.js';
|
|
163
165
|
export { default as StellarDeliveryDatePickup } from './third-party/components/StellarDeliveryDatePickup.liquid.js';
|
|
164
166
|
export { default as ImageComparison } from './image-comparison/components/ImageComparison.liquid.js';
|
|
@@ -2,26 +2,29 @@
|
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useProduct, useProductOfferDiscount, cls } from '@gem-sdk/core';
|
|
4
4
|
import Text from '../../text/Text.js';
|
|
5
|
+
import { useDynamicProduct } from '../hooks/useDynamicProduct.js';
|
|
5
6
|
|
|
6
7
|
const PostPurchaseProductDiscountTag = ({ setting = {}, styles = {}, style, builderAttrs, builderProps, children })=>{
|
|
7
8
|
const currentProduct = useProduct();
|
|
8
9
|
const currentProductId = currentProduct?.baseID?.replace('gid://shopify/Product/', '');
|
|
9
10
|
const currentOfferDiscount = useProductOfferDiscount();
|
|
11
|
+
const { isDynamicProduct, isEnableDynamicDiscount } = useDynamicProduct();
|
|
10
12
|
const { typo } = styles;
|
|
11
13
|
const { message } = setting;
|
|
14
|
+
const hasDiscount = !!currentOfferDiscount || isDynamicProduct && isEnableDynamicDiscount;
|
|
12
15
|
return /*#__PURE__*/ jsxs("div", {
|
|
13
16
|
...builderAttrs,
|
|
14
17
|
className: cls(builderProps?.uid, 'gp-flex gp-w-full'),
|
|
15
18
|
style: {
|
|
16
19
|
...style,
|
|
17
|
-
opacity:
|
|
20
|
+
opacity: hasDiscount ? 1 : 0.2
|
|
18
21
|
},
|
|
19
22
|
id: `shopify-text-element-${builderProps?.uid}`,
|
|
20
23
|
"data-product-id": currentProductId,
|
|
21
24
|
children: [
|
|
22
25
|
/*#__PURE__*/ jsx(Text, {
|
|
23
26
|
setting: {
|
|
24
|
-
text:
|
|
27
|
+
text: hasDiscount ? message : message?.replace(new RegExp(/\{\{Discount\}\}/, 'gi'), '0%')
|
|
25
28
|
},
|
|
26
29
|
styles: {
|
|
27
30
|
typo
|
|
@@ -8,14 +8,20 @@ import Loading from '../../../common/components/Loading.js';
|
|
|
8
8
|
import { DEVICES } from './ProductVariant.js';
|
|
9
9
|
import { postPurchaseViewSpacing } from '../../utils/helper.js';
|
|
10
10
|
import { hasPublicStoreFrontData, createStoreFrontFetcher } from '../helpers/index.js';
|
|
11
|
+
import { productOfferPlaceholder } from '../constants/ProductOfferPlaceholder.js';
|
|
12
|
+
import { useDynamicProduct } from '../hooks/useDynamicProduct.js';
|
|
11
13
|
|
|
12
14
|
const PostPurchaseProductOffer = ({ styles, builderAttrs, builderProps, children, setting })=>{
|
|
13
15
|
const mode = useEditorMode();
|
|
14
|
-
const { productSetting, productOfferLayout, inlineAlignment, variantSelected, ...rowSetting } = setting || {};
|
|
16
|
+
const { productSetting, productOfferLayout, inlineAlignment, variantSelected, discountAndShippingFee, ...rowSetting } = setting || {};
|
|
15
17
|
const { productOfferColumnGap, productOfferVerticalGutter, productOfferWidth, ...rowStyles } = styles || {};
|
|
16
18
|
const productOffers = usePageStore((s)=>s.productOffers);
|
|
17
19
|
const publicStoreFrontData = usePageStore((s)=>s.publicStoreFrontData);
|
|
18
|
-
const
|
|
20
|
+
const { isDynamicProduct } = useDynamicProduct();
|
|
21
|
+
const dynamicDiscountOffer = usePageStore((s)=>s.dynamicDiscountOffer);
|
|
22
|
+
const totalProduct = useMemo(()=>isDynamicProduct ? dynamicDiscountOffer?.appliedProductCount : productOffers?.length, [
|
|
23
|
+
dynamicDiscountOffer?.appliedProductCount,
|
|
24
|
+
isDynamicProduct,
|
|
19
25
|
productOffers?.length
|
|
20
26
|
]);
|
|
21
27
|
const sortedProductBaseIDs = useMemo(()=>{
|
|
@@ -41,7 +47,14 @@ const PostPurchaseProductOffer = ({ styles, builderAttrs, builderProps, children
|
|
|
41
47
|
const products = useMemo(()=>flattenConnection(productData.data?.products), [
|
|
42
48
|
productData.data?.products
|
|
43
49
|
]);
|
|
44
|
-
const productSortedById =
|
|
50
|
+
const productSortedById = useMemo(()=>{
|
|
51
|
+
return isDynamicProduct && dynamicDiscountOffer?.appliedProductCount ? Array(dynamicDiscountOffer.appliedProductCount).fill(productOfferPlaceholder) : sortedProductBaseIDs?.map((id)=>products?.find((el)=>el?.baseID === id)).filter(Boolean);
|
|
52
|
+
}, [
|
|
53
|
+
isDynamicProduct,
|
|
54
|
+
dynamicDiscountOffer?.appliedProductCount,
|
|
55
|
+
sortedProductBaseIDs,
|
|
56
|
+
products
|
|
57
|
+
]);
|
|
45
58
|
const getStyles = ()=>{
|
|
46
59
|
return {
|
|
47
60
|
...makeStyleResponsive('cg', productOfferColumnGap),
|
|
@@ -3,6 +3,7 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { useCurrentVariant, useProduct, shopifyPriceRounding, useProductOfferDiscount, useFormatMoney, cls } from '@gem-sdk/core';
|
|
4
4
|
import { useMemo } from 'react';
|
|
5
5
|
import Text from '../../text/Text.js';
|
|
6
|
+
import { useDynamicProduct } from '../hooks/useDynamicProduct.js';
|
|
6
7
|
|
|
7
8
|
const PostPurchaseProductPrice = ({ styles, style, builderAttrs, builderProps, children })=>{
|
|
8
9
|
const currentVariant = useCurrentVariant();
|
|
@@ -10,6 +11,7 @@ const PostPurchaseProductPrice = ({ styles, style, builderAttrs, builderProps, c
|
|
|
10
11
|
const price = currentVariant?.price ?? 0;
|
|
11
12
|
const salePrice = currentVariant?.salePrice ?? 0;
|
|
12
13
|
const discount = parseFloat(shopifyPriceRounding(useProductOfferDiscount(), 2));
|
|
14
|
+
const { isDynamicProduct } = useDynamicProduct();
|
|
13
15
|
const priceShow = useMemo(()=>{
|
|
14
16
|
if (!discount) {
|
|
15
17
|
if (styles?.priceType === 'compare') {
|
|
@@ -50,7 +52,7 @@ const PostPurchaseProductPrice = ({ styles, style, builderAttrs, builderProps, c
|
|
|
50
52
|
/*#__PURE__*/ jsx(Text, {
|
|
51
53
|
styles: styles,
|
|
52
54
|
setting: {
|
|
53
|
-
text: moneyFormatted
|
|
55
|
+
text: isDynamicProduct ? '$???' : moneyFormatted
|
|
54
56
|
},
|
|
55
57
|
className: cls({
|
|
56
58
|
'gp-money': styles?.priceType === 'regular',
|
|
@@ -4,6 +4,7 @@ import { useCurrentVariant, useProduct, useQuantity, useProductOfferDiscount, us
|
|
|
4
4
|
import { useMemo, useState, useEffect, Fragment as Fragment$1 } from 'react';
|
|
5
5
|
import { postPurchaseSpacing } from '../../utils/helper.js';
|
|
6
6
|
import MoneyLine from './priceBreakdown/MoneyLine.js';
|
|
7
|
+
import { useDynamicProduct } from '../hooks/useDynamicProduct.js';
|
|
7
8
|
|
|
8
9
|
const PostPurchaseProductPriceBreakdown = ({ setting = {}, styles = {}, style, builderAttrs, builderProps, children })=>{
|
|
9
10
|
const currentVariant = useCurrentVariant();
|
|
@@ -18,6 +19,7 @@ const PostPurchaseProductPriceBreakdown = ({ setting = {}, styles = {}, style, b
|
|
|
18
19
|
const discountShopifyFormat = shopifyPriceRounding(discountWithQuantity, 2);
|
|
19
20
|
const totalMoneyFormatted = useFormatMoney(subTotal - parseFloat(discountShopifyFormat), false);
|
|
20
21
|
const currentProductId = currentProduct?.baseID?.replace('gid://shopify/Product/', '');
|
|
22
|
+
const { isDynamicProduct, dynamicPrice, dynamicDiscount, isEnableDynamicDiscount } = useDynamicProduct();
|
|
21
23
|
const { labelStyle, moneyStyle, spacing, width, align, isShowPrice } = styles;
|
|
22
24
|
const itemGap = useMemo(()=>{
|
|
23
25
|
return postPurchaseSpacing[spacing || 'none'];
|
|
@@ -30,19 +32,19 @@ const PostPurchaseProductPriceBreakdown = ({ setting = {}, styles = {}, style, b
|
|
|
30
32
|
}, [
|
|
31
33
|
isShowPrice
|
|
32
34
|
]);
|
|
33
|
-
const
|
|
35
|
+
const getMoneyLines = ()=>{
|
|
34
36
|
const data = [];
|
|
35
37
|
if (styles.isShowSubTotalLabel !== false) {
|
|
36
38
|
data.push({
|
|
37
39
|
title: setting.subTotalLabel,
|
|
38
|
-
money: subTotalMoneyFormatted,
|
|
40
|
+
money: isDynamicProduct ? dynamicPrice : subTotalMoneyFormatted,
|
|
39
41
|
uniqueId: 'subTotalLabel'
|
|
40
42
|
});
|
|
41
43
|
}
|
|
42
44
|
if (styles.isShowDiscountLabel !== false) {
|
|
43
45
|
data.push({
|
|
44
46
|
title: setting.discountLabel,
|
|
45
|
-
money: discount > 0 ? discountMoneyFormatted : 'No discount',
|
|
47
|
+
money: isDynamicProduct && dynamicDiscount && isEnableDynamicDiscount ? `${dynamicDiscount.value}%` : discount > 0 ? discountMoneyFormatted : 'No discount',
|
|
46
48
|
uniqueId: 'discountLabel'
|
|
47
49
|
});
|
|
48
50
|
}
|
|
@@ -68,25 +70,11 @@ const PostPurchaseProductPriceBreakdown = ({ setting = {}, styles = {}, style, b
|
|
|
68
70
|
}
|
|
69
71
|
data.push({
|
|
70
72
|
title: setting.totalLabel,
|
|
71
|
-
money: totalMoneyFormatted,
|
|
73
|
+
money: isDynamicProduct ? dynamicPrice : totalMoneyFormatted,
|
|
72
74
|
uniqueId: 'totalLabel'
|
|
73
75
|
});
|
|
74
76
|
return data;
|
|
75
|
-
}
|
|
76
|
-
discount,
|
|
77
|
-
discountMoneyFormatted,
|
|
78
|
-
setting.discountLabel,
|
|
79
|
-
setting.shippingLabel,
|
|
80
|
-
setting.subTotalLabel,
|
|
81
|
-
setting.taxesLabel,
|
|
82
|
-
setting.totalLabel,
|
|
83
|
-
styles.isShowSubTotalLabel,
|
|
84
|
-
styles.isShowDiscountLabel,
|
|
85
|
-
styles.isShowShippingLabel,
|
|
86
|
-
styles.isShowTaxesLabel,
|
|
87
|
-
subTotalMoneyFormatted,
|
|
88
|
-
totalMoneyFormatted
|
|
89
|
-
]);
|
|
77
|
+
};
|
|
90
78
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
91
79
|
children: [
|
|
92
80
|
/*#__PURE__*/ jsxs("div", {
|
|
@@ -137,9 +125,9 @@ const PostPurchaseProductPriceBreakdown = ({ setting = {}, styles = {}, style, b
|
|
|
137
125
|
...makeStyleResponsive('w', width),
|
|
138
126
|
gap: itemGap
|
|
139
127
|
},
|
|
140
|
-
children:
|
|
128
|
+
children: getMoneyLines().map((item)=>/*#__PURE__*/ jsxs(Fragment$1, {
|
|
141
129
|
children: [
|
|
142
|
-
item.uniqueId === 'totalLabel' &&
|
|
130
|
+
item.uniqueId === 'totalLabel' && getMoneyLines().length > 1 && /*#__PURE__*/ jsx("hr", {}),
|
|
143
131
|
/*#__PURE__*/ jsx("div", {
|
|
144
132
|
children: /*#__PURE__*/ jsx(MoneyLine, {
|
|
145
133
|
uniqueId: item.uniqueId,
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
const productOfferPlaceholder = {
|
|
2
|
+
id: '',
|
|
3
|
+
title: 'Dynamic product',
|
|
4
|
+
description: 'This is a dynamic product. The actual product will appear here based on your setup',
|
|
5
|
+
descriptionHtml: '<p class="QN2lPu">This is a dynamic product. The actual product will</p>\n<p class="QN2lPu">appear here based on your setup</p>',
|
|
6
|
+
createdAt: '2024-07-01T04:19:51.286753Z',
|
|
7
|
+
handle: 'dynamic-product',
|
|
8
|
+
averageRating: 0,
|
|
9
|
+
isStorefront: true,
|
|
10
|
+
isSample: false,
|
|
11
|
+
baseID: '',
|
|
12
|
+
sku: '',
|
|
13
|
+
options: [
|
|
14
|
+
{
|
|
15
|
+
id: '1',
|
|
16
|
+
name: 'Variant',
|
|
17
|
+
optionType: '',
|
|
18
|
+
values: [
|
|
19
|
+
{
|
|
20
|
+
id: '1',
|
|
21
|
+
label: 'Variant option',
|
|
22
|
+
isDefault: true,
|
|
23
|
+
baseID: ''
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
vendor: '',
|
|
29
|
+
featuredImage: {
|
|
30
|
+
id: '542178560626918105',
|
|
31
|
+
contentType: 'IMAGE',
|
|
32
|
+
previewImage: '',
|
|
33
|
+
src: 'https://cdn.shopify.com/s/files/1/0858/3168/0279/files/gempages_502328832959710176-312cf60c-d923-4913-9873-66545effe9cc.png',
|
|
34
|
+
width: 449,
|
|
35
|
+
height: 449,
|
|
36
|
+
alt: ''
|
|
37
|
+
},
|
|
38
|
+
collections: {
|
|
39
|
+
edges: [
|
|
40
|
+
{
|
|
41
|
+
node: {
|
|
42
|
+
id: '502321959132988135',
|
|
43
|
+
title: 'Home page'
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
node: {
|
|
48
|
+
id: '539286505089204764',
|
|
49
|
+
title: 'b'
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
node: {
|
|
54
|
+
id: '539286505089401372',
|
|
55
|
+
title: 'e'
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
tags: [],
|
|
61
|
+
medias: {
|
|
62
|
+
edges: [
|
|
63
|
+
{
|
|
64
|
+
cursor: 'gqFpzweGNIc/AALZoXYB',
|
|
65
|
+
node: {
|
|
66
|
+
id: '542178560626918105',
|
|
67
|
+
contentType: 'IMAGE',
|
|
68
|
+
previewImage: '',
|
|
69
|
+
src: 'https://cdn.shopify.com/s/files/1/0858/3168/0279/files/gempages_502328832959710176-312cf60c-d923-4913-9873-66545effe9cc.png',
|
|
70
|
+
width: 449,
|
|
71
|
+
height: 449,
|
|
72
|
+
alt: ''
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
pageInfo: {
|
|
77
|
+
endCursor: 'gqFpzweGNIc/AALZoXYB',
|
|
78
|
+
hasNextPage: true
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
variants: {
|
|
82
|
+
edges: [
|
|
83
|
+
{
|
|
84
|
+
cursor: 'gqFpzwc5ZqRtDAMIoXYC',
|
|
85
|
+
node: {
|
|
86
|
+
id: '520560088328176392',
|
|
87
|
+
title: 'Default Title',
|
|
88
|
+
barcode: '',
|
|
89
|
+
baseID: 'gid://shopify/ProductVariant/49298248925463',
|
|
90
|
+
costPrice: 88,
|
|
91
|
+
height: 0,
|
|
92
|
+
inventoryPolicy: 'DENY',
|
|
93
|
+
inventoryQuantity: 211,
|
|
94
|
+
inventoryStatus: '',
|
|
95
|
+
isDigital: true,
|
|
96
|
+
length: 0,
|
|
97
|
+
lowInventoryAmount: 0,
|
|
98
|
+
manageInventory: false,
|
|
99
|
+
mediaId: '0',
|
|
100
|
+
platform: 'SHOPIFY',
|
|
101
|
+
price: 88,
|
|
102
|
+
salePrice: 88,
|
|
103
|
+
sku: '',
|
|
104
|
+
soldIndividually: false,
|
|
105
|
+
weight: 0,
|
|
106
|
+
width: 0,
|
|
107
|
+
selectedOptions: [],
|
|
108
|
+
media: undefined
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
cursor: 'gqFpzwc5ZqRtDAMIoXYC',
|
|
113
|
+
node: {
|
|
114
|
+
id: '520560088328176392',
|
|
115
|
+
title: 'Default Title',
|
|
116
|
+
barcode: '',
|
|
117
|
+
baseID: 'gid://shopify/ProductVariant/49298248925463',
|
|
118
|
+
costPrice: 88,
|
|
119
|
+
height: 0,
|
|
120
|
+
inventoryPolicy: 'DENY',
|
|
121
|
+
inventoryQuantity: 211,
|
|
122
|
+
inventoryStatus: '',
|
|
123
|
+
isDigital: true,
|
|
124
|
+
length: 0,
|
|
125
|
+
lowInventoryAmount: 0,
|
|
126
|
+
manageInventory: false,
|
|
127
|
+
mediaId: '0',
|
|
128
|
+
platform: 'SHOPIFY',
|
|
129
|
+
price: 88,
|
|
130
|
+
salePrice: 88,
|
|
131
|
+
sku: '',
|
|
132
|
+
soldIndividually: false,
|
|
133
|
+
weight: 0,
|
|
134
|
+
width: 0,
|
|
135
|
+
selectedOptions: [],
|
|
136
|
+
media: undefined
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
pageInfo: {
|
|
141
|
+
hasNextPage: false,
|
|
142
|
+
endCursor: 'gaFpzwc5ZqRtDAMI'
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export { productOfferPlaceholder };
|