### Run Saleor Storefront Development Server Source: https://docs.saleor.io/quickstart/storefront Starts the development server for the Saleor storefront using pnpm. ```bash pnpm run dev ``` -------------------------------- ### Saleor CLI Example Command Help Source: https://docs.saleor.io/cli/commands/example Displays the help information for the `saleor example` command, outlining its purpose, available options, positional arguments, and usage examples for setting up Saleor examples locally. ```bash $ saleor example --help ``` ```bash saleor example [name] Setup an official Saleor example locally Positionals: name [string] [default: "my-saleor-app"] Options: --json Output the data as JSON [boolean] [default: false] --short Output data as text [boolean] [default: false] -u, --instance, --url Saleor instance API URL (must start with the protocol, i.e. https:// or http://) [string] --dependencies, --deps [boolean] [default: true] -t, --template, --repo, --repository [string] -V, --version Show version number [boolean] -h, --help Show help [boolean] Examples: saleor example auth-sdk Setup the auth-sdk example from saleor/examples on GitHub ``` -------------------------------- ### Clone and Install Saleor Storefront Source: https://docs.saleor.io/quickstart/storefront Clones the Saleor storefront repository and installs its dependencies using pnpm. ```bash git clone https://github.com/saleor/storefront.git saleor-storefront cd saleor-storefront pnpm i ``` -------------------------------- ### Run Saleor App Source: https://docs.saleor.io/developer/extending/apps/quickstart This snippet shows how to navigate into the newly created Saleor app directory and start the development server. It assumes the Saleor CLI has been used to set up the project and install dependencies. ```bash cd my-saleor-app pnpm dev ``` -------------------------------- ### Copy Environment Variables Source: https://docs.saleor.io/quickstart/storefront Copies the example environment variables file to a new file for local configuration. ```bash cp .env.example .env ``` -------------------------------- ### Run Saleor Storefront Source: https://docs.saleor.io/setup/windows Starts the Saleor storefront development server. This command builds and serves the storefront application locally. ```bash pnpm dev ``` -------------------------------- ### Clone Saleor Storefront Repository Source: https://docs.saleor.io/setup/windows Clones the Saleor storefront repository from GitHub and navigates into the directory. This is the first step to setting up the example storefront. ```bash git clone https://github.com/saleor/storefront.git cd storefront ``` -------------------------------- ### Configure Saleor API URL Source: https://docs.saleor.io/quickstart/storefront Sets the Saleor API URL in the .env file, pointing to either a Saleor Cloud instance or a local Docker setup. ```env # Add backend address # Make sure to add slash at the end: NEXT_PUBLIC_SALEOR_API_URL=https://{your_domain}.saleor.cloud/graphql/ # Local example # NEXT_PUBLIC_SALEOR_API_URL=http://localhost:8000/graphql/ ``` -------------------------------- ### Run Saleor API Server Source: https://docs.saleor.io/setup/windows Starts the Saleor API server in development mode using Uvicorn. This command is intended for development and uses the 'saleor.asgi:application'. ```bash poetry run uvicorn saleor.asgi:application --reload ``` -------------------------------- ### Run Saleor Dashboard Source: https://docs.saleor.io/setup/windows Starts the Saleor dashboard development server. Ensure the API_URI environment variable is set correctly before running this command. ```bash npm start ``` -------------------------------- ### Create Saleor App with Saleor CLI Source: https://docs.saleor.io/developer/extending/apps/quickstart This snippet demonstrates how to create a new Saleor app using the Saleor CLI. It clones the Saleor App Template repository and installs necessary dependencies. The Saleor CLI is recommended for its comprehensive app development commands. ```bash saleor app template my-saleor-app ``` ```bash npx saleor app template my-saleor-app ``` -------------------------------- ### Clone Saleor Repository Source: https://docs.saleor.io/setup/windows Clones the Saleor repository from GitHub and navigates into the directory. This is the first step in setting up the Saleor project locally. ```bash git clone https://github.com/saleor/saleor.git cd saleor ``` -------------------------------- ### Saleor Order Creation Mutation Example Source: https://docs.saleor.io/developer/bulks/bulk-orders An example of a Saleor mutation for bulk order creation, demonstrating the structure of the input payload with user, delivery, and line item details. It also includes an example of fulfillment line input. ```GraphQL mutation CreateBulkOrders($input: OrderBulkCreateInput!) { orderBulkCreate(input: $input) { orders { id user { email } lines { productSku quantity } } errors { field message } } } # Example input for the mutation: # { # "input": { # "user": { # "email": "customer@example.com" # }, # "lines": [ # { # "variantId": "VHJhbnNhY3Rpb25JdGVtOjI3MTYwYWRlLTA4ZWYtNDhiNC05OWE1LTFkNWExOWYzZDhkNA==", # "quantity": 1, # "totalPrice": {"amount": 100.0, "currency": "PLN"}, # "undiscountedTotalPrice": {"amount": 100.0, "currency": "PLN"}, # "warehouse": "V2FyZWhvdXNlOjE=" # } # ], # "deliveryMethod": { # "warehouseId": "V2FyZWhvdXNlOjE=" # }, # "fulfillments": [ # { # "orderLineIndex": 0, # "variantId": "VHJhbnNhY3Rpb25JdGVtOjI3MTYwYWRlLTA4ZWYtNDhiNC05OWE1LTFkNWExOWYzZDhkNA==" # } # ] # } # } ``` -------------------------------- ### Start ngrok Tunnel Source: https://docs.saleor.io/developer/running-saleor/exposing-instance This command starts an ngrok tunnel to expose your local Saleor instance running on port 8000 to the internet. Ensure ngrok is installed and configured. ```bash ngrok http 8000 ``` -------------------------------- ### Adyen API Error Details Example Source: https://docs.saleor.io/developer/app-store/apps/adyen/storefront An example JSON structure illustrating how Adyen API errors are represented within the `details` field of a `SyncWebhookAppError`. This includes `errorCode` and `statusCode` from Adyen. ```JSON { "data": { "transactionInitialize": { "transactionEvent": { "pspReference": "", "amount": { "amount": 54.24, "currency": "EUR" }, "type": "AUTHORIZATION_FAILURE" }, "data": { "errors": [ { "code": "HttpClientError", "message": "HTTP Exception: 422. : Unable to decrypt data", "details": { "errorCode": "174", "statusCode": 422 } } ], "paymentResponse": {} }, "errors": [] } } } ``` -------------------------------- ### Start MailHog with Docker Compose Source: https://docs.saleor.io/developer/app-store/apps/smtp/configuration This snippet shows how to start the MailHog service for local email testing using Docker Compose. Ensure Docker and docker compose are installed and accessible in your terminal. ```bash docker compose up ``` -------------------------------- ### Setup Plugin Entry Points Source: https://docs.saleor.io/developer/extending/plugins/overview Configures a Saleor plugin by defining its entry point in the setup.py file. This allows Saleor to discover and load the plugin. ```Python from setuptools import setup setup( ..., entry_points={ "saleor.plugins": [ "my_plugin = my_plugin.plugin:MyPlugin" ] } ) ``` -------------------------------- ### Example Promotion Events Response Source: https://docs.saleor.io/developer/discounts/promotions An example response showing the history of events for a promotion, including when the promotion and its rules were created and started. Each event includes its type, timestamp, and the ID of the user who initiated the action. ```JSON { "data": { "promotion": { "id": "UHJvbW90aW9uOjEyMzA0YmM4LTA2ZTMtNDg1Mi05ODU1LWM4ZDkyMDgzNTYwZA==", "events": [ { "type": "PROMOTION_CREATED", "date": "2023-09-21T12:28:16.457902+00:00", "createdBy": { "id": "VXNlcjox" } }, { "type": "PROMOTION_STARTED", "date": "2023-09-21T12:28:16.464749+00:00", "createdBy": { "id": "VXNlcjox" } }, { "type": "RULE_CREATED", "date": "2023-09-21T12:30:17.520316+00:00", "createdBy": { "id": "VXNlcjox" }, "ruleId": "UHJvbW90aW9uUnVsZTo1MjIwYmViZS02MjczLTRkNjUtYTNkZC1iYjNlYmI4MjllYjA=" } ] } } } ``` -------------------------------- ### Clone Saleor App Template and Install Dependencies Source: https://docs.saleor.io/developer/extending/apps/building-payment-app This snippet shows how to clone the Saleor App Template repository and install its dependencies using pnpm. This is the starting point for building a Saleor App. ```bash git clone https://github.com/saleor/saleor-app-template.git cd saleor-app-template pnpm install ``` -------------------------------- ### Clone Saleor Dashboard Repository Source: https://docs.saleor.io/setup/windows Clones the Saleor dashboard repository from GitHub and navigates into the directory. This is the initial step for setting up the dashboard locally. ```bash git clone https://github.com/saleor/saleor-dashboard.git cd saleor-dashboard ``` -------------------------------- ### TypeScript: Example `onBalanceCheck` Implementation Source: https://docs.saleor.io/developer/app-store/apps/adyen/storefront An example implementation of the `onBalanceCheck` callback in TypeScript, demonstrating how to use a GraphQL client to call the `PaymentGatewayInitialize` mutation and process the response for a gift card balance check. ```TypeScript async onBalanceCheck(resolve, reject, data) { const { paymentGatewayInitialize: { gatewayConfigs }, } = await client.request(PaymentGatewayInitialize, { checkoutId, data: { action: "checkBalance", paymentMethod: data.paymentMethod }, }); const response = gatewayConfigs[0].data.giftCardBalanceResponse; resolve(response); } ``` -------------------------------- ### Migrate Saleor Database Source: https://docs.saleor.io/setup/windows Applies database migrations for Saleor, creating necessary tables and extensions. If errors occur related to 'CREATE EXTENSION', review the user creation step. ```bash python manage.py migrate ``` -------------------------------- ### Install External App in Saleor Dashboard Source: https://docs.saleor.io/developer/extending/apps/developing-with-tunnels This guide explains how to install an external app in the Saleor Dashboard once it's exposed to the internet via a tunnel. It involves copying the app URL and appending '/api/manifest' before pasting it into the dashboard. ```bash 1. Copy the app URL. 2. Go to Dashboard → Apps. 3. Click _Install external app_ in the top right corner. 4. Paste the app URL with "/api/manifest" suffix. 5. Follow the dashboard installation process. ``` -------------------------------- ### Run Saleor Services Source: https://docs.saleor.io/setup/docker-compose Starts all Saleor services using Docker Compose. Once running, the Saleor dashboard will be accessible at localhost:9000. ```Bash docker compose up ``` -------------------------------- ### Install Saleor Storefront Dependencies Source: https://docs.saleor.io/setup/windows Installs the project dependencies for the Saleor storefront using pnpm. Ensure pnpm is installed globally. ```bash pnpm install ``` -------------------------------- ### Register Saleor Plugin via Setuptools Entry Point Source: https://docs.saleor.io/developer/extending/plugins/overview This example illustrates how to make a custom Saleor plugin discoverable by the Saleor core using Python's `setuptools` entry points. It shows the syntax for including a `saleor.plugins` entry point in the `setup()` function, mapping a package name to the plugin class path. ```Python setup( ... entry_points={ 'saleor.plugins': [ 'my_plugin_package = my_plugin_package.path.to:PluginClass' ] }, ... ) ``` -------------------------------- ### Register App with Environment Variable Domain Pattern Source: https://docs.saleor.io/developer/extending/apps/installation-protection This example shows how to configure allowed Saleor domains using an environment variable for the domain pattern. This approach allows for flexible control over installation restrictions without requiring code deployments. ```javascript allowedSaleorUrls: [ (url) => { if (process.env.ALLOWED_DOMAIN_PATTERN) { const regex = new RegExp(process.env.ALLOWED_DOMAIN_PATTERN); return regex.test(url); } return true; }, ] ``` -------------------------------- ### Saleor CLI Storefront Create Help Source: https://docs.saleor.io/cli/commands/storefront Displays the help information for the 'saleor storefront create' command, detailing how to bootstrap a Next.js storefront with various options like template, branch, and instance URL. ```bash saleor storefront create --help ``` -------------------------------- ### Install Saleor Dependencies with Poetry Source: https://docs.saleor.io/setup/windows Installs all necessary project dependencies for Saleor using the Poetry package manager. Ensure Poetry is installed before running this command. ```bash poetry install ``` -------------------------------- ### Generate Types and Queries Source: https://docs.saleor.io/quickstart/storefront Generates updated types and queries for the Saleor GraphQL schema, typically after modifying GraphQL files. ```bash pnpm run generate ``` -------------------------------- ### Storefront Configuration for Segment.io Source: https://docs.saleor.io/developer/app-store/apps/segment/examples Example environment variables for configuring a Saleor storefront to send data to Segment.io. These variables include API keys and channel information. ```javascript NEXT_PUBLIC_INITIAL_ENV_URL= NEXT_PUBLIC_INITIAL_CHANNEL_SLUG=default-channel NEXT_PUBLIC_INITIAL_CHECKOUT_COUNTRY_CODE=US NEXT_PUBLIC_SEGMENT_WRITE_KEY= NEXT_PUBLIC_STOREFRONT_USER_EMAIL= NEXT_PUBLIC_STOREFRONT_USER_PASSWORD= ``` -------------------------------- ### Promotion Creation Query Variables Source: https://docs.saleor.io/developer/discounts/promotions Example variables for the `promotionCreate` mutation, specifying the promotion's name, type, description, and start date. ```JSON { "input": { "name": "Example sale", "type": "CATALOGUE", "description": { "blocks": [ { "type": "paragraph", "data": { "text": "Test example sale." } } ] }, "startDate": "2023-06-06T00:00:00.00+00:00" } } ``` -------------------------------- ### Bypass Cache for Product Updates Source: https://docs.saleor.io/quickstart/storefront Navigates to a specific API endpoint to bypass Next.js caching and view updated product information. ```bash http://{your-host}/api/draft ``` -------------------------------- ### Install @saleor/app-sdk Source: https://docs.saleor.io/developer/extending/apps/developing-apps/app-sdk/overview Installs the @saleor/app-sdk package using different package managers like pnpm, npm, and yarn. This is the first step to using the SDK in your Saleor app development. ```Shell # Preferred - with pnpm pnpm add @saleor/app-sdk # With npm and yarn npm i @saleor/app-sdk yarn add @saleor/app-sdk ``` -------------------------------- ### Add Sample Data to Database Source: https://docs.saleor.io/quickstart/running-locally Populates the Saleor database with sample data, which is useful for testing and development purposes. ```bash docker compose run --rm api python3 manage.py populatedb ``` -------------------------------- ### Run Saleor ASGI Application with Uvicorn Source: https://docs.saleor.io/setup/telemetry This command starts the Saleor ASGI application using Uvicorn, initializing the telemetry system as part of the application setup. ```bash uvicorn saleor.asgi:application ``` -------------------------------- ### Install Saleor CLI with pnpm Source: https://docs.saleor.io/cli/overview Installs the Saleor CLI globally using the pnpm package manager. This command makes the `saleor` executable available in your system's PATH. ```bash pnpm i @saleor/cli -g ``` -------------------------------- ### Update Product Page with New Field Source: https://docs.saleor.io/quickstart/storefront Demonstrates how to access and render a new field, 'isAvailable', within a product page component in the Next.js storefront. ```javascript export default async function Page(){ // ... const isAvailable = data.product.isAvailable; // ... } ``` -------------------------------- ### Create Local App with Permissions (Python) Source: https://docs.saleor.io/developer/extending/apps/installing-apps Creates a new local Saleor app with specified permissions and an optional target URL for receiving authentication tokens. If a target URL is provided, Saleor posts the auth token to it upon successful installation. ```Python python manage.py create_app "Order App" \ --permission MANAGE_USERS \ --permission MANAGE_ORDERS \ --target-url https://your-order-app/your-register-endpoint/ ``` ```Python python manage.py create_app "Order App" \ --permission MANAGE_USERS \ --permission MANAGE_ORDERS ``` -------------------------------- ### Example Saleor Core CONTRIBUTING.md Source: https://docs.saleor.io/developer/community/contributing This snippet provides an example of a CONTRIBUTING.md file for Saleor's core repository, detailing specific guidelines for code contributions. ```markdown This is an example for Saleor's core repository. Please refer to the specific repository's CONTRIBUTING.md for detailed guidelines. ``` -------------------------------- ### Populate Database with Sample Data Source: https://docs.saleor.io/setup/docker-compose Populates the Saleor database with sample data using Docker Compose. This is useful for testing and development purposes. ```Bash docker compose run --rm api python3 manage.py populatedb ```