Gathering detailed insights and metrics for nuxt-shopify
Gathering detailed insights and metrics for nuxt-shopify
Gathering detailed insights and metrics for nuxt-shopify
Gathering detailed insights and metrics for nuxt-shopify
@konkonam/nuxt-shopify
Easily integrate shopify into your nuxt 3 & 4 project 🚀
@shopify/cli-kit
A set of utilities, interfaces, and models that are common across all the platform features
@shopify/cli
A CLI tool to build for the Shopify platform
@nuxtjs/opencollective
[![npm version][npm-v-src]][npm-v-href] [![npm downloads][npm-d-src]][npm-d-href] [![status][github-actions-src]][github-actions-href]
npm install nuxt-shopify
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
353 Stars
1,280 Commits
29 Forks
6 Watching
19 Branches
3 Contributors
Updated on 20 Oct 2024
TypeScript (38.95%)
Vue (30.88%)
JavaScript (30.17%)
Cumulative downloads
Total Downloads
Last day
6.2%
517
Compared to previous day
Last week
-0.7%
3,322
Compared to previous week
Last month
0%
14,385
Compared to previous month
Last year
155.4%
146,990
Compared to previous year
3
25
Easy Shopify Buy client integration with Nuxt.js
Install with yarn:
1yarn add nuxt-shopify
Install with npm:
1npm install nuxt-shopify
nuxt.config.js
1module.exports = { 2 modules: ['nuxt-shopify'], 3 4 shopify: { 5 /** 6 * Your shopify domain 7 */ 8 domain: 'your-shop-name.myshopify.com', 9 10 /** 11 * Your shopify storefront access token 12 */ 13 storefrontAccessToken: 'your-storefront-access-token', 14 15 /** 16 * This will be larger than the optimized version, as it will contain all fields that are available in the 17 * Storefront API. (https://help.shopify.com/en/api/custom-storefronts/storefront-api/reference) 18 * This should only be used when you need to add custom queries to supplement the JS Buy SDK queries. 19 */ 20 unoptimized: false, 21 22 /** 23 * Set language to return translated content (optional) 24 */ 25 language: 'ja-JP', 26 }, 27};
OR
1module.exports = { 2 modules: ['nuxt-shopify'], 3 4 env: { 5 SHOPIFY_DOMAIN: 'your-shop-name.myshopify.com', // your shopify domain 6 SHOPIFY_ACCESS_TOKEN: 'your-storefront-access-token', // your shopify storefront access token 7 }, 8};
Don't have a Storefront Access Token yet? Get started.
asyncData
1async asyncData({ $shopify, params }) { 2 const product = await $shopify.product.fetch(params.id); 3 return { product }; 4}
methods
/created
/mounted
/etc
1methods: { 2 async fetchProduct(productId) { 3 this.product = await this.$shopify.product.fetch(productId); 4 } 5}
nuxtServerInit
)1// In store 2{ 3 actions: { 4 async fetchAllProducts ({ commit }) { 5 const products = await this.$shopify.product.fetchAll(); 6 commit('SET_PRODUCTS', products) 7 } 8 } 9}
Examples from the official shopify-buy sdk library
1// Fetch all products in your shop 2this.$shopify.product.fetchAll().then((products) => { 3 // Do something with the products 4 console.log(products); 5}); 6 7// Fetch a single product by ID 8const productId = 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc4NTc5ODkzODQ='; 9 10this.$shopify.product.fetch(productId).then((product) => { 11 // Do something with the product 12 console.log(product); 13});
1// Fetch all collections, including their products 2this.$shopify.collection.fetchAllWithProducts().then((collections) => { 3 // Do something with the collections 4 console.log(collections); 5 console.log(collections[0].products); 6}); 7 8// Fetch a single collection by ID, including its products 9const collectionId = 'Z2lkOi8vc2hvcGlmeS9Db2xsZWN0aW9uLzM2OTMxMjU4NA=='; 10 11this.$shopify.collection.fetchWithProducts(collectionId).then((collection) => { 12 // Do something with the collection 13 console.log(collection); 14 console.log(collection.products); 15});
1// Create an empty checkout 2this.$shopify.checkout.create().then((checkout) => { 3 // Do something with the checkout 4 console.log(checkout); 5});
1const checkoutId = 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0SW1hZ2UvMTgyMTc3ODc1OTI='; // ID of an existing checkout 2const lineItemsToAdd = [ 3 { 4 variantId: 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yOTEwNjAyMjc5Mg==', 5 quantity: 5, 6 customAttributes: [{ key: 'MyKey', value: 'MyValue' }], 7 }, 8]; 9 10// Add an item to the checkout 11this.$shopify.checkout.addLineItems(checkoutId, lineItemsToAdd).then((checkout) => { 12 // Do something with the updated checkout 13 console.log(checkout.lineItems); // Array with one additional line item 14});
1const checkoutId = 'Z2lkOi8vc2hvcGlmeS9DaGVja291dC9kMTZmM2EzMDM4Yjc4N='; 2const input = { customAttributes: [{ key: 'MyKey', value: 'MyValue' }] }; 3 4this.$shopify.checkout.updateAttributes(checkoutId, input).then((checkout) => { 5 // Do something with the updated checkout 6});
1const checkoutId = 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0SW1hZ2UvMTgyMTc3ODc1OTI='; // ID of an existing checkout 2const lineItemsToUpdate = [{ id: 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc4NTc5ODkzODQ=', quantity: 2 }]; 3 4// Update the line item on the checkout (change the quantity or variant) 5this.$shopify.checkout.updateLineItems(checkoutId, lineItemsToUpdate).then((checkout) => { 6 // Do something with the updated checkout 7 console.log(checkout.lineItems); // Quantity of line item 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc4NTc5ODkzODQ=' updated to 2 8});
1const checkoutId = 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0SW1hZ2UvMTgyMTc3ODc1OTI='; // ID of an existing checkout 2const lineItemIdsToRemove = ['Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc4NTc5ODkzODQ=']; 3 4// Remove an item from the checkout 5this.$shopify.checkout.removeLineItems(checkoutId, lineItemIdsToRemove).then((checkout) => { 6 // Do something with the updated checkout 7 console.log(checkout.lineItems); // Checkout with line item 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc4NTc5ODkzODQ=' removed 8});
1const checkoutId = '2U4NWNkYzI4ZWEyOTdlOD9rZXk9MDVjMzY3Zjk3YWM0YWJjNGRhMTkwMDgwYTUzOGJmYmI='; 2 3this.$shopify.checkout.fetch(checkoutId).then((checkout) => { 4 // Do something with the checkout 5 console.log(checkout); 6});
1const checkoutId = 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0SW1hZ2UvMTgyMTc3ODc1OTI='; // ID of an existing checkout 2const discountCode = 'best-discount-ever'; 3 4// Add a discount code to the checkout 5this.$shopify.checkout.addDiscount(checkoutId, discountCode).then((checkout) => { 6 // Do something with the updated checkout 7 console.log(checkout); 8});
1const checkoutId = 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0SW1hZ2UvMTgyMTc3ODc1OTI='; // ID of an existing checkout 2 3// Removes the applied discount from an existing checkout. 4this.$shopify.checkout.removeDiscount(checkoutId).then((checkout) => { 5 // Do something with the updated checkout 6 console.log(checkout); 7});
1const checkoutId = 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0SW1hZ2UvMTgyMTc3ODc1OTI='; // ID of an existing checkout 2 3const shippingAddress = { 4 address1: 'Chestnut Street 92', 5 address2: 'Apartment 2', 6 city: 'Louisville', 7 company: null, 8 country: 'United States', 9 firstName: 'Bob', 10 lastName: 'Norman', 11 phone: '555-625-1199', 12 province: 'Kentucky', 13 zip: '40202', 14}; 15 16// Update the shipping address for an existing checkout. 17this.$shopify.checkout.updateShippingAddress(checkoutId, shippingAddress).then((checkout) => { 18 // Do something with the updated checkout 19});
yarn install
or npm install
yarn build
or npm run build
yarn dev
or npm run dev
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
Found 0/29 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
44 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More