-
Notifications
You must be signed in to change notification settings - Fork 13
/
store product detail variant title selected add.html
125 lines (65 loc) · 2.73 KB
/
store product detail variant title selected add.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
120
121
122
123
124
125
<!--
begin store product detail variant title selected add
License : < https://tinyurl.com/s872fb68 >
Version : 0.1.0
SS Version : 7.1
Dependencies : twcsl
By : Thomas Creedon < http://www.tomsWeb.consulting/ >
-->
<script>
if ( window.twc == undefined ) window.twc = { };
twc.spdvtsa = {
options : [
/*
the format of each line is a variant option. use exactly what you
entered in the product editor UI
following is an example line. copy the example line below and paste
after the example line. remove '// ' at beginning of pasted line.
repeat for as many variant options where you want the effect applied.
this has been done once for your initially
*/
// '[enter variant option here between single quotes replacing square brackets]',
'[enter variant option here between single quotes replacing square brackets]',
]
};
</script>
<!-- do not change anything below, there be the borg here -->
<style>
.twc-spdvtsa {
font-style : italic;
}
</style>
<script>
$( ( ) => {
const title = 'Store Product Detail Variant Title Selected Add';
const version = '0.1.0';
const s = `${ title } v${ version }, ` +
'License < https://tinyurl.com/s872fb68 >, ' +
'Tom\'s Web Consulting < http://www.tomsWeb.consulting >';
console.log ( s );
if ( ! twcsl.page.store.detail.is ) return; // bail if not detail
const codeKey = 'twc-spdvtsa';
const options = twc.spdvtsa.options;
const selectorTitle = '.variant-option-title';
const selectorPrefix = `${ selectorTitle }:contains(`;
const selectorSuffix = ': )';
const span = `<span class="${ codeKey }"/>`;
const selector = selectorPrefix
+
options
.join ( `${ selectorSuffix }, ${ selectorPrefix }` )
+
selectorSuffix;
$( selector )
.append ( span )
.parent ( )
.on ( 'change', function ( event ) {
const selector = `.${ codeKey }`;
const $target = $( event.target );
const value = $target.val ( );
$( selector, this )
.text ( value );
} );
} );
</script>
<!-- end store product detail variant title selected add -->