@gem-sdk/components 12.0.0-dev.43 → 12.0.0-dev.45
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.
|
@@ -7,20 +7,47 @@
|
|
|
7
7
|
</div>
|
|
8
8
|
<script>
|
|
9
9
|
const moneyFormatGp = {{ shop.money_format | json }};
|
|
10
|
+
|
|
11
|
+
const formatCurrency = (cents, format) => {
|
|
12
|
+
if (typeof Shopify !== 'undefined' && Shopify.formatMoney) {
|
|
13
|
+
return Shopify.formatMoney(cents, format);
|
|
14
|
+
}
|
|
15
|
+
return (cents / 100).toFixed(2);
|
|
16
|
+
};
|
|
17
|
+
|
|
10
18
|
document.addEventListener('DOMContentLoaded', function() {
|
|
11
|
-
document.addEventListener('sealsubs:
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
document.addEventListener('sealsubs:selling_plan_changed', function(e) {
|
|
20
|
+
const productWrapper = e.detail?.element?.closest('gp-product');
|
|
21
|
+
if (!productWrapper) return;
|
|
22
|
+
|
|
23
|
+
const comparePriceContainers = productWrapper.querySelectorAll('gp-product-price');
|
|
24
|
+
const hasSellingPlan = !!e.detail.selling_plan_id;
|
|
25
|
+
|
|
26
|
+
comparePriceContainers.forEach(container => {
|
|
27
|
+
if (!hasSellingPlan) {
|
|
28
|
+
container.style.removeProperty('display');
|
|
29
|
+
} else {
|
|
30
|
+
container.style.setProperty('display', 'block', 'important');
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
document.addEventListener('sealsubs:price_update', function(e) {
|
|
36
|
+
const detail = e.detail;
|
|
37
|
+
const productWrapper = detail?.element?.closest('gp-product');
|
|
38
|
+
if (!productWrapper) return;
|
|
39
|
+
|
|
40
|
+
const gpPriceElement = productWrapper.querySelector('gp-product-price .gp-price.gp-money');
|
|
41
|
+
const compareAtPriceElement = productWrapper.querySelector('gp-product-price .gp-product-compare-price');
|
|
15
42
|
|
|
16
|
-
if (gpPriceElement) {
|
|
17
|
-
gpPriceElement.innerHTML =
|
|
43
|
+
if (gpPriceElement && typeof detail.price !== 'undefined') {
|
|
44
|
+
gpPriceElement.innerHTML = formatCurrency(detail.price, moneyFormatGp);
|
|
18
45
|
}
|
|
19
46
|
|
|
20
47
|
if (compareAtPriceElement) {
|
|
21
|
-
const compareAtPrice =
|
|
48
|
+
const compareAtPrice = detail?.compareAtPrice || 0;
|
|
22
49
|
setTimeout(function() {
|
|
23
|
-
compareAtPriceElement.innerHTML =
|
|
50
|
+
compareAtPriceElement.innerHTML = formatCurrency(compareAtPrice, moneyFormatGp);
|
|
24
51
|
});
|
|
25
52
|
}
|
|
26
53
|
});
|
|
@@ -1,26 +1,53 @@
|
|
|
1
|
-
import{template as e,makeStyleResponsive as t}from"@gem-sdk/core";let SealSubscriptions=({setting:r,advanced:o})=>{let{align:
|
|
1
|
+
import{template as e,makeStyleResponsive as t}from"@gem-sdk/core";let SealSubscriptions=({setting:r,advanced:o})=>{let{align:n}=r??{};return e`
|
|
2
2
|
<div
|
|
3
3
|
class="${o?.cssClass}"
|
|
4
|
-
style="${{...t("ta",
|
|
4
|
+
style="${{...t("ta",n)}}"
|
|
5
5
|
>
|
|
6
6
|
<div class="sealsubs-target-element" data-handle="{{ product.handle }}"></div>
|
|
7
7
|
</div>
|
|
8
8
|
<script>
|
|
9
9
|
const moneyFormatGp = {{ shop.money_format | json }};
|
|
10
|
+
|
|
11
|
+
const formatCurrency = (cents, format) => {
|
|
12
|
+
if (typeof Shopify !== 'undefined' && Shopify.formatMoney) {
|
|
13
|
+
return Shopify.formatMoney(cents, format);
|
|
14
|
+
}
|
|
15
|
+
return (cents / 100).toFixed(2);
|
|
16
|
+
};
|
|
17
|
+
|
|
10
18
|
document.addEventListener('DOMContentLoaded', function() {
|
|
11
|
-
document.addEventListener('sealsubs:
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
document.addEventListener('sealsubs:selling_plan_changed', function(e) {
|
|
20
|
+
const productWrapper = e.detail?.element?.closest('gp-product');
|
|
21
|
+
if (!productWrapper) return;
|
|
22
|
+
|
|
23
|
+
const comparePriceContainers = productWrapper.querySelectorAll('gp-product-price');
|
|
24
|
+
const hasSellingPlan = !!e.detail.selling_plan_id;
|
|
25
|
+
|
|
26
|
+
comparePriceContainers.forEach(container => {
|
|
27
|
+
if (!hasSellingPlan) {
|
|
28
|
+
container.style.removeProperty('display');
|
|
29
|
+
} else {
|
|
30
|
+
container.style.setProperty('display', 'block', 'important');
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
document.addEventListener('sealsubs:price_update', function(e) {
|
|
36
|
+
const detail = e.detail;
|
|
37
|
+
const productWrapper = detail?.element?.closest('gp-product');
|
|
38
|
+
if (!productWrapper) return;
|
|
39
|
+
|
|
40
|
+
const gpPriceElement = productWrapper.querySelector('gp-product-price .gp-price.gp-money');
|
|
41
|
+
const compareAtPriceElement = productWrapper.querySelector('gp-product-price .gp-product-compare-price');
|
|
15
42
|
|
|
16
|
-
if (gpPriceElement) {
|
|
17
|
-
gpPriceElement.innerHTML =
|
|
43
|
+
if (gpPriceElement && typeof detail.price !== 'undefined') {
|
|
44
|
+
gpPriceElement.innerHTML = formatCurrency(detail.price, moneyFormatGp);
|
|
18
45
|
}
|
|
19
46
|
|
|
20
47
|
if (compareAtPriceElement) {
|
|
21
|
-
const compareAtPrice =
|
|
48
|
+
const compareAtPrice = detail?.compareAtPrice || 0;
|
|
22
49
|
setTimeout(function() {
|
|
23
|
-
compareAtPriceElement.innerHTML =
|
|
50
|
+
compareAtPriceElement.innerHTML = formatCurrency(compareAtPrice, moneyFormatGp);
|
|
24
51
|
});
|
|
25
52
|
}
|
|
26
53
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/components",
|
|
3
|
-
"version": "12.0.0-dev.
|
|
3
|
+
"version": "12.0.0-dev.45",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"i18n:generate": "node ./scripts/update-locales-to-setting.js"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@gem-sdk/core": "12.0.0-dev.
|
|
31
|
-
"@gem-sdk/styles": "12.0.0-dev.
|
|
32
|
-
"@gem-sdk/system": "12.0.0-dev.
|
|
30
|
+
"@gem-sdk/core": "12.0.0-dev.44",
|
|
31
|
+
"@gem-sdk/styles": "12.0.0-dev.44",
|
|
32
|
+
"@gem-sdk/system": "12.0.0-dev.44",
|
|
33
33
|
"@types/react-transition-group": "^4.4.12",
|
|
34
34
|
"tsup": "8.5.1",
|
|
35
35
|
"postcss-import": "16.1.1",
|