• This repository has been archived on 14/Jul/2022
  • Stars
    star
    768
  • Rank 59,159 (Top 2 %)
  • Language
    TypeScript
  • License
    BSD 3-Clause "New...
  • Created over 6 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A GraphQL-powered, NextJs-based, PWA storefront for Saleor. IMPORTANT: This project is [DEPRECATED] in favor of saleor/react-storefront soon to become our default demo and storefront starter pack.

saleor-storefront repository is DEPRECATED

We've decided to build a new storefront starting from scratch, with no fancy design, focusing solely on best practices for building commerce storefronts. The new project, called react-storefront, uses Next.js as its foundation and Tailwind for the looks. You can find it here: https://github.com/saleor/react-storefront.

Saleor Storefront

1 copy 2x

Note: This project is a demonstration on how Saleor can be used. It’s not ready to be a starter but rather show how different cases can be handled and could be used as a recipe book. There will be breaking changes and the code is constantly evolving, so use at your own risk.

A GraphQL-powered, PWA, single-page application storefront for Saleor.

Features

Demo

See the public demo of Saleor Storefront!

Or launch the demo on a free Heroku instance.

Deploy

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • Node.js 14.16
  • A running instance of Saleor.

To run the storefront, you have to set the NEXT_PUBLIC_API_URI environment variable to point to the Saleor GraphQL API. If you are running Saleor locally, with the default settings, NEXT_PUBLIC_API_URI is set to: http://localhost:8000/graphql/. To change it, either create a .env.local file and add it there or set an env variable using export command.

Installing

Clone the repository:

git clone https://github.com/mirumee/saleor-storefront.git

Enter the project directory:

cd saleor-storefront

Using stable release

To use the official stable release, checkout to a release tag:

$ git checkout 2.11.0

See the list of all releases here: https://github.com/mirumee/saleor-storefront/releases/

Using development version

If you want to use the latest development version, checkout to the master branch:

$ git checkout master

Install NPM dependencies:

npm i

Run the development server:

npm start

Go to http://localhost:3000 to access the storefront.

Build

To compile the app run:

$ npm run build

To compile the app and export storefront to the static HTML run:

$ npm run build:export

To compile the app and run it in production mode with next server run:

$ npm run build:start

In order to enable Apollo Devtools in the production version, set the environmental variable

NEXT_PUBLIC_ENABLE_APOLLO_DEVTOOLS=true

Cypress tests

If you want to run Cypress tests, make sure that all dependencies (including Cypress) are installed by running the install command.

npm i

Following environment variables are required to be set in order to be able to run tests properly:

  • API_URI - GraphQL API address.
  • STATIC_URL - static files destination url, eg. S3 bucket
  • CYPRESS_USER_NAME - username (email) for Storefront user.
  • CYPRESS_USER_PASSWORD - for the user mentioned above.

If you are running the Storefront from the perspective of Docker container, then you can run tests using following commands:

Headless mode:

cy:run

Cypress UI mode:

cy:open

If you want to run tests against your local development environment then use following commands:

Headless mode:

test:e2e:run

Cypress UI mode:

test:e2e:dev

Creating new components

All new components should follow Atomic Design Guidelines and be placed in src/@next/components directory.

Files structure can be generated using plop:

npm run generate

Modifying the Storefront

From Spectrum Post

Important Files

  • saleor-storefront/config/next/config.base.js - Base Next.js config file which contains webpack custom adjustments.
    • Can change name of the app (displayed when installed on mobile)
  • saleor-storefront/src/pages/app.tsx - Main entry point file. Render's the component, apollo-client, and others to the root div in index.html file above. Contains also head section - You can change the title of storefront here.
  • saleor-storefront/src/core/config.ts - Controls number of products shown per page, support email, gateway providers, social media, and some meta.
    • Can change support email
    • Can change products shown per page
    • Can change gateway providers
    • Can change social media links that are displayed in the footer
    • Can change some meta options
  • saleor-storefront/src/images/ - Holds all the images for logo, cart, favicon, etc.
    • Can change storefront logo, favicon, or add new images here.
  • saleor-storefront/src/globalStyles/scss/variables.scss - Contains base styles like colors, font size, container width, media breakpoints and more.
  • saleor-storefront/src/@next/globalStyles/ - Contains more base styles, themes, media, and constants.
  • saleor-storefront/src/views/ - This folder controls the views, or what is displayed for each page. Most views have a file named "Page.tsx" that controls the layout of the page and a file named "View.tsx" that calls the query and renders the component with the data.
    • Can add another view to storefront here. Requires adding a route (see routes below).
  • saleor-storefront/src/@next/pages/ - Second spot for modifying/adding different pages. This is the recommended directory to add new pages.
  • saleor-storefront/src/paths.ts - This folder contains all the paths. Here is where you add a new one.
  • saleor-storefront/src/pages/ - This folder contains files which are translated to Next.js routing. Here is where you add a new route.
    1. Export a new path in paths.ts
    2. Inside pages, create a new file with name correnspond to your desired route (read more here about nested routes). Import your view in the created route file end export it as a default export.
    3. To link to your new view import Link from "next/link" and use new path you created in paths.ts (make sure to import it)
  • saleor-storefront/src/app/App.tsx - This is main component that renders the , (explained below), and a couple other components.

Adding a Payment Gateway

  • saleor-storefront/src/core/config.ts - Add new gateway provider name here.
  • saleor-storefront/src/@next/components/organisms/ - Create a new folder for new payment gateway component here.
  • saleor-storefront/src/@next/components/organisms/PaymentGatewaysList/PaymentGatewaysList.tsx - Import new gateway component, create a new switch case to handle your gateway component.

