-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathstore page detail price total.html
119 lines (60 loc) · 3.07 KB
/
store page detail price total.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<script>
/*
begin store page detail price total
License : < https://tinyurl.com/s872fb68 >
Version : 0.3.0
SS Version : 7.1
Dependencies : store page price change < https://tinyurl.com/5az53zbz >
Copyright : 2021-2024 Thomas Creedon
Tom's Web Consulting < http://www.tomsWeb.consulting/ >
no user serviceable parts below
*/
( ( ) => {
const
version = '0.3.0',
s = `Store Page Detail Price Total v${ version }
License < https://tinyurl.com/s872fb68 >
© 2021-2024 Thomas Creedon
Tom's Web Consulting < http://www.tomsWeb.consulting >`
.replace ( /^\s+/gm, '' );
console.log ( s );
} ) ( );
// initialize twc module
var twc = ( ( self ) => self ) ( window.twc || { } );
// initialize twc sppc sub-module
twc.sppc = ( ( self ) => self ) ( twc.sppc || { } );
// initialize twc sppc callbacks sub-module
twc.sppc.callbacks = ( ( self ) => {
self
.twcSpdpt = ( node, isDetail, text, searchText ) => {
if ( ! isDetail ) return true; // continue if not detail
const isOriginalPrice = Boolean ( $( node )
.parents ( '.original-price' )
.length );
const quantity = Number ( $( '.product-quantity-input input' ).val ( ) );
let selectedVariant = $( '.product-variants' )
.attr ( 'data-selected-variant' );
if ( selectedVariant === undefined ) {
selectedVariant = Static.SQUARESPACE_CONTEXT.product.variants [ 0 ];
price = ! selectedVariant.onSale || ( selectedVariant.onSale &&
isOriginalPrice ) ? selectedVariant.price.value :
selectedVariant.salePrice.value;
price = price / 100;
} else {
selectedVariant = JSON.parse ( selectedVariant );
const b = selectedVariant.unlimited == false &&
selectedVariant.qtyInStock == 0;
if ( b ) return true; // bail if sold out
price = ! selectedVariant.onSale || ( selectedVariant.onSale &&
isOriginalPrice ) ? selectedVariant.priceMoney.value :
selectedVariant.salePriceMoney.value;
price = Number ( price );
}
price = price * quantity;
price = price.toFixed ( 2 );
return price;
};
return self;
} ) ( twc.sppc.callbacks || { } );
// end store page detail price total
</script>