-
Notifications
You must be signed in to change notification settings - Fork 13
/
change unable to add item to cart alert.html
97 lines (51 loc) · 2.4 KB
/
change unable to add item to cart alert.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
<script>
$( ( ) => {
/*
change unable to add item to cart alert
License : < https://tinyurl.com/s872fb68 >
Version : 0.1d2
SS Version : 7.0
Templates : Montauk ( Julia, Kent, Om )
Dependencies : jQuery
Notes : this effect is not active in SS Preview to test it use
private browsing < https://bit.ly/3f6lhq2 >.
By : Thomas Creedon < http://www.tomsWeb.consulting/ >
*/
const data = {
'SQ9043529' : {
message : 'x',
title : null /* null means don't change the title, to change title
replace null with text in single quotes */
}, // notice the comma here
'SQ8187993' : { /* test w */
message : 'Sorry, no space left in this workshop.',
title : null /* null means don't change the title, to change title
replace null with text in single quotes */
}, // notice the comma here
'SQ7187559' : { /* test a */
message : 'Sorry, this piece has been sold.',
title : null /* null means don't change the title, to change title
replace null with text in single quotes */
},
};
// bail if no mutation observer available
if ( ! ( 'MutationObserver' in window ) ) return;
if ( ! $( '#productWrapper' ).length ) return;
const sku = Static.SQUARESPACE_CONTEXT.product.variants [ 0 ].sku;
if ( ! data.hasOwnProperty ( sku ) ) return;
const observer = new MutationObserver ( function ( mutations ) {
$.each ( mutations, function ( mutation ) {
if ( ! this.addedNodes.length ) return false;
let $e = $( this.addedNodes [ 0 ] );
if ( ! $e.hasClass ( 'sqs-widgets-confirmation' ) ) return;
$( '.message', $e ).text ( data [ sku ].message );
if ( data [ sku ].title !== null )
$( '.title', $e ).text ( data [ sku ].title );
} );
} );
// starts listening for changes in body
observer.observe ( document.body, {
childList : true
} );
} );
</script>