Commit 1894171 1 parent 17b8352 commit 1894171 Copy full SHA for 1894171
File tree 1 file changed +55
-1
lines changed
1 file changed +55
-1
lines changed Original file line number Diff line number Diff line change
1
+ < html >
2
+ < head >
3
+ < title >
4
+ Test Page
5
+ </ title >
6
+ </ head >
7
+ < body >
1
8
2
- Index page
9
+
10
+ < script >
11
+ ( function ( ) {
12
+ // Helper to check if we're on checkout/thank you pages
13
+ const isCheckoutPage = window . location . pathname . includes ( '/checkout' ) ;
14
+ const isThankYouPage = window . location . pathname . includes ( '/thank_you' ) ;
15
+
16
+ // Don't load on regular checkout pages
17
+ if ( isCheckoutPage && ! isThankYouPage ) {
18
+ return ;
19
+ }
20
+
21
+ // Function to initialize the widget
22
+ const initializeWidget = ( ) => {
23
+ // Add CSS first
24
+ const link = document . createElement ( 'link' ) ;
25
+ link . rel = 'stylesheet' ;
26
+ link . href = 'https://feedbackstack.test/js/core/style.css' ;
27
+ document . head . appendChild ( link ) ;
28
+
29
+ // Then load JS
30
+ const script = document . createElement ( 'script' ) ;
31
+ script . src = `https://feedbackstack.test/js/core/script.js?token=b19bf05984da4b073b378ba2dc3ec0b5e941ea42e0bdaf52cebe7a9051396fd2&shop=${ window . location . host } ` ;
32
+ script . onload = function ( ) {
33
+ if ( typeof FeedbackWidget === 'function' ) {
34
+ FeedbackWidget ( ) ;
35
+ }
36
+ } ;
37
+ document . body . appendChild ( script ) ;
38
+ } ;
39
+
40
+ // If on thank you page, wait for Shopify's checkout to be ready
41
+ if ( isThankYouPage ) {
42
+ // Wait for Shopify's checkout object to be fully initialized
43
+ const waitForCheckout = setInterval ( ( ) => {
44
+ if ( window . Shopify && window . Shopify . checkout ) {
45
+ clearInterval ( waitForCheckout ) ;
46
+ setTimeout ( initializeWidget , 1000 ) ; // Add a small delay after checkout is ready
47
+ }
48
+ } , 100 ) ;
49
+ } else {
50
+ // Regular page, initialize normally
51
+ initializeWidget ( ) ;
52
+ }
53
+ } ) ( ) ;
54
+ </ script >
55
+ </ body >
56
+ </ html >
You can’t perform that action at this time.
0 commit comments