Repository: chec/commercejs-chopchop-demo
Branch: main
Commit: 9ff079217bdc
Files: 54
Total size: 81.5 KB
Directory structure:
gitextract_jvvou8o_/
├── .babelrc
├── .chec.json
├── .editorconfig
├── .gitignore
├── LICENSE.md
├── README.md
├── components/
│ ├── Breadcrumbs.js
│ ├── Button.js
│ ├── Cart.js
│ ├── CartItem.js
│ ├── CartSummary.js
│ ├── Checkout/
│ │ ├── AddressFields.js
│ │ ├── BillingForm.js
│ │ ├── Checkout.js
│ │ ├── CheckoutSummary.js
│ │ ├── ExtraFieldsForm.js
│ │ ├── OrderSummary.js
│ │ ├── ShippingForm.js
│ │ ├── Success.js
│ │ └── index.js
│ ├── Footer.js
│ ├── Form/
│ │ ├── FormCheckbox.js
│ │ ├── FormError.js
│ │ ├── FormInput.js
│ │ ├── FormSelect.js
│ │ ├── FormTextarea.js
│ │ └── index.js
│ ├── Header.js
│ ├── Layout.js
│ ├── Modal.js
│ ├── Product.js
│ ├── ProductAttributes.js
│ ├── ProductGrid.js
│ ├── ProductImages.js
│ ├── ProductList.js
│ ├── RelatedProducts.js
│ └── VariantPicker.js
├── context/
│ ├── cart.js
│ ├── checkout.js
│ ├── modal.js
│ └── theme.js
├── lib/
│ ├── commerce.js
│ └── gtag.js
├── next.config.js
├── package.json
├── pages/
│ ├── _app.js
│ ├── _document.js
│ ├── index.js
│ └── products/
│ └── [permalink].js
├── postcss.config.js
├── seeds/
│ ├── assets.json
│ ├── categories.json
│ └── products.json
└── tailwind.config.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .babelrc
================================================
{
"presets": ["next/babel"],
"plugins": ["inline-react-svg"]
}
================================================
FILE: .chec.json
================================================
{
"npm": "npm",
"buildScripts": ["seed", "dev"],
"dotenv": {
"NODE_ENV": "development",
"NEXT_PUBLIC_CHEC_PUBLIC_API_KEY": "%chec_pkey%",
"CHEC_API_URL": "%chec_api_url%",
"CHEC_SECRET_KEY": "%chec_skey%"
}
}
================================================
FILE: .editorconfig
================================================
# For more information about the properties used in this file,
# please see the EditorConfig documentation:
# http://editorconfig.org
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.{yml,js,json,css,scss,feature,eslintrc}]
indent_size = 2
================================================
FILE: .gitignore
================================================
# Build output
.next
# Environment variables
.env
# Dependency directories
node_modules
# Logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Misc
.vercel
================================================
FILE: LICENSE.md
================================================
Copyright (c) 2021 Chec Platform LLC, All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3) Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
================================================
FILE: README.md
================================================
A Next.js, Commerce.js, Stripe, and Vercel powered, open source storefront, cart and checkout experience.
## Introduction
ChopChop is our beautifully designed, elegantly developed demo store and starter kit that sells fine tools for thoughtful cooks. We’ve created a premium brand with a commerce experience to match. Read more about this resource on the [Commerce.js blog](https://commercejs.com/blog/chopchop-nextjs-starter-commerce/).
## 🥞 ChopChop Stack
* [Next.js](https://nextjs.org/)
* [Commerce.js](https://commercejs.com)
* [Tailwind CSS](https://tailwindcss.com/)
* [Stripe](https://stripe.com)
* [Vercel](https://vercel.com/)
## Live demo
Check out https://commercejs-chopchop-demo.vercel.app to see this project in action.
## Getting started
### Prerequisites
- IDE or code editor of your choice
- Node (v12 or higher)
- NPM or Yarn
- Optional: [Chec CLI](https://github.com/chec/cli)
### Use the Chec CLI
You can use the [Chec CLI](https://github.com/chec/cli) to quickly and easily install demo stores like this, and also
to install sample data into your account. To install the Chec CLI, run `npm install -g @chec/cli` (or `yarn global add @chec/cli`).
* Navigate to your projects folder: `cd ~/Projects`
* Install the ChopChop demo store: `chec demo-store`
* Choose "Chop Chop demo store (Next.js)" from the list
* This will install dependencies and sample data, then start your dev server
* Stop the server, open `.env` and add your `NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY` for using Stripe, then re-run `npm run dev`
* Open [http://localhost:3000](http://localhost:3000) and get started!
### Manual installation
Clone the project, then get started by installing the dependencies, creating a `.env` file, and starting the dev server.
```
npm install
cp .env.example .env
npm run dev
```
Once the server is running, open it up in your browser, start editing the code, and enjoy!
### Sample data
This repository comes with some sample products and images for you to use if you want to get up and running quickly.
To install sample data, first copy `.env.example` to `.env`, then edit `.env` and fill out the
following variables:
* `NEXT_PUBLIC_CHEC_PUBLIC_API_KEY`: Your Chec public/sandbox API key, available from the Chec Dashboard under
Developers > API keys
* `NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY`: Your Stripe test publishable key, available from the Stripe dashboard
* `CHEC_SECRET_KEY`: Your Chec secret API key, used for seeding
* `NEXT_PUBLIC_GA_TRACKING_ID`: Set this with your Google Analytics ID if you want to enable GA.
Once this is done, save and close your file. You can now run the seeder to install sample data:
```
npm run seed
...
✔ Completed seeding
Added:
3 categories
6 products
9 assets
```
And you're ready to go!
### Deploying to Vercel (with one click)
The one-click deploy allows you to add the Vercel application to your GitHub account to clone this repository and deploy it automatically. Be sure to go to [Vercel](https://vercel.com/signup) and sign up for an account with Github, GitLab, or GitBucket before clicking the deploy button.
[](https://vercel.com/new/project?template=https://github.com/chec/commercejs-chopchop-demo)
Please make sure that you enter the required environment variables listed above during deployment.
#### Caveats for sample data
To make your ChopChop experience even better, there are a couple of things you can do that are not included with
the sample data:
* **Add related products:** Go into the [Chec Dashboard](https://dashboard.chec.io) and set related products for each
of your new products. This helps to provide upsell suggestions on your website.
* **Set up shipping rates:** Also in the dashboard, set up some shipping zones and rates in Settings > Shipping, then
enable them on each of your products. This will enable the "Shipping" checkout screen, and allow you to charge
shipping for your customers as well.
## Customizations and Extendability
- Integrate another payment gateway, either one of our supported gateways or your own with our [manual gateway API](https://commercejs.com/docs/guides/manual-payment-integration)
- Integrate with the Google Calendar API to automatically add ticketed items to a customer’s calendars
- Suggest products from other sources based on items purchased, i.e. a book on knife skills if you buy the knife set
- Add [Algolia](https://www.algolia.com/) for integrated search
- Add additional modules to the checkout flow to handle other content types, like booking a time to pickup in-store purchases
- Integrate with a headless CMS to make the content editable
- Create a customers login section using our [customers endpoint](https://commercejs.com/docs/api/#customers)
- Use webhooks to deliver SMS notifications about orders
## License
This project is licensed under [BSD-3-Clause](LICENSE.md).
## ⚠️ Note
### This repository is no longer maintained
However, we will accept issue reports and contributions for this repository. See the [contribute to the commerce community](https://commercejs.com/docs/community/contribute) page for more information on how to contribute to our open source projects. For update-to-date APIs, please check the latest version of the [API documentation](https://commercejs.com/docs/api/).
================================================
FILE: components/Breadcrumbs.js
================================================
import { useCheckoutState } from "../context/checkout";
// TODO: Build array of crumbs dynamically from available steps
function Breadcrumbs({ inCart }) {
const { currentStep, extrafields } = useCheckoutState();
if (inCart) {
return Shopping Bag;
}
if (currentStep === "success") {
return Order received;
}
return (
);
}
export default ShippingForm;
================================================
FILE: components/Checkout/Success.js
================================================
import Image from 'next/image';
function Success({ has }) {
return (
Thanks!
{has.digital_fulfillment
? "You’ll receive an email with your receipt, and a backup link to re-download your purchase"
: "You’ll receive an email with your receipt, and tracking information."}
...if it did, we'd offer you a 100% real store credit, but since it doesn't, we'd love for you to check out commercejs.com and the repo for this store instead.
);
}
export default FormTextarea;
================================================
FILE: components/Form/index.js
================================================
export { default as FormInput } from "./FormInput";
export { default as FormTextarea } from "./FormTextarea";
export { default as FormCheckbox } from "./FormCheckbox";
export { default as FormSelect } from "./FormSelect";
export { default as FormError } from "./FormError";
================================================
FILE: components/Header.js
================================================
import Link from "next/link";
import CartSummary from "./CartSummary";
import LogoSVG from "../svg/logo.svg";
function Header() {
return (
);
}
export default ProductPage;
================================================
FILE: postcss.config.js
================================================
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
================================================
FILE: seeds/assets.json
================================================
[
{
"link": "products[5].id",
"filename": "ChopChop_Tote.jpg",
"url": "https://cdn.chec.io/merchants/19303/assets/X1HxOcELkPfQBY22_ChopChop_Tote.jpg"
},
{
"link": "products[4].id",
"filename": "Kitchen-Sink-Journal-1.jpg",
"url": "https://cdn.chec.io/merchants/19303/assets/9yI6YD9osPkZqmXC_Kitchen-Sink-Journal-1.jpg"
},
{
"link": "products[3].id",
"filename": "italic-rqWlTD5GwKc-unsplash-1.jpg",
"url": "https://cdn.chec.io/merchants/19303/assets/italic-rqWlTD5GwKc-unsplash%201.jpg"
},
{
"link": "products[3].id",
"filename": "dutch-oven-recolor-green.jpg",
"url": "https://cdn.chec.io/merchants/19303/assets/fhEBFIGPSx4jXhEJ_dutch-oven-recolor-green.jpg"
},
{
"link": "products[3].id",
"filename": "dutch-oven-recolor-red.jpg",
"url": "https://cdn.chec.io/merchants/19303/assets/VvLWyLKtYa17nQEo_dutch-oven-recolor-red.jpg"
},
{
"link": "products[2].id",
"filename": "italic--wPo52T1z-8-unsplash-1.jpg",
"url": "https://cdn.chec.io/merchants/19303/assets/italic--wPo52T1z-8-unsplash%201.jpg"
},
{
"link": "products[2].id",
"filename": "italic-dGoB5OrHDS0-unsplash-1.jpg",
"url": "https://cdn.chec.io/merchants/19303/assets/italic-dGoB5OrHDS0-unsplash%201.jpg"
},
{
"link": "products[1].id",
"filename": "emy-kOtEYRJspm8-unsplash.jpg",
"url": "https://cdn.chec.io/merchants/19303/assets/emy-kOtEYRJspm8-unsplash.jpg"
},
{
"link": "products[0].id",
"filename": "photo-1594761077961-cadd185540a4-1.jpg",
"url": "https://cdn.chec.io/merchants/19303/assets/photo-1594761077961-cadd185540a4%201.jpg"
}
]
================================================
FILE: seeds/categories.json
================================================
[
{
"slug": "journal",
"name": "Journal"
},
{
"slug": "cooking-class",
"name": "Cooking Class"
},
{
"slug": "cookware",
"name": "Cookware"
}
]
================================================
FILE: seeds/products.json
================================================
[
{
"product": {
"name": "Walnut Cook's Tools",
"description": "Carved by our friends at Mason St. Workshop, these cook’s tools are made to last. We went back and forth for months deliberating on woods, handles and the exact tools to include before landing on the current set of five which includes a spatula, three different spoons and a large ladle.",
"price": "40.00",
"category_id": "categories[2].id"
},
"collect": {
"billing": true,
"fullname": true
},
"seo": {
"title": "Walnut Cook's Tools | ChopChop",
"description": "Carved by our friends at Mason St. Workshop, these cook’s tools are made to last. A set of five which includes a spatula, three different spoons and a large ladle."
}
},
{
"product": {
"name": "Private Cooking Class",
"description": "Learn core skills or advanced techniques in our private cooking classes. Classes run two hours (online or in person at our Brooklyn storefront) and cover a range of recipes, approaches and techniques. Tell us what you want to tackle or learn a classic recipe. Just let us know in the form at checkout.",
"price": "120.00",
"category_id": "categories[1].id"
},
"extra_field": [
{
"name": "Lesson Plan",
"required": false
}
],
"collect": {
"fullname": true
},
"seo": {
"title": "Private Cooking Class | ChopChop",
"description": "Learn core skills or advanced techniques in our private cooking classes. Classes run two hours (online or in person at our Brooklyn storefront) and cover a range of recipes, approaches and techniques."
}
},
{
"product": {
"name": "Essential Knife Set",
"description": "There are a lot of knife sets out there, a lot of them are fine, but they also have a bunch of stuff you probably don’t need. We put together the essential knife set so you can snag exactly what you need to get cooking, no more no less. If you want a slightly different variation just get in touch and let us know, we’re happy to put something custom together for your needs.",
"price": "120.00",
"category_id": "categories[2].id"
},
"collect": {
"billing": true,
"fullname": true
},
"seo": {
"title": "Essential Knife Set | ChopChop",
"description": "We put together the essential knife set so you can snag exactly what you need to get cooking, no more no less."
}
},
{
"product": {
"name": "Ceramic Dutch Oven",
"description": "A colorful, stovetop multi-tool that will outlive you with even the most minimal amount of care, the ceramic coated, cast iron dutch oven is the Coach duffle of stovetop cooking - gorgeous, functional and the envy of literally every penny pinching home cook alive today.",
"price": "250.00",
"category_id": "categories[2].id"
},
"variant": [
{
"name": "Color",
"options": [
{
"description": "Yellow",
"quantity": "0",
"price": "0.00"
},
{
"description": "Green",
"price": "0.00"
},
{
"description": "Red",
"price": "0.00"
}
]
}
],
"collect": {
"billing": true,
"fullname": true
},
"seo": {
"title": "Ceramic Dutch Oven | ChopChop",
"description": "The ceramic coated, cast iron dutch oven is the Coach duffle of stovetop cooking - gorgeous, functional and the envy of literally every penny pinching home cook alive today."
}
},
{
"product": {
"name": "Kitchen Sink Journal",
"description": "Kitchen Sink Journal, our first publication, documents a year of culinary experiments by the Chop Chop team and some friends of the shop. While it includes 41 detailed recipes, in practice we use it more as a reference on how to tackle a given flavor, texture or ingredient. Hopefully you’ll find it just as useful!",
"price": "35.00",
"category_id": "categories[0].id"
},
"collect": {
"billing": true,
"fullname": true
},
"seo": {
"title": "Kitchen Sink Journal | ChopChop",
"description": "Our first publication documents a year of culinary experiments by the Chop Chop team and some friends of the shop. While it includes 41 detailed recipes, in practice we use it more as a reference on how to tackle a given flavor, texture or ingredient."
}
},
{
"product": {
"name": "Tote bag",
"price": "0.00",
"active": false
}
}
]
================================================
FILE: tailwind.config.js
================================================
const defaultTheme = require("tailwindcss/defaultTheme");
module.exports = {
purge: ["./{components,pages}/**/*.js"],
theme: {
extend: {
colors: {
clementine: "#EF7300",
tumbleweed: "#D9A876",
"hawkes-blue": "#C7DDFD",
asparagus: "#789750",
goldenrod: "#FFCE70",
black: "#150703",
"faded-black": "rgba(21,7,3,0.6)",
"ecru-white": "#FAF8F3",
"white-rock": "#E8E0CF",
},
height: {
112: "28rem",
},
rotate: {
'-25': '-25deg',
},
boxShadow: {
'thank-you': '-2.63365px 5.92572px 8.55938px rgba(0, 0, 0, 0.25)',
},
},
fontFamily: {
sans: ["Inter", ...defaultTheme.fontFamily.sans],
serif: ["'EB Garamond'", ...defaultTheme.fontFamily.serif],
},
},
variants: {
extend: {
backgroundColor: ["checked"],
borderColor: ["checked"],
borderRadius: ["hover"],
fontStyle: ["hover"],
textColor: ["checked"],
},
},
};