@@ -12,28 +12,29 @@ The _accept-terms_ plugin is only loaded for the checkout contact information st
12
12
13
13
To enable a plugin add this code to your _ Google Analytics Additional Scripts_ section in Shopify's Admin / Online Store / Preferences.
14
14
15
- ```
16
- (function() {
15
+ ``` javascript
16
+ fetch (
' //cdn.jsdelivr.net/gh/nerdsofalltrades/[email protected] /dist/shopify-plugin-loader.min.js' ).
then (
function (
17
+ result
18
+ ) {
19
+ result .text ().then (function (script ) {
17
20
var plugin = document .createElement (' script' );
18
- plugin.src = '//cdn.jsdelivr.net/gh/nerdsofalltrades/[email protected] /dist/shopify-plugin-loader.min.js' ;
21
+ plugin .innerHTML = script ;
19
22
document .body .appendChild (plugin);
20
23
21
- plugin.onload = function () {
22
- var ctx = window.ShopifyPlugins;
23
-
24
- // Load plugins here
24
+ // Load plugins here
25
+ var ctx = window .ShopifyPlugins ;
25
26
26
- // Load the accept-terms plugin only in checkout
27
- // contact information step
28
- ctx.checkout.contactInformation.load('accept-terms');
27
+ // Load the accept-terms plugin only in checkout
28
+ // contact information step
29
+ ctx .checkout .contactInformation .load (' accept-terms' );
29
30
30
- // Load the progress-bar plugin for all steps
31
- // in checkout
32
- ctx.checkout.all.load('progress-bar');
31
+ // Load the progress-bar plugin for all steps
32
+ // in checkout
33
+ ctx .checkout .all .load (' progress-bar' );
33
34
34
- // Load other plugins here ...
35
- }
36
- })( );
35
+ // Load other plugins...
36
+ });
37
+ } );
37
38
```
38
39
39
40
## Plugins
@@ -45,26 +46,26 @@ Checkbox in Shopify's contact information checkout step.
45
46
46
47
![ Accept terms plugin in action] ( examples/accept-terms/accept-terms.png )
47
48
48
- Add this code to your ` plugin.onload ` function to enable it.
49
+ Add this code to enable it.
49
50
50
- ```
51
+ ``` javascript
51
52
ctx .checkout .contactInformation .load (' accept-terms' );
52
53
```
53
54
54
55
Without options standard english texts are displayed and the url of your terms
55
56
is expected to be found at ` /pages/terms ` . To change that just pass options
56
57
and set it up as you like.
57
58
58
- ```
59
+ ``` javascript
59
60
ctx .checkout .contactInformation .load (' accept-terms' , {
60
61
// The checkbox label
61
- label: " I have read and I agree to the" ,
62
+ label: ' I have read and I agree to the' ,
62
63
// The label of the terms link
63
- termsName: " terms" ,
64
+ termsName: ' terms' ,
64
65
// The url to your terms
65
- termsURL: " /pages/terms" ,
66
+ termsURL: ' /pages/terms' ,
66
67
// Message displayed when customer tries to go on without agreeing
67
- errorMessage: " Please agree to our terms before your purchase"
68
+ errorMessage: ' Please agree to our terms before your purchase'
68
69
});
69
70
```
70
71
@@ -77,15 +78,15 @@ configuration is needed.
77
78
78
79
![ Progress bar plugin in action] ( examples/progress-bar/progress-bar.png )
79
80
80
- Add this code to your ` plugin.onload ` function to enable it.
81
+ Add this code to enable it.
81
82
82
- ```
83
+ ``` javascript
83
84
ctx .checkout .all .load (' progress-bar' );
84
85
```
85
86
86
87
## Development
87
88
88
- ```
89
+ ``` shell
89
90
$ npm install
90
91
$ npm run dev
91
92
```
0 commit comments