You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+22-23
Original file line number
Diff line number
Diff line change
@@ -20,14 +20,7 @@
20
20
1. Add `@nuxtjs/snipcart` dependency to your project
21
21
22
22
```bash
23
-
# Using pnpm
24
-
pnpm add -D @nuxtjs/snipcart
25
-
26
-
# Using yarn
27
-
yarn add --dev @nuxtjs/snipcart
28
-
29
-
# Using npm
30
-
npm install --save-dev @nuxtjs/snipcart
23
+
npx nuxi@latest module add snipcart
31
24
```
32
25
33
26
2. Add `@nuxtjs/snipcart` to the `modules` section of `nuxt.config.ts`
@@ -52,25 +45,34 @@ At any time please have a look at our beautiful playground example.
52
45
53
46
We tried to not create too much wrapper around the Snipcart api so we don't have to maintain so much if Snipcart change. But you may found some of them useful as:
54
47
- exposing snipcart instance
55
-
- use of isReady boolean to watch and make sure you can use snipcart instance safely
56
-
- realtime store subscription (working but performance hit)
57
-
- some function in case you are not using the JS SDK form `window.Snipcart` that will help you add html attributes that Snipcart will read on load. As bindProductItem or bindProductItemCustom
58
-
- ability to change language or currency using respectively `setLanguage` or `setCurrency`
48
+
- isReady will define the basic settings are ready to be used but snipcart not loaded yet
49
+
- use watch on snipcart to make sure its ready
50
+
- realtime store subscription
51
+
- utils functions As bindProductItem or bindProductItemCustom
52
+
- wrapper utils function to change language or currency using respectively `setLanguage` or `setCurrency`
59
53
60
54
As we have a full typescript support play with it and read the description of what is exposed.
61
55
62
56
## Loading
63
57
64
58
We are following Snipcart [different loadings](https://docs.snipcart.com/v3/setup/installation). You can control the load of the js using `loadStrategy` configuration property. You can tell snipcart to not load css using `loadCSS` config property.
65
59
66
-
If you load async take in consideration on server or client you will not have access to `window.Snipcart` or `snipcart` exposed by `useSnipcart` until its loaded. So adapt your logic
60
+
If you load async take in consideration you will not have access to `window.Snipcart` or `snipcart` exposed by `useSnipcart` until its loaded. So adapt your logic. Check on playground we have added few comments
With nuxt it is super easy to customize snipart components. Use your own class css in addition of custom html to override [snipcart component](https://docs.snipcart.com/v3/themes/default/reference).
71
65
72
66
To do that create for example `public/snipcart-custom.html` as inside the playground. And make sure you add the path in the nuxt config using `templatesUrl` property
73
67
68
+
```
69
+
snipcart: {
70
+
templatesUrl: '/snipcart-custom.html',
71
+
```
72
+
73
+
this will after be passed to snipcart to understand what file to retrieve to have access to all templates it will use to build snipcart components
As we told before we expose the snipcart SDK as by default with window.Snipcart or form the composable `useSnipcart`. So you will have the exact same full access to snipcart SDK
@@ -79,26 +81,23 @@ As we told before we expose the snipcart SDK as by default with window.Snipcart
0 commit comments