Receiving confirmation emails

  • Set EMAIL_URL environment variable for Saleor core.
    • Using Docker - Add EMAIL_URL as new environment variable to both the api and worker service following the format here.
  • Issues getting emails working?
    • Gmail
      • Check to see that "Less secure app access" is turned ON. Under "Manage your Google Account" > Go to the security tab. By default, the setting is off for security reasons.
      • If using 2FA make sure to set an app password and use that in place of your normal login password.

Multichannel

  • Set [SALEOR_CHANNEL_SLUG] environment variable. - Default value: default-channel.

License

This project is licensed under the BSD-3-Clause License - see the LICENSE file for details

Crafted with ❤️ by Saleor Commerce

[email protected]

More Repositories

1

saleor

Saleor Core: the high performance, composable, headless commerce API.
Python
20,676
star
2

storefront

Saleor Storefront built with React 18, Next.js 14, App Router, TypeScript, GraphQL, and Tailwind CSS.
TypeScript
983
star
3

saleor-dashboard

A GraphQL-powered, single-page dashboard application for Saleor.
TypeScript
832
star
4

saleor-platform

All Saleor services started from a single repository with docker-compose.
640
star
5

saleor-sdk

Deprecated! See the announcement below. JavaScript/TypeScript SDK for building e-commerce experiences and checkouts with Saleor API.
TypeScript
129
star
6

saleor-docs

Saleor documentation.
JavaScript
106
star
7

apps

A central space for Saleor Apps, integrations, and the App Store 🚀
TypeScript
105
star
8

macaw-ui

MacawUI: an official UI design kit for Saleor
TypeScript
100
star
9

cli

Command-line interface allowing interaction with Saleor Cloud environments.
TypeScript
69
star
10

saleor-app-template

Your boilerplate for new Saleor Apps. Batteries included.
TypeScript
62
star
11

app-sdk

SDK for building great Saleor Apps
TypeScript
46
star
12

saleor.io-learn

The Saleor Tutorial content. Learn how to create production-grade Saleor storefronts with React and Next.js. https://saleor.io/learn
39
star
13

saleor-app-payment-adyen

TypeScript
36
star
14

saleor-app-slack

TypeScript
29
star
15

saleor-next-starter

TypeScript
27
star
16

saleor-checkout

Migrated into a monorepo: https://github.com/saleor/react-storefront | The first fully open source and production-ready checkout experience.
TypeScript
22
star
17

saleor-app-klaviyo

TypeScript
20
star
18

auth-sdk

TypeScript
19
star
19

examples

Examples showing how to use the Saleor API.
15
star
20

saleor-app-payment-klarna

TypeScript
15
star
21

saleor-graphql-playground

TypeScript
12
star
22

saleor-app-payment-stripe

TypeScript
12
star
23

app-bridge

An official library for handling all communication between Saleor Dashboard and Saleor Apps.
TypeScript
12
star
24

create-saleor-app

TypeScript
10
star
25

app-examples

Common examples and patterns writing great Saleor apps
10
star
26

example-flutter

Saleor Example: Flutter Mobile App (Dart)
Dart
9
star
27

example-react-native-typescript

Saleor Example: React Native App in TypeScript using Expo
TypeScript
9
star
28

saleor-stellate

Stellate support for Saleor Commerce
TypeScript
9
star
29

saleor-email-templates

Example e-mail templates for Saleor
HTML
9
star
30

dummy-payment-app

Bare-bones app for testing Saleor's Transactions API
TypeScript
8
star
31

example-nextjs-app-router-starter

Saleor Example: Next.js 13 App Router Starter
TypeScript
8
star
32

requests-hardened

A library that overrides the default behaviors of the requests library, and adds new security features.
Python
8
star
33

saleor-app-search

TypeScript
6
star
34

tutorial-walkthrough

TypeScript
6
star
35

saleor-app-cms

TypeScript
6
star
36

example-nextjs-stripe

TypeScript
6
star
37

saleor-plugin-avatax-excise

Python
6
star
38

example-react-cra-typescript

Saleor Example: React App in TypeScript using Create React App (CRA)
TypeScript
5
star
39

saleor-avatax

TypeScript
5
star
40

saleor-app-invoices

Saleor integration for invoices generation
TypeScript
5
star
41

saleor-taxjar

TypeScript
5
star
42

saleor-admin-email-templates

Saleor admin email MJML templates: Reset password, export data, staff order
HTML
4
star
43

graphiql-plugin-collection

TypeScript
4
star
44

devtools-integration-tests

This is a hub for integration and e2e tests for CLI
TypeScript
4
star
45

saleor-app-data-importer

TypeScript
3
star
46

.github

3
star
47

example-react-nextjs-apollo-typescript

Saleor Example: React App in TypeScript with Apollo GraphQL using Next.js
TypeScript
3
star
48

json-schema-compiler

TypeScript
3
star
49

saleor-app-payment-template

Template Saleor payments apps are built from
TypeScript
3
star
50

saleor-app-emails-and-messages

TypeScript
2
star
51

saleor-app-klaviyo-old

TypeScript
2
star
52

digitalocean-1click

Shell
2
star
53

saleor-og

TypeScript
2
star
54

saleor-app-algolia

TypeScript
1
star
55

saleor-app-abandoned-checkouts

Example app built for documentation purposes
TypeScript
1
star
56

app-debug-bar

TypeScript
1
star
57

eslint-plugin-saleor-app

ESLint plugin with rules for Saleor Apps
TypeScript
1
star
58

marketplace-content

Marketplace content
1
star
59

example-auth-nextjs-pages-router

Saleor Example: Auth SDK with Next.js (Pages Router) in TypeScript
TypeScript
1
star
60

shellcheck-gha

Extracts and checks shell scripts in Github Workflows for potential issues using ShellCheck.
Python
1
star