docs: update docusaurus to v3 (#5625)

* update dependencies

* update onboarding mdx

* fixes for mdx issues

* fixes for mdx compatibility

* resolve mdx errors

* fixes in reference

* fix check errors

* revert change in vale action

* fix node version in action

* fix summary in markdown
This commit is contained in:
Shahed Nasser authored and GitHub committed 2023-11-13 20:11:50 +02:00
1 parent cedab58339
commit c6dff873de
2265 files changed
+46163 -47195

No files matched your search

File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+16 -16
View File
@@ -351,26 +351,26 @@ import TabItem from '@theme/TabItem';
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.uploads.create(file) // file is an instance of File
.then(({ uploads }) => {
const key = uploads[0].key
})
```
```ts
medusa.admin.uploads.create(file) // file is an instance of File
.then(({ uploads }) => {
const key = uploads[0].key
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/uploads' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: text/csv' \
-F 'files=@"<FILE_PATH_1>"'
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/uploads' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: text/csv' \
-F 'files=@"<FILE_PATH_1>"'
```
</TabItem>
</TabItem>
</Tabs>
~~~
+40 -49
View File
@@ -42,9 +42,9 @@ In your terminal, run the following command:
<Tabs groupId="npxyarn" isCodeTabs={true}>
<TabItem value="npx" label="NPX" default>
```bash
npx create-medusa-app@latest
```
```bash
npx create-medusa-app@latest
```
</TabItem>
{/* <TabItem value="yarn" label="Yarn">
@@ -56,69 +56,60 @@ In your terminal, run the following command:
</TabItem> */}
<TabItem value="pnpm" label="pnpm">
```bash
pnpm dlx create-medusa-app@latest
```
```bash
pnpm dlx create-medusa-app@latest
```
</TabItem>
</Tabs>
<details>
<summary>
Command Options
</summary>
<Details>
<Summary>Command Options</Summary>
The `create-medusa-app` command can accept the following options:
The `create-medusa-app` command can accept the following options:
- `--repo-url <url>`: The repository URL to create the project from. By default it will be `https://github.com/medusajs/medusa-starter-default`.
- `--seed`: A flag indicating whether the database should be seeded with demo data. By default, seeding is disabled.
- `--no-boilerplate`: A flag that removes all files added for an enhanced onboarding experience (files under `src/admin`, `src/api`, etc...). This is helpful if you want to create a clean project, and is only recommended if you're familiar with Medusa.
- `--no-browser`: Disables opening the browser at the end of the project creation and only shows success message.
- `--skip-db`: Skips creating the database, running migrations, and seeding, and subsequently skips opening the browser. Useful if you want to set the database URL at a later point in the configurations.
- `--db-url <url>`: Skips database creation and sets the database URL to the provided URL. Throws an error if connection to the database fails. Will still run migrations and open the admin after project creation. Useful if you already have a database created, locally or remotely.
- `--no-migrations`: Skips running migrations, creating admin user, and seeding. If used, it's expected that you pass the `--db-url` option with a URL of a database that has all necessary migrations. Otherwise, unexpected errors will occur. Helpful only if combined with `--db-url`.
- `--directory-path <path>`: Allows specifying the parent directory path to create the directory of the new project in.
- `--with-nextjs-starter`: Installs the Next.js starter storefront under the `<PROJECT_NAME>-storefront` directory, where `<PROJECT_NAME>` is the name of the project you enter in the first question. If the `<PROJECT_NAME>-storefront` directory already exists, random characters are added at the end of `<PROJECT_NAME>-storefront`.
</Details>
- `--repo-url <url>`: The repository URL to create the project from. By default it will be `https://github.com/medusajs/medusa-starter-default`.
- `--seed`: A flag indicating whether the database should be seeded with demo data. By default, seeding is disabled.
- `--no-boilerplate`: A flag that removes all files added for an enhanced onboarding experience (files under `src/admin`, `src/api`, etc...). This is helpful if you want to create a clean project, and is only recommended if you're familiar with Medusa.
- `--no-browser`: Disables opening the browser at the end of the project creation and only shows success message.
- `--skip-db`: Skips creating the database, running migrations, and seeding, and subsequently skips opening the browser. Useful if you want to set the database URL at a later point in the configurations.
- `--db-url <url>`: Skips database creation and sets the database URL to the provided URL. Throws an error if connection to the database fails. Will still run migrations and open the admin after project creation. Useful if you already have a database created, locally or remotely.
- `--no-migrations`: Skips running migrations, creating admin user, and seeding. If used, it's expected that you pass the `--db-url` option with a URL of a database that has all necessary migrations. Otherwise, unexpected errors will occur. Helpful only if combined with `--db-url`.
- `--directory-path <path>`: Allows specifying the parent directory path to create the directory of the new project in.
- `--with-nextjs-starter`: Installs the Next.js starter storefront under the `<PROJECT_NAME>-storefront` directory, where `<PROJECT_NAME>` is the name of the project you enter in the first question. If the `<PROJECT_NAME>-storefront` directory already exists, random characters are added at the end of `<PROJECT_NAME>-storefront`.
<Details className="border-t-0">
<Summary>Example: Connect to a Vercel PostgreSQL Database</Summary>
</details>
If you want to use a PostgreSQL database hosted on Vercel, you must use the `--db-url` option and add to the end of your connection URL `?sslmode=require`. For example:
<details className="border-t-0">
<summary>
Example: Connect to a Vercel PostgreSQL Database
</summary>
```bash
npx create-medusa-app@latest --db-url "postgres://default:<password><host-region>.postgres.vercel-storage.com:5432/verceldb?sslmode=require"
```
If you want to use a PostgreSQL database hosted on Vercel, you must use the `--db-url` option and add to the end of your connection URL `?sslmode=require`. For example:
:::note
```bash
npx create-medusa-app@latest --db-url "postgres://default:<password><host-region>.postgres.vercel-storage.com:5432/verceldb?sslmode=require"
```
If the database already has the necessary migrations and you don't need the command to run migrations, you can pass the `--no-migrations` option.
:::note
:::
</Details>
If the database already has the necessary migrations and you don't need the command to run migrations, you can pass the `--no-migrations` option.
<Details className="border-t-0">
<Summary>Example: Connect to a Supabase Database</Summary>
:::
If you want to connect to a Supabase database, you must use the `--db-url` option with its value beign the connection URL to your Supabase database. For example:
</details>
```bash
npx create-medusa-app@latest --db-url postgresql://postgres:<password>@<host>.supabase.co:5432/postgres
```
<details className="border-t-0">
<summary>
Example: Connect to a Supabase Database
</summary>
:::note
If you want to connect to a Supabase database, you must use the `--db-url` option with its value beign the connection URL to your Supabase database. For example:
If the database already has the necessary migrations and you don't need the command to run migrations, you can pass the `--no-migrations` option.
```bash
npx create-medusa-app@latest --db-url postgresql://postgres:<password>@<host>.supabase.co:5432/postgres
```
:::note
If the database already has the necessary migrations and you don't need the command to run migrations, you can pass the `--no-migrations` option.
:::
</details>
:::
</Details>
## Step 2: Specify Project Name
@@ -22,8 +22,8 @@ If you're deploying the admin plugin along with the backend, you'll need at leas
If you also don't have a Medusa project, you can deploy to Railway instantly with this button:
<a
href="https://railway.app/template/zC7eOq?referralCode=TW4Qi0" class="img-url no-zoom-img">
<img src="https://railway.app/button.svg" alt="Deploy with Railway" class="no-zoom-img"/>
href="https://railway.app/template/zC7eOq?referralCode=TW4Qi0" className="img-url no-zoom-img">
<img src="https://railway.app/button.svg" alt="Deploy with Railway" className="no-zoom-img"/>
</a>
---
@@ -13,8 +13,8 @@ In this document, you’ll learn how to deploy the Next.js Starter Template on V
Alternatively, you can directly deploy the Next.js Starter Template to Vercel with this button.
<a
href="https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fmedusajs%2Fnextjs-starter-medusa.git&env=NEXT_PUBLIC_MEDUSA_BACKEND_URL&envDescription=URL%20of%20your%20Medusa%20Backend" class="img-url no-zoom-img">
<img src="https://vercel.com/button" alt="Deploy with Vercel" class="no-zoom-img"/>
href="https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fmedusajs%2Fnextjs-starter-medusa.git&env=NEXT_PUBLIC_MEDUSA_BACKEND_URL&envDescription=URL%20of%20your%20Medusa%20Backend" className="img-url no-zoom-img">
<img src="https://vercel.com/button" alt="Deploy with Vercel" className="no-zoom-img"/>
</a>
:::note
@@ -143,52 +143,52 @@ export default (rootDirectory) => {
Then, create an object that will hold the CORS configurations. Based on whether it's storefront or admin CORS options, you pass it the respective configuration from `projectConfig`:
<Tabs groupId="endpoint-type" isCodeTabs={true}>
<TabItem value="storefront" label="Storefront CORS" default>
<TabItem value="storefront" label="Storefront CORS" default>
```ts
const storeCorsOptions = {
origin: projectConfig.store_cors.split(","),
credentials: true,
}
```
```ts
const storeCorsOptions = {
origin: projectConfig.store_cors.split(","),
credentials: true,
}
```
</TabItem>
<TabItem value="admin" label="Admin CORS">
</TabItem>
<TabItem value="admin" label="Admin CORS">
```ts
const adminCorsOptions = {
origin: projectConfig.admin_cors.split(","),
credentials: true,
}
```
```ts
const adminCorsOptions = {
origin: projectConfig.admin_cors.split(","),
credentials: true,
}
```
</TabItem>
</TabItem>
</Tabs>
Finally, you can either pass the `cors` middleware for a specific route, or pass it to the entire router:
<Tabs groupId="pass-type" isCodeTabs={true}>
<TabItem value="single" label="Pass to Endpoint" default>
<TabItem value="single" label="Pass to Endpoint" default>
```ts
adminRouter.options("/admin/hello", cors(adminCorsOptions))
adminRouter.get(
"/admin/hello",
cors(adminCorsOptions),
(req, res) => {
// ...
}
)
```
```ts
adminRouter.options("/admin/hello", cors(adminCorsOptions))
adminRouter.get(
"/admin/hello",
cors(adminCorsOptions),
(req, res) => {
// ...
}
)
```
</TabItem>
<TabItem value="router" label="Pass to Router">
</TabItem>
<TabItem value="router" label="Pass to Router">
```ts
adminRouter.use(cors(adminCorsOptions))
```
```ts
adminRouter.use(cors(adminCorsOptions))
```
</TabItem>
</TabItem>
</Tabs>
---
@@ -252,43 +252,43 @@ import { requireCustomerAuthentication } from "@medusajs/medusa"
Then, pass the middleware to either a single route or an entire router:
<Tabs groupId="pass-type" isCodeTabs={true}>
<TabItem value="single" label="Pass to Endpoint" default>
<TabItem value="single" label="Pass to Endpoint" default>
```ts
// only necessary if you're passing cors options per route
router.options("/store/hello", cors(storeCorsOptions))
router.get(
"/store/hello",
cors(storeCorsOptions),
requireCustomerAuthentication(),
// authenticateCustomer()
async (req, res) => {
// access current customer
const id = req.user.customer_id
// if you're using authenticateCustomer middleware
// check if id is set first
```ts
// only necessary if you're passing cors options per route
router.options("/store/hello", cors(storeCorsOptions))
router.get(
"/store/hello",
cors(storeCorsOptions),
requireCustomerAuthentication(),
// authenticateCustomer()
async (req, res) => {
// access current customer
const id = req.user.customer_id
// if you're using authenticateCustomer middleware
// check if id is set first
const customerService = req.scope.resolve("customerService")
const customer = await customerService.retrieve(id)
// ...
}
)
```
const customerService = req.scope.resolve("customerService")
const customer = await customerService.retrieve(id)
// ...
}
)
```
</TabItem>
<TabItem value="router" label="Pass to Router">
</TabItem>
<TabItem value="router" label="Pass to Router">
```ts
storeRouter.use(requireCustomerAuthentication())
// all routes added to storeRouter are now protected
// the logged in customer can be accessed using:
// req.user.customer_id
```ts
storeRouter.use(requireCustomerAuthentication())
// all routes added to storeRouter are now protected
// the logged in customer can be accessed using:
// req.user.customer_id
// storeRouter.use(authenticateCustomer())
```
// storeRouter.use(authenticateCustomer())
```
</TabItem>
</TabItem>
</Tabs>
### Protect Admin Routes
@@ -304,37 +304,37 @@ import { authenticate } from "@medusajs/medusa"
Then, pass the middleware to either a single route or an entire router:
<Tabs groupId="pass-type" isCodeTabs={true}>
<TabItem value="single" label="Pass to Endpoint" default>
<TabItem value="single" label="Pass to Endpoint" default>
```ts
// only necessary if you're passing cors options per route
adminRouter.options("/admin/hello", cors(adminCorsOptions))
adminRouter.get(
"/admin/hello",
cors(adminCorsOptions),
authenticate(),
async (req, res) => {
// access current user
const id = req.user.userId
const userService = req.scope.resolve("userService")
const user = await userService.retrieve(id)
// ...
}
)
```
```ts
// only necessary if you're passing cors options per route
adminRouter.options("/admin/hello", cors(adminCorsOptions))
adminRouter.get(
"/admin/hello",
cors(adminCorsOptions),
authenticate(),
async (req, res) => {
// access current user
const id = req.user.userId
const userService = req.scope.resolve("userService")
const user = await userService.retrieve(id)
// ...
}
)
```
</TabItem>
<TabItem value="router" label="Pass to Router">
</TabItem>
<TabItem value="router" label="Pass to Router">
```ts
adminRouter.use(authenticate())
// all routes added to adminRouter are now protected
// the logged in user can be accessed using:
// req.user.userId
```
```ts
adminRouter.use(authenticate())
// all routes added to adminRouter are now protected
// the logged in user can be accessed using:
// req.user.userId
```
</TabItem>
</TabItem>
</Tabs>
---
@@ -628,318 +628,318 @@ This section services as an example of creating endpoints that perform Create, R
You can refer to the [Entities](../entities/create.mdx#adding-relations) and [Services](../services/create-service.mdx#example-services-with-crud-operations) documentation to learn how to create the custom entities and services used in this example.
<Tabs groupId="files" isCodeTabs={true}>
<TabItem value="index" label="src/api/index.ts" default>
<TabItem value="index" label="src/api/index.ts" default>
```ts
import express, { Router } from "express"
import adminRoutes from "./admin"
import storeRoutes from "./store"
import { errorHandler } from "@medusajs/medusa"
```ts
import express, { Router } from "express"
import adminRoutes from "./admin"
import storeRoutes from "./store"
import { errorHandler } from "@medusajs/medusa"
export default (rootDirectory, options) => {
const router = Router()
export default (rootDirectory, options) => {
const router = Router()
router.use(express.json())
router.use(express.urlencoded({ extended: true }))
router.use(express.json())
router.use(express.urlencoded({ extended: true }))
adminRoutes(router, options)
storeRoutes(router, options)
adminRoutes(router, options)
storeRoutes(router, options)
router.use(errorHandler())
router.use(errorHandler())
return router
}
```
return router
}
```
</TabItem>
<TabItem value="admin" label="src/api/admin.ts">
</TabItem>
<TabItem value="admin" label="src/api/admin.ts">
```ts
import { Router } from "express"
import PostService from "../services/post"
import {
ConfigModule,
} from "@medusajs/medusa/dist/types/global"
import cors from "cors"
import { authenticate, wrapHandler } from "@medusajs/medusa"
import AuthorService from "../services/author"
```ts
import { Router } from "express"
import PostService from "../services/post"
import {
ConfigModule,
} from "@medusajs/medusa/dist/types/global"
import cors from "cors"
import { authenticate, wrapHandler } from "@medusajs/medusa"
import AuthorService from "../services/author"
export default function adminRoutes(
router: Router,
options: ConfigModule
) {
const { projectConfig } = options
export default function adminRoutes(
router: Router,
options: ConfigModule
) {
const { projectConfig } = options
const corsOptions = {
origin: projectConfig.admin_cors.split(","),
credentials: true,
}
const adminRouter = Router()
router.use("/admin/blog", adminRouter)
adminRouter.use(cors(corsOptions))
adminRouter.use(authenticate())
// it's recommended to define the routes
// in separate files. They're done in
// the same file here for simplicity
// list all blog posts
adminRouter.get(
"/posts",
wrapHandler(async (req, res) => {
const postService: PostService = req.scope.resolve(
"postService"
)
res.json({
posts: await postService.list(),
})
}))
// retrieve a single blog post
adminRouter.get(
"/posts/:id",
wrapHandler(async (req, res) => {
const postService: PostService = req.scope.resolve(
"postService"
)
const post = await postService.retrieve(req.params.id)
res.json({
post,
})
}))
// create a blog post
adminRouter.post(
"/posts",
wrapHandler(async (req, res) => {
const postService: PostService = req.scope.resolve(
"postService"
)
// basic validation of request body
if (!req.body.title || !req.body.author_id) {
throw new Error("`title` and `author_id` are required.")
const corsOptions = {
origin: projectConfig.admin_cors.split(","),
credentials: true,
}
const post = await postService.create(req.body)
const adminRouter = Router()
res.json({
post,
})
}))
router.use("/admin/blog", adminRouter)
// update a blog post
adminRouter.post(
"/posts/:id",
wrapHandler(async (req, res) => {
const postService: PostService = req.scope.resolve(
"postService"
)
adminRouter.use(cors(corsOptions))
adminRouter.use(authenticate())
// basic validation of request body
if (req.body.id) {
throw new Error("Can't update post ID")
// it's recommended to define the routes
// in separate files. They're done in
// the same file here for simplicity
// list all blog posts
adminRouter.get(
"/posts",
wrapHandler(async (req, res) => {
const postService: PostService = req.scope.resolve(
"postService"
)
res.json({
posts: await postService.list(),
})
}))
// retrieve a single blog post
adminRouter.get(
"/posts/:id",
wrapHandler(async (req, res) => {
const postService: PostService = req.scope.resolve(
"postService"
)
const post = await postService.retrieve(req.params.id)
res.json({
post,
})
}))
// create a blog post
adminRouter.post(
"/posts",
wrapHandler(async (req, res) => {
const postService: PostService = req.scope.resolve(
"postService"
)
// basic validation of request body
if (!req.body.title || !req.body.author_id) {
throw new Error("`title` and `author_id` are required.")
}
const post = await postService.create(req.body)
res.json({
post,
})
}))
// update a blog post
adminRouter.post(
"/posts/:id",
wrapHandler(async (req, res) => {
const postService: PostService = req.scope.resolve(
"postService"
)
// basic validation of request body
if (req.body.id) {
throw new Error("Can't update post ID")
}
const post = await postService.update(
req.params.id,
req.body
)
res.json({
post,
})
}))
// delete a blog post
adminRouter.delete(
"/posts/:id",
wrapHandler(async (req, res) => {
const postService: PostService = req.scope.resolve(
"postService"
)
await postService.delete(req.params.id)
res.status(200).end()
}))
// list all blog authors
adminRouter.get(
"/authors",
wrapHandler(async (req, res) => {
const authorService: AuthorService = req.scope.resolve(
"authorService"
)
res.json({
authors: await authorService.list(),
})
}))
// retrieve a single blog author
adminRouter.get(
"/authors/:id",
wrapHandler(async (req, res) => {
const authorService: AuthorService = req.scope.resolve(
"authorService"
)
res.json({
post: await authorService.retrieve(req.params.id),
})
}))
// create a blog author
adminRouter.post(
"/authors",
wrapHandler(async (req, res) => {
const authorService: AuthorService = req.scope.resolve(
"authorService"
)
// basic validation of request body
if (!req.body.name) {
throw new Error("`name` is required.")
}
const author = await authorService.create(req.body)
res.json({
author,
})
}))
// update a blog author
adminRouter.post(
"/authors/:id",
wrapHandler(async (req, res) => {
const authorService: AuthorService = req.scope.resolve(
"authorService"
)
// basic validation of request body
if (req.body.id) {
throw new Error("Can't update author ID")
}
const author = await authorService.update(
req.params.id,
req.body
)
res.json({
author,
})
}))
// delete a blog author
adminRouter.delete(
"/authors/:id",
wrapHandler(async (req, res) => {
const authorService: AuthorService = req.scope.resolve(
"authorService"
)
await authorService.delete(req.params.id)
res.status(200).end()
}))
}
```
</TabItem>
<TabItem value="store" label="src/api/store.ts">
```ts
import { Router } from "express"
import {
ConfigModule,
} from "@medusajs/medusa/dist/types/global"
import PostService from "../services/post"
import cors from "cors"
import AuthorService from "../services/author"
import { wrapHandler } from "@medusajs/medusa"
export default function storeRoutes(
router: Router,
options: ConfigModule
) {
const { projectConfig } = options
const storeCorsOptions = {
origin: projectConfig.store_cors.split(","),
credentials: true,
}
const post = await postService.update(
req.params.id,
req.body
)
const storeRouter = Router()
router.use("/store/blog", storeRouter)
res.json({
post,
})
}))
storeRouter.use(cors(storeCorsOptions))
// list all blog posts
storeRouter.get(
"/posts",
wrapHandler(async (req, res) => {
const postService: PostService = req.scope.resolve(
"postService"
)
// delete a blog post
adminRouter.delete(
"/posts/:id",
wrapHandler(async (req, res) => {
const postService: PostService = req.scope.resolve(
"postService"
)
res.json({
posts: await postService.list(),
})
}))
await postService.delete(req.params.id)
// retrieve a single blog post
storeRouter.get(
"/posts/:id",
wrapHandler(async (req, res) => {
const postService: PostService = req.scope.resolve(
"postService"
)
res.status(200).end()
}))
res.json({
post: await postService.retrieve(req.params.id),
})
}))
// list all blog authors
adminRouter.get(
"/authors",
wrapHandler(async (req, res) => {
const authorService: AuthorService = req.scope.resolve(
"authorService"
)
// list all blog authors
storeRouter.get(
"/authors",
wrapHandler(async (req, res) => {
const authorService: AuthorService = req.scope.resolve(
"authorService"
)
res.json({
authors: await authorService.list(),
})
}))
res.json({
authors: await authorService.list(),
})
}))
// retrieve a single blog author
adminRouter.get(
"/authors/:id",
wrapHandler(async (req, res) => {
const authorService: AuthorService = req.scope.resolve(
"authorService"
)
// retrieve a single blog author
storeRouter.get(
"/authors/:id",
wrapHandler(async (req, res) => {
const authorService: AuthorService = req.scope.resolve(
"authorService"
)
res.json({
post: await authorService.retrieve(req.params.id),
})
}))
res.json({
post: await authorService.retrieve(req.params.id),
})
}))
}
```
// create a blog author
adminRouter.post(
"/authors",
wrapHandler(async (req, res) => {
const authorService: AuthorService = req.scope.resolve(
"authorService"
)
// basic validation of request body
if (!req.body.name) {
throw new Error("`name` is required.")
}
const author = await authorService.create(req.body)
res.json({
author,
})
}))
// update a blog author
adminRouter.post(
"/authors/:id",
wrapHandler(async (req, res) => {
const authorService: AuthorService = req.scope.resolve(
"authorService"
)
// basic validation of request body
if (req.body.id) {
throw new Error("Can't update author ID")
}
const author = await authorService.update(
req.params.id,
req.body
)
res.json({
author,
})
}))
// delete a blog author
adminRouter.delete(
"/authors/:id",
wrapHandler(async (req, res) => {
const authorService: AuthorService = req.scope.resolve(
"authorService"
)
await authorService.delete(req.params.id)
res.status(200).end()
}))
}
```
</TabItem>
<TabItem value="store" label="src/api/store.ts">
```ts
import { Router } from "express"
import {
ConfigModule,
} from "@medusajs/medusa/dist/types/global"
import PostService from "../services/post"
import cors from "cors"
import AuthorService from "../services/author"
import { wrapHandler } from "@medusajs/medusa"
export default function storeRoutes(
router: Router,
options: ConfigModule
) {
const { projectConfig } = options
const storeCorsOptions = {
origin: projectConfig.store_cors.split(","),
credentials: true,
}
const storeRouter = Router()
router.use("/store/blog", storeRouter)
storeRouter.use(cors(storeCorsOptions))
// list all blog posts
storeRouter.get(
"/posts",
wrapHandler(async (req, res) => {
const postService: PostService = req.scope.resolve(
"postService"
)
res.json({
posts: await postService.list(),
})
}))
// retrieve a single blog post
storeRouter.get(
"/posts/:id",
wrapHandler(async (req, res) => {
const postService: PostService = req.scope.resolve(
"postService"
)
res.json({
post: await postService.retrieve(req.params.id),
})
}))
// list all blog authors
storeRouter.get(
"/authors",
wrapHandler(async (req, res) => {
const authorService: AuthorService = req.scope.resolve(
"authorService"
)
res.json({
authors: await authorService.list(),
})
}))
// retrieve a single blog author
storeRouter.get(
"/authors/:id",
wrapHandler(async (req, res) => {
const authorService: AuthorService = req.scope.resolve(
"authorService"
)
res.json({
post: await authorService.retrieve(req.params.id),
})
}))
}
```
</TabItem>
</TabItem>
</Tabs>
---
@@ -538,25 +538,23 @@ After using `MedusaError`, the returned error in the response provides a clearer
}
```
<details>
<summary>
Available MedusaError Types and their respective status codes
</summary>
<Details>
<Summary>Available MedusaError Types and their respective status codes</Summary>
The default response code is `500` unless mentioned otherwise.
The default response code is `500` unless mentioned otherwise.
- `MedusaError.Types.DB_ERROR`: Sets the response code to `500`.
- `MedusaError.Types.DUPLICATE_ERROR`: Sets the response code to `422`.
- `MedusaError.Types.INVALID_ARGUMENT`
- `MedusaError.Types.INVALID_DATA`: Sets the resposne code to `400`.
- `MedusaError.Types.UNAUTHORIZED`: Sets the resposne code to `401`.
- `MedusaError.Types.NOT_FOUND`: Sets the response code to `404`.
- `MedusaError.Types.NOT_ALLOWED`: Sets the resposne code to `400`.
- `MedusaError.Types.UNEXPECTED_STATE`
- `MedusaError.Types.CONFLICT`: Sets the resposne code to `409`.
- `MedusaError.Types.PAYMENT_AUTHORIZATION_ERROR`: Sets the resposne code to `422`.
- `MedusaError.Types.DB_ERROR`: Sets the response code to `500`.
- `MedusaError.Types.DUPLICATE_ERROR`: Sets the response code to `422`.
- `MedusaError.Types.INVALID_ARGUMENT`
- `MedusaError.Types.INVALID_DATA`: Sets the resposne code to `400`.
- `MedusaError.Types.UNAUTHORIZED`: Sets the resposne code to `401`.
- `MedusaError.Types.NOT_FOUND`: Sets the response code to `404`.
- `MedusaError.Types.NOT_ALLOWED`: Sets the resposne code to `400`.
- `MedusaError.Types.UNEXPECTED_STATE`
- `MedusaError.Types.CONFLICT`: Sets the resposne code to `409`.
- `MedusaError.Types.PAYMENT_AUTHORIZATION_ERROR`: Sets the resposne code to `422`.
</details>
</Details>
### Override Error Handler
@@ -691,41 +689,41 @@ Files and directories prefixed with `_` are ignored. This can be helpful if you
For example:
<Tabs groupId="files" isCodeTabs={true}>
<TabItem value="custom-route" label="src/api/custom/route.ts" default>
<TabItem value="custom-route" label="src/api/custom/route.ts" default>
```ts
import getProducts from "../_methods/get-products"
```ts
import getProducts from "../_methods/get-products"
export const GET = getProducts
```
export const GET = getProducts
```
</TabItem>
<TabItem value="internal-method" label="src/api/_methods/get-product.ts">
</TabItem>
<TabItem value="internal-method" label="src/api/_methods/get-product.ts">
```ts
import {
MedusaRequest,
MedusaResponse,
ProductService,
} from "@medusajs/medusa"
```ts
import {
MedusaRequest,
MedusaResponse,
ProductService,
} from "@medusajs/medusa"
export default async function (
req: MedusaRequest,
res: MedusaResponse
) {
const productService = req.scope.resolve<ProductService>(
"productService"
)
export default async function (
req: MedusaRequest,
res: MedusaResponse
) {
const productService = req.scope.resolve<ProductService>(
"productService"
)
const products = await productService.list({})
const products = await productService.list({})
res.json({
products,
})
}
```
res.json({
products,
})
}
```
</TabItem>
</TabItem>
</Tabs>
---
@@ -741,117 +739,117 @@ You can refer to the [Entities](../entities/create.mdx#adding-relations) and [Se
:::
<Tabs groupId="files" isCodeTabs={true}>
<TabItem value="posts-routes" label="src/api/admin/posts/route.ts" default>
<TabItem value="posts-routes" label="src/api/admin/posts/route.ts" default>
```ts
import type {
MedusaRequest,
MedusaResponse,
} from "@medusajs/medusa"
import { PostService } from "../../../services/post"
```ts
import type {
MedusaRequest,
MedusaResponse,
} from "@medusajs/medusa"
import { PostService } from "../../../services/post"
// list posts
export const GET = async (
req: MedusaRequest,
res: MedusaResponse
) => {
const postService: PostService = req.scope.resolve(
"postService"
)
// list posts
export const GET = async (
req: MedusaRequest,
res: MedusaResponse
) => {
const postService: PostService = req.scope.resolve(
"postService"
)
res.json({
posts: await postService.list(),
})
}
res.json({
posts: await postService.list(),
})
}
// create a post
export const POST = async (
req: MedusaRequest,
res: MedusaResponse
) => {
const postService: PostService = req.scope.resolve(
"postService"
)
// create a post
export const POST = async (
req: MedusaRequest,
res: MedusaResponse
) => {
const postService: PostService = req.scope.resolve(
"postService"
)
// basic validation of request body
if (!req.body.title || !req.body.author_id) {
throw new Error("`title` and `author_id` are required.")
}
// basic validation of request body
if (!req.body.title || !req.body.author_id) {
throw new Error("`title` and `author_id` are required.")
}
const post = await postService.create(req.body)
const post = await postService.create(req.body)
res.json({
post,
})
}
```
res.json({
post,
})
}
```
</TabItem>
<TabItem value="posts-id-routes" label="src/api/admin/posts/[id]/route.ts">
</TabItem>
<TabItem value="posts-id-routes" label="src/api/admin/posts/[id]/route.ts">
```ts
import type {
MedusaRequest,
MedusaResponse,
} from "@medusajs/medusa"
import { PostService } from "../../../services/post"
```ts
import type {
MedusaRequest,
MedusaResponse,
} from "@medusajs/medusa"
import { PostService } from "../../../services/post"
// retrieve a post by its ID
export const GET = async (
req: MedusaRequest,
res: MedusaResponse
) => {
const postService: PostService = req.scope.resolve(
"postService"
)
// retrieve a post by its ID
export const GET = async (
req: MedusaRequest,
res: MedusaResponse
) => {
const postService: PostService = req.scope.resolve(
"postService"
)
const post = await postService.retrieve(req.params.id)
const post = await postService.retrieve(req.params.id)
res.json({
post,
})
}
res.json({
post,
})
}
// update a post by its ID
export const POST = async (
req: MedusaRequest,
res: MedusaResponse
) => {
const postService: PostService = req.scope.resolve(
"postService"
)
// update a post by its ID
export const POST = async (
req: MedusaRequest,
res: MedusaResponse
) => {
const postService: PostService = req.scope.resolve(
"postService"
)
// basic validation of request body
if (req.body.id) {
throw new Error("Can't update post ID")
}
// basic validation of request body
if (req.body.id) {
throw new Error("Can't update post ID")
}
const post = await postService.update(
req.params.id,
req.body
)
const post = await postService.update(
req.params.id,
req.body
)
res.json({
post,
})
}
res.json({
post,
})
}
// delete a post by its ID
export const DELETE = async (
req: MedusaRequest,
res: MedusaResponse
) => {
const postService: PostService = req.scope.resolve(
"postService"
)
// delete a post by its ID
export const DELETE = async (
req: MedusaRequest,
res: MedusaResponse
) => {
const postService: PostService = req.scope.resolve(
"postService"
)
await postService.delete(req.params.id)
await postService.delete(req.params.id)
res.status(200).end()
}
```
res.status(200).end()
}
```
</TabItem>
</TabItem>
</Tabs>
---
@@ -25,60 +25,48 @@ node -v
:::
<Tabs groupId="operating-systems" queryString="os">
<TabItem value="windows" label="Windows" default>
<TabItem value="windows" label="Windows" default>
You can install the executable directly from [the Node.js website](https://nodejs.org/en/#home-downloadhead).
You can install the executable directly from [the Node.js website](https://nodejs.org/en/#home-downloadhead).
For other approaches, you can check out [Node.js’s guide](https://nodejs.org/en/download/package-manager/#windows-1).
</TabItem>
<TabItem value="linux" label="Linux">
You can use the following commands to install Node.js on Ubuntu:
For other approaches, you can check out [Node.js’s guide](https://nodejs.org/en/download/package-manager/#windows-1).
```bash
#Ubuntu
sudo apt update
sudo apt install nodejs
```
</TabItem>
<TabItem value="linux" label="Linux">
For other Linux distributions, you can check out [Node.js’s guide](https://nodejs.org/en/download/package-manager/).
</TabItem>
<TabItem value="macos" label="macOS">
You can use the following commands to install Node.js on macOS:
You can use the following commands to install Node.js on Ubuntu:
<Tabs groupId="homebrew" isCodeTabs={true}>
<TabItem value="homebrew" label="Homebrew">
```bash
brew install node
```
</TabItem>
<TabItem value="no-homebrew" label="Without Homebrew">
```bash
curl \
"https://nodejs.org/dist/latest/node-${VERSION:-$(wget -qO- \
https://nodejs.org/dist/latest/ | sed -nE \
's|.*>node-(.*)\.pkg</a>.*|\1|p')}.pkg" \
> "$HOME/Downloads/node-latest.pkg" &&
sudo installer -store -pkg "$HOME/Downloads/node-latest.pkg" -target "/"
```
</TabItem>
</Tabs>
```bash
#Ubuntu
sudo apt update
sudo apt install nodejs
```
For other approaches, you can check out [Node.js’s guide](https://nodejs.org/en/download/package-manager/#macos).
For other Linux distributions, you can check out [Node.js’s guide](https://nodejs.org/en/download/package-manager/).
Make sure that you have Xcode command line tools installed. If not, run the following command to install it: `xcode-select --install`.
</TabItem>
<TabItem value="macos" label="macOS">
You can use the following commands to install Node.js on macOS:
<Tabs groupId="homebrew" isCodeTabs={true}>
<TabItem value="homebrew" label="Homebrew">
```bash
brew install node
```
</TabItem>
<TabItem value="no-homebrew" label="Without Homebrew">
```bash
curl \
"https://nodejs.org/dist/latest/node-${VERSION:-$(wget -qO- \
https://nodejs.org/dist/latest/ | sed -nE \
's|.*>node-(.*)\.pkg</a>.*|\1|p')}.pkg" \
> "$HOME/Downloads/node-latest.pkg" &&
sudo installer -store -pkg "$HOME/Downloads/node-latest.pkg" -target "/"
```
</TabItem>
</Tabs>
For other approaches, you can check out [Node.js’s guide](https://nodejs.org/en/download/package-manager/#macos).
:::tip
Make sure that you have Xcode command line tools installed; if not, run the following command to install it: `xcode-select --install`
:::
</TabItem>
</TabItem>
</Tabs>
## Git
@@ -86,35 +74,29 @@ Make sure that you have Xcode command line tools installed; if not, run the fol
Medusa uses Git behind the scenes when you create a new project. So, you'll have to install it on your machine to get started.
<Tabs groupId="operating-systems" queryString="os">
<TabItem value="windows" label="Windows" default>
<TabItem value="windows" label="Windows" default>
To install Git on Windows, you need to [download the installable package](https://git-scm.com/download/win).
</TabItem>
<TabItem value="linux" label="Linux">
For Debian/Ubuntu, you can use the following command:
To install Git on Windows, you need to [download the installable package](https://git-scm.com/download/win).
```bash
apt-get install git
```
</TabItem>
<TabItem value="linux" label="Linux">
As for other Linux distributions, please check [git’s guide](https://git-scm.com/download/linux).
</TabItem>
<TabItem value="macos" label="macOS">
You should already have Git installed as part of the Xcode command-line tools.
For Debian/Ubuntu, you can use the following command:
However, if for any reason you need to install it manually, you can install it with Homebrew:
```bash
apt-get install git
```
```bash
brew install git
```
As for other Linux distributions, please check [git’s guide](https://git-scm.com/download/linux).
</TabItem>
<TabItem value="macos" label="macOS">
You should already have Git installed as part of the Xcode command-line tools.
However, if for any reason you need to install it manually, you can install it with Homebrew:
```bash
brew install git
```
You can also check out [git’s guide](https://git-scm.com/download/mac) for more installation options.
</TabItem>
You can also check out [git’s guide](https://git-scm.com/download/mac) for more installation options.
</TabItem>
</Tabs>
## PostgreSQL
@@ -122,32 +104,26 @@ You can also check out [git’s guide](https://git-scm.com/download/mac) for mor
The Medusa backend uses PostgreSQL to store data of your commerce system.
<Tabs groupId="operating-systems" queryString="os">
<TabItem value="windows" label="Windows">
<TabItem value="windows" label="Windows">
You can [download the PostgreSQL Windows installer](https://www.postgresql.org/download/windows/) from their website.
</TabItem>
<TabItem value="linux" label="Linux">
If you’re using Ubuntu, you can use the following commands to download and install PostgreSQL:
You can [download the PostgreSQL Windows installer](https://www.postgresql.org/download/windows/) from their website.
```bash
sudo sh -c \
'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - \
https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql
```
</TabItem>
<TabItem value="linux" label="Linux">
If you’re using Ubuntu, you can use the following commands to download and install PostgreSQL:
```bash
sudo sh -c \
'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - \
https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql
```
For other distributions, you can check out [PostgreSQL’s website for more guides](https://www.postgresql.org/download/linux/).
</TabItem>
<TabItem value="macos" label="macOS">
You can download PostgreSQL on your macOS using [the installer on their website](https://www.postgresql.org/download/macosx/).
</TabItem>
For other distributions, you can check out [PostgreSQL’s website for more guides](https://www.postgresql.org/download/linux/).
</TabItem>
<TabItem value="macos" label="macOS">
You can download PostgreSQL on your macOS using [the installer on their website](https://www.postgresql.org/download/macosx/).
</TabItem>
</Tabs>
## (Optional) Medusa CLI
@@ -293,54 +293,54 @@ The first step is to create a batch job using the [Create Batch Job API Route](h
For example, this creates a batch job of the type `publish-products`:
<Tabs groupId="request-types" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```jsx
medusa.admin.batchJobs.create({
type: "publish-products",
context: { },
dry_run: true,
})
.then(( batch_job ) => {
console.log(batch_job.status)
})
```
```jsx
medusa.admin.batchJobs.create({
type: "publish-products",
context: { },
dry_run: true,
})
.then(( batch_job ) => {
console.log(batch_job.status)
})
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```jsx
fetch(`<BACKEND_URL>/admin/batch-jobs`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
type: "publish-products",
context: { },
dry_run: true,
}),
})
.then((response) => response.json())
.then(({ batch_job }) => {
console.log(batch_job.status)
})
```
```jsx
fetch(`<BACKEND_URL>/admin/batch-jobs`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
type: "publish-products",
context: { },
dry_run: true,
}),
})
.then((response) => response.json())
.then(({ batch_job }) => {
console.log(batch_job.status)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/batch-jobs' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"type": "publish-products",
"context": { },
"dry_run": true
}'
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/batch-jobs' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"type": "publish-products",
"context": { },
"dry_run": true
}'
```
</TabItem>
</Tabs>
@@ -354,38 +354,38 @@ Make sure to replace `<BACKEND_URL>` with the backend URL where applicable.
You can retrieve the batch job afterward to get its status and view details about the process in the `result` property:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```jsx
medusa.admin.batchJobs.retrieve(batchJobId)
.then(( batch_job ) => {
console.log(batch_job.status, batch_job.result)
})
```
```jsx
medusa.admin.batchJobs.retrieve(batchJobId)
.then(( batch_job ) => {
console.log(batch_job.status, batch_job.result)
})
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```jsx
fetch(`<BACKEND_URL>/admin/batch-jobs/${batchJobId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ batch_job }) => {
console.log(batch_job.status, batch_job.result)
})
```
```jsx
fetch(`<BACKEND_URL>/admin/batch-jobs/${batchJobId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ batch_job }) => {
console.log(batch_job.status, batch_job.result)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/batch-jobs/<BATCH_JOB_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
# <BATCH_JOB_ID> is the ID of the batch job
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/batch-jobs/<BATCH_JOB_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
# <BATCH_JOB_ID> is the ID of the batch job
```
</TabItem>
</TabItem>
</Tabs>
Based on the batch job strategy implemented in this documentation, the `result` property could be something like this:
@@ -409,39 +409,39 @@ Based on the batch job strategy implemented in this documentation, the `result`
To process the batch job, send a request to [confirm the batch job](https://docs.medusajs.com/api/admin#batch-jobs_postbatchjobsbatchjobconfirmprocessing):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```jsx
medusa.admin.batchJobs.confirm(batchJobId)
.then(( batch_job ) => {
console.log(batch_job.status)
})
```
```jsx
medusa.admin.batchJobs.confirm(batchJobId)
.then(( batch_job ) => {
console.log(batch_job.status)
})
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```jsx
fetch(`<BACKEND_URL>/admin/batch-jobs/${batchJobId}/confirm`, {
method: "POST",
credentials: "include",
})
.then((response) => response.json())
.then(({ batch_job }) => {
console.log(batch_job.status)
})
```
```jsx
fetch(`<BACKEND_URL>/admin/batch-jobs/${batchJobId}/confirm`, {
method: "POST",
credentials: "include",
})
.then((response) => response.json())
.then(({ batch_job }) => {
console.log(batch_job.status)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/batch-jobs/<BATCH_JOB_ID>/confirm' \
-H 'Authorization: Bearer <API_TOKEN>'
# <BATCH_JOB_ID> is the ID of the batch job
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/batch-jobs/<BATCH_JOB_ID>/confirm' \
-H 'Authorization: Bearer <API_TOKEN>'
# <BATCH_JOB_ID> is the ID of the batch job
```
</TabItem>
</TabItem>
</Tabs>
The batch job will start processing afterward. Based on the batch job strategy implemented in this documentation, draft products will be published.
@@ -70,71 +70,71 @@ Your entity may be related to another entity. You can showcase the relation with
For example, you can create another entity `Author` and add a `ManyToOne` relation to it from the `Post`, and a `OneToMany` relation from the `Author` to the `Post`:
<Tabs groupId="files" isCodeTabs={true}>
<TabItem value="post" label="src/models/post.ts" default>
<TabItem value="post" label="src/models/post.ts" default>
```ts
import {
BeforeInsert,
Column,
Entity,
JoinColumn,
ManyToOne,
} from "typeorm"
import { BaseEntity } from "@medusajs/medusa"
import { generateEntityId } from "@medusajs/medusa/dist/utils"
import { Author } from "./author"
```ts
import {
BeforeInsert,
Column,
Entity,
JoinColumn,
ManyToOne,
} from "typeorm"
import { BaseEntity } from "@medusajs/medusa"
import { generateEntityId } from "@medusajs/medusa/dist/utils"
import { Author } from "./author"
@Entity()
export class Post extends BaseEntity {
@Column({ type: "varchar" })
title: string | null
@Entity()
export class Post extends BaseEntity {
@Column({ type: "varchar" })
title: string | null
@Column({ type: "varchar" })
author_id: string
@Column({ type: "varchar" })
author_id: string
@ManyToOne(() => Author, (author) => author.posts)
@JoinColumn({ name: "author_id" })
author: Author
@ManyToOne(() => Author, (author) => author.posts)
@JoinColumn({ name: "author_id" })
author: Author
@BeforeInsert()
private beforeInsert(): void {
this.id = generateEntityId(this.id, "post")
}
}
```
@BeforeInsert()
private beforeInsert(): void {
this.id = generateEntityId(this.id, "post")
}
}
```
</TabItem>
<TabItem value="author" label="src/models/author.ts">
</TabItem>
<TabItem value="author" label="src/models/author.ts">
```ts
import { BaseEntity, generateEntityId } from "@medusajs/medusa"
import {
BeforeInsert,
Column,
Entity,
OneToMany,
} from "typeorm"
import { Post } from "./post"
```ts
import { BaseEntity, generateEntityId } from "@medusajs/medusa"
import {
BeforeInsert,
Column,
Entity,
OneToMany,
} from "typeorm"
import { Post } from "./post"
@Entity()
export class Author extends BaseEntity {
@Column({ type: "varchar" })
name: string
@Entity()
export class Author extends BaseEntity {
@Column({ type: "varchar" })
name: string
@Column({ type: "varchar", nullable: true })
image?: string
@Column({ type: "varchar", nullable: true })
image?: string
@OneToMany(() => Post, (post) => post.author)
posts: Post[]
@OneToMany(() => Post, (post) => post.author)
posts: Post[]
@BeforeInsert()
private beforeInsert(): void {
this.id = generateEntityId(this.id, "auth")
}
}
```
@BeforeInsert()
private beforeInsert(): void {
this.id = generateEntityId(this.id, "auth")
}
}
```
</TabItem>
</TabItem>
</Tabs>
Adding these relations allows you to later on expand these relations when retrieving records of this entity with repositories.
@@ -417,24 +417,21 @@ While you develop your plugin, you’ll need to test it on an actual Medusa back
<Tabs groupId="plugin-preference">
<TabItem value="without-admin" label="Without Admin Customizations" default>
In the root of your plugin directory, run the `build` command:
In the root of your plugin directory, run the `build` command:
```bash
npm run build
```
```bash
npm run build
```
</TabItem>
<TabItem value="with-admin" label="With Admin Customizations">
In the root of your plugin directory, run the `prepare` command:
In the root of your plugin directory, run the `prepare` command:
```bash
npm run prepare
```
If the `prepare` script is not available in your project, you can find it in [this section](#changes-for-admin-plugins).
```bash
npm run prepare
```
If the `prepare` script is not available in your project, you can find it in [this section](#changes-for-admin-plugins).
</TabItem>
</Tabs>
@@ -499,30 +496,30 @@ In the directory of the Medusa backend, start the backend with the `dev` command
<Tabs groupId="npm2yarn" isCodeTabs={true}>
<TabItem value="npm" label="npm" default>
```bash
npm run dev -- -- --preserve-symlinks
```
```bash
npm run dev -- -- --preserve-symlinks
```
</TabItem>
<TabItem value="yarn-1" label="Yarn v1">
```bash
yarn dev -- -- --preserve-symlinks
```
```bash
yarn dev -- -- --preserve-symlinks
```
</TabItem>
<TabItem value="yarn-berry" label="Yarn berry">
```bash
yarn dev -- --preserve-symlinks
```
```bash
yarn dev -- --preserve-symlinks
```
</TabItem>
<TabItem value="pnpm" label="pnpm">
```bash
pnpm run dev -- -- --preserve-symlinks
```
```bash
pnpm run dev -- -- --preserve-symlinks
```
</TabItem>
</Tabs>
@@ -45,40 +45,36 @@ Before publishing your plugin, make sure you've set the following fields in your
<Tabs groupId="plugin-preference">
<TabItem value="without-admin" label="Without Admin Customizations" default>
Make sure you add the `publish` script to your `scripts` field:
Make sure you add the `publish` script to your `scripts` field:
```json title=package.json
"scripts": {
// other scripts...
"build": "cross-env npm run clean && tsc -p tsconfig.json",
"prepare": "cross-env NODE_ENV=production npm run build"
}
```
```json title=package.json
"scripts": {
// other scripts...
"build": "cross-env npm run clean && tsc -p tsconfig.json",
"prepare": "cross-env NODE_ENV=production npm run build"
}
```
The `build` script ensures that the plugin's built files are placed as explained in the [plugin structure](./create.mdx#plugin-structure) section of the Create Plugin documentation.
The `prepare` script facilitates your publishing process. You would typically run this script before publishing your plugin.
The `build` script ensures that the plugin's built files are placed as explained in the [plugin structure](./create.mdx#plugin-structure) section of the Create Plugin documentation.
The `prepare` script facilitates your publishing process. You would typically run this script before publishing your plugin.
</TabItem>
<TabItem value="with-admin" label="With Admin Customizations">
First, make sure to change `tsconfig` files as recommended in the [create guide](./create.mdx#changes-for-admin-plugins).
First, make sure to change `tsconfig` files as recommended in the [create guide](./create.mdx#changes-for-admin-plugins).
Then, add the following `prepare` and `build` scripts to your `scripts`
Then, add the following `prepare` and `build` scripts to your `scripts`
```json title=package.json
"scripts": {
// other scripts...
"build:server": "cross-env npm run clean && tsc -p tsconfig.json",
"prepare": "cross-env NODE_ENV=production npm run build:server && medusa-admin bundle"
}
```
The `build:server` script builds the resources of the backend for development and ensures they are placed as explained in the [plugin structure](./create.mdx#plugin-structure) section of the Create Plugin documentation.
The `prepare` script creates a production build of both backend and admin resources.
```json title=package.json
"scripts": {
// other scripts...
"build:server": "cross-env npm run clean && tsc -p tsconfig.json",
"prepare": "cross-env NODE_ENV=production npm run build:server && medusa-admin bundle"
}
```
The `build:server` script builds the resources of the backend for development and ensures they are placed as explained in the [plugin structure](./create.mdx#plugin-structure) section of the Create Plugin documentation.
The `prepare` script creates a production build of both backend and admin resources.
</TabItem>
</Tabs>
@@ -424,249 +424,249 @@ In this section, you'll find a full example of the `PostService` and `AuthorServ
You can refer to the [Entities](../entities/create.mdx#adding-relations) documentation to learn how to create the custom entities used in this example.
<Tabs groupId="files" isCodeTabs={true}>
<TabItem value="post" label="src/services/post.ts" default>
<TabItem value="post" label="src/services/post.ts" default>
```ts
import {
FindConfig,
Selector,
TransactionBaseService,
buildQuery,
} from "@medusajs/medusa"
import { PostRepository } from "../repositories/post"
import { Post } from "../models/post"
import { MedusaError } from "@medusajs/utils"
```ts
import {
FindConfig,
Selector,
TransactionBaseService,
buildQuery,
} from "@medusajs/medusa"
import { PostRepository } from "../repositories/post"
import { Post } from "../models/post"
import { MedusaError } from "@medusajs/utils"
class PostService extends TransactionBaseService {
protected postRepository_: typeof PostRepository
class PostService extends TransactionBaseService {
protected postRepository_: typeof PostRepository
constructor(container) {
super(container)
this.postRepository_ = container.postRepository
}
constructor(container) {
super(container)
this.postRepository_ = container.postRepository
}
async listAndCount(
selector?: Selector<Post>,
config: FindConfig<Post> = {
skip: 0,
take: 20,
relations: [],
}): Promise<[Post[], number]> {
const postRepo = this.activeManager_.withRepository(
this.postRepository_
)
async listAndCount(
selector?: Selector<Post>,
config: FindConfig<Post> = {
skip: 0,
take: 20,
relations: [],
}): Promise<[Post[], number]> {
const postRepo = this.activeManager_.withRepository(
this.postRepository_
)
const query = buildQuery(selector, config)
const query = buildQuery(selector, config)
return postRepo.findAndCount(query)
}
async list(
selector?: Selector<Post>,
config: FindConfig<Post> = {
skip: 0,
take: 20,
relations: [],
}): Promise<Post[]> {
const [posts] = await this.listAndCount(selector, config)
return postRepo.findAndCount(query)
}
async list(
selector?: Selector<Post>,
config: FindConfig<Post> = {
skip: 0,
take: 20,
relations: [],
}): Promise<Post[]> {
const [posts] = await this.listAndCount(selector, config)
return posts
}
return posts
}
async retrieve(
id: string,
config?: FindConfig<Post>
): Promise<Post> {
const postRepo = this.activeManager_.withRepository(
this.postRepository_
)
async retrieve(
id: string,
config?: FindConfig<Post>
): Promise<Post> {
const postRepo = this.activeManager_.withRepository(
this.postRepository_
)
const query = buildQuery({
id,
}, config)
const query = buildQuery({
id,
}, config)
const post = await postRepo.findOne(query)
const post = await postRepo.findOne(query)
if (!post) {
throw new MedusaError(
MedusaError.Types.NOT_FOUND,
"Post was not found"
)
if (!post) {
throw new MedusaError(
MedusaError.Types.NOT_FOUND,
"Post was not found"
)
}
return post
}
async create(
data: Pick<Post, "title" | "author_id">
): Promise<Post> {
return this.atomicPhase_(async (manager) => {
const postRepo = manager.withRepository(
this.postRepository_
)
const post = postRepo.create()
post.title = data.title
post.author_id = data.author_id
const result = await postRepo.save(post)
return result
})
}
async update(
id: string,
data: Omit<Partial<Post>, "id">
): Promise<Post> {
return await this.atomicPhase_(async (manager) => {
const postRepo = manager.withRepository(
this.postRepository_
)
const post = await this.retrieve(id)
Object.assign(post, data)
return await postRepo.save(post)
})
}
async delete(id: string): Promise<void> {
return await this.atomicPhase_(async (manager) => {
const postRepo = manager.withRepository(
this.postRepository_
)
const post = await this.retrieve(id)
await postRepo.remove([post])
})
}
}
return post
}
export default PostService
```
async create(
data: Pick<Post, "title" | "author_id">
): Promise<Post> {
return this.atomicPhase_(async (manager) => {
const postRepo = manager.withRepository(
this.postRepository_
)
const post = postRepo.create()
post.title = data.title
post.author_id = data.author_id
const result = await postRepo.save(post)
</TabItem>
<TabItem value="author" label="src/services/author.ts">
return result
})
}
```ts
import {
FindConfig,
Selector,
TransactionBaseService,
buildQuery,
} from "@medusajs/medusa"
import { EntityManager } from "typeorm"
import AuthorRepository from "../repositories/author"
import { Author } from "../models/author"
import { MedusaError } from "@medusajs/utils"
async update(
id: string,
data: Omit<Partial<Post>, "id">
): Promise<Post> {
return await this.atomicPhase_(async (manager) => {
const postRepo = manager.withRepository(
this.postRepository_
)
const post = await this.retrieve(id)
class AuthorService extends TransactionBaseService {
protected manager_: EntityManager
protected transactionManager_: EntityManager
protected authorRepository_: typeof AuthorRepository
Object.assign(post, data)
constructor(container) {
super(container)
this.authorRepository_ = container.authorRepository
}
return await postRepo.save(post)
})
}
async listAndCount(
selector?: Selector<Author>,
config: FindConfig<Author> = {
skip: 0,
take: 20,
relations: [],
}): Promise<[Author[], number]> {
const authorRepo = this.activeManager_.withRepository(
this.authorRepository_
)
async delete(id: string): Promise<void> {
return await this.atomicPhase_(async (manager) => {
const postRepo = manager.withRepository(
this.postRepository_
)
const post = await this.retrieve(id)
const query = buildQuery(selector, config)
return authorRepo.findAndCount(query)
}
await postRepo.remove([post])
})
}
}
async list(
selector?: Selector<Author>,
config: FindConfig<Author> = {
skip: 0,
take: 20,
relations: [],
}): Promise<Author[]> {
const [authors] = await this.listAndCount(selector, config)
export default PostService
```
return authors
}
</TabItem>
<TabItem value="author" label="src/services/author.ts">
async retrieve(
id: string,
config?: FindConfig<Author>
): Promise<Author> {
const authorRepo = this.activeManager_.withRepository(
this.authorRepository_
)
```ts
import {
FindConfig,
Selector,
TransactionBaseService,
buildQuery,
} from "@medusajs/medusa"
import { EntityManager } from "typeorm"
import AuthorRepository from "../repositories/author"
import { Author } from "../models/author"
import { MedusaError } from "@medusajs/utils"
const query = buildQuery({
id,
}, config)
class AuthorService extends TransactionBaseService {
protected manager_: EntityManager
protected transactionManager_: EntityManager
protected authorRepository_: typeof AuthorRepository
const author = await authorRepo.findOne(query)
constructor(container) {
super(container)
this.authorRepository_ = container.authorRepository
}
if (!author) {
throw new MedusaError(
MedusaError.Types.NOT_FOUND,
"Author was not found"
)
}
async listAndCount(
selector?: Selector<Author>,
config: FindConfig<Author> = {
skip: 0,
take: 20,
relations: [],
}): Promise<[Author[], number]> {
const authorRepo = this.activeManager_.withRepository(
this.authorRepository_
)
return
}
const query = buildQuery(selector, config)
async create(
data: Pick<Author, "name" | "image">
): Promise<Author> {
return this.atomicPhase_(async (manager) => {
const authorRepo = manager.withRepository(
this.authorRepository_
)
const post = authorRepo.create(data)
const result = await authorRepo.save(post)
return authorRepo.findAndCount(query)
}
async list(
selector?: Selector<Author>,
config: FindConfig<Author> = {
skip: 0,
take: 20,
relations: [],
}): Promise<Author[]> {
const [authors] = await this.listAndCount(selector, config)
return result
})
}
return authors
}
async update(
id: string,
data: Omit<Partial<Author>, "id">
): Promise<Author> {
return await this.atomicPhase_(async (manager) => {
const authorRepo = manager.withRepository(
this.authorRepository_
)
const post = await this.retrieve(id)
Object.assign(post, data)
async retrieve(
id: string,
config?: FindConfig<Author>
): Promise<Author> {
const authorRepo = this.activeManager_.withRepository(
this.authorRepository_
)
return await authorRepo.save(post)
})
}
const query = buildQuery({
id,
}, config)
const author = await authorRepo.findOne(query)
if (!author) {
throw new MedusaError(
MedusaError.Types.NOT_FOUND,
"Author was not found"
)
async delete(id: string): Promise<void> {
return await this.atomicPhase_(async (manager) => {
const authorRepo = manager.withRepository(
this.authorRepository_
)
const post = await this.retrieve(id)
await authorRepo.remove([post])
})
}
}
return
}
export default AuthorService
```
async create(
data: Pick<Author, "name" | "image">
): Promise<Author> {
return this.atomicPhase_(async (manager) => {
const authorRepo = manager.withRepository(
this.authorRepository_
)
const post = authorRepo.create(data)
const result = await authorRepo.save(post)
return result
})
}
async update(
id: string,
data: Omit<Partial<Author>, "id">
): Promise<Author> {
return await this.atomicPhase_(async (manager) => {
const authorRepo = manager.withRepository(
this.authorRepository_
)
const post = await this.retrieve(id)
Object.assign(post, data)
return await authorRepo.save(post)
})
}
async delete(id: string): Promise<void> {
return await this.atomicPhase_(async (manager) => {
const authorRepo = manager.withRepository(
this.authorRepository_
)
const post = await this.retrieve(id)
await authorRepo.remove([post])
})
}
}
export default AuthorService
```
</TabItem>
</TabItem>
</Tabs>
---
+100 -102
View File
@@ -2,8 +2,8 @@
description: 'Learn how to install the Medusa JS Client in a storefront. Medusa JS Client provides easy access to the Medusa API from a client written in TypeScript.'
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
# Medusa JS Client
@@ -39,30 +39,28 @@ Where `MEDUSA_BACKEND_URL` is the URL to your Medusa backend. If the `baseUrl` o
After initialization, you can use the client's properties and methods to send requests to the Medusa backend.
<details>
<summary>
Troubleshooting: Could not find a declaration file for module '@medusajs/medusa-js'
</summary>
<Details>
<Summary>Troubleshooting: Could not find a declaration file for module '@medusajs/medusa-js'</Summary>
If you import `@medusajs/medusa-js` in your code and see the following TypeScript error:
If you import `@medusajs/medusa-js` in your code and see the following TypeScript error:
```bash
Could not find a declaration file for module '@medusajs/medusa-js'
```
```bash
Could not find a declaration file for module '@medusajs/medusa-js'
```
Make sure to set `moduleResolution` in your `tsconfig.json` to `nodenext` or `node`:
Make sure to set `moduleResolution` in your `tsconfig.json` to `nodenext` or `node`:
```json title=tsconfig.json
{
"compilerOptions": {
"moduleResolution": "nodenext",
```json title=tsconfig.json
{
"compilerOptions": {
"moduleResolution": "nodenext",
// ...
},
// ...
},
// ...
}
```
}
```
</details>
</Details>
## How to Use this Reference
@@ -128,38 +126,38 @@ Once the user or customer is authenticated successfully, the Medusa client autom
For example:
<Tabs groupId="client-authentication-type" isCodeTabs={true}>
<TabItem value="user" label="Admin User" default>
<TabItem value="user" label="Admin User" default>
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({
baseUrl: MEDUSA_BACKEND_URL,
maxRetries: 3,
})
await medusa.admin.auth.getToken({
email: "user@example.com",
password: "supersecret",
})
// send authenticated requests now
```
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({
baseUrl: MEDUSA_BACKEND_URL,
maxRetries: 3,
})
await medusa.admin.auth.getToken({
email: "user@example.com",
password: "supersecret",
})
// send authenticated requests now
```
</TabItem>
<TabItem value="customer" label="Customer">
</TabItem>
<TabItem value="customer" label="Customer">
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({
baseUrl: MEDUSA_BACKEND_URL,
maxRetries: 3,
})
await medusa.auth.getToken({
email: "user@example.com",
password: "supersecret",
})
// send authenticated requests now
```
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({
baseUrl: MEDUSA_BACKEND_URL,
maxRetries: 3,
})
await medusa.auth.getToken({
email: "user@example.com",
password: "supersecret",
})
// send authenticated requests now
```
</TabItem>
</TabItem>
</Tabs>
### Cookie Session ID
@@ -173,38 +171,38 @@ Once the user or customer is authenticated successfully, the Medusa client sets
For example:
<Tabs groupId="client-authentication-type" isCodeTabs={true}>
<TabItem value="user" label="Admin User" default>
<TabItem value="user" label="Admin User" default>
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({
baseUrl: MEDUSA_BACKEND_URL,
maxRetries: 3,
})
await medusa.admin.AdminAuthResource.createSession({
email: "user@example.com",
password: "supersecret",
})
// send authenticated requests now
```
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({
baseUrl: MEDUSA_BACKEND_URL,
maxRetries: 3,
})
await medusa.admin.AdminAuthResource.createSession({
email: "user@example.com",
password: "supersecret",
})
// send authenticated requests now
```
</TabItem>
<TabItem value="customer" label="Customer">
</TabItem>
<TabItem value="customer" label="Customer">
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({
baseUrl: MEDUSA_BACKEND_URL,
maxRetries: 3,
})
await medusa.auth.authenticate({
email: "user@example.com",
password: "user@example.com",
})
// send authenticated requests now
```
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({
baseUrl: MEDUSA_BACKEND_URL,
maxRetries: 3,
})
await medusa.auth.authenticate({
email: "user@example.com",
password: "user@example.com",
})
// send authenticated requests now
```
</TabItem>
</TabItem>
</Tabs>
### API Key
@@ -214,36 +212,36 @@ You can authenticate admin users with a personal API Token.
If a user doesn't have a personal API token, create one with the [admin.users.update](../references/js-client/classes/AdminUsersResource.mdx#update) method:
<Tabs groupId="client-type" isCodeTabs={true}>
<TabItem value="js-client" label="JS Client" default>
<TabItem value="js-client" label="JS Client" default>
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({
baseUrl: MEDUSA_BACKEND_URL,
maxRetries: 3,
})
// must be previously logged in or use api token
medusa.admin.users.update(userId, {
api_token,
})
.then(({ user }) => {
console.log(user.api_token)
})
```
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({
baseUrl: MEDUSA_BACKEND_URL,
maxRetries: 3,
})
// must be previously logged in or use api token
medusa.admin.users.update(userId, {
api_token,
})
.then(({ user }) => {
console.log(user.api_token)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/users/<USER_ID>' \\
-H 'Cookie: connect.sid={sid}' \\
-H 'Content-Type: application/json' \\
--data-raw '{
"api_token": "{api_token}"
}'
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/users/<USER_ID>' \\
-H 'Cookie: connect.sid={sid}' \\
-H 'Content-Type: application/json' \\
--data-raw '{
"api_token": "{api_token}"
}'
```
</TabItem>
</TabItem>
</Tabs>
Then, initialize the Medusa client passing it the `apiKey` option:
+96 -96
View File
@@ -235,110 +235,110 @@ The request returns an object containing keys like `data` which is an object tha
For example:
<Tabs groupId="admin-custom-query" isCodeTabs={true}>
<TabItem value="post-page" label="src/admin/routes/blog/posts/[id]/page.tsx" default>
<TabItem value="post-page" label="src/admin/routes/blog/posts/[id]/page.tsx" default>
```tsx
import { useAdminCustomQuery } from "medusa-react"
import { useParams } from "react-router-dom"
```tsx
import { useAdminCustomQuery } from "medusa-react"
import { useParams } from "react-router-dom"
type BlogPost = {
title: string,
content: string,
author_id: string,
}
// Single post
type AdminBlogPostQuery = {
expand?: string,
fields?: string
}
type AdminBlogPostRes = {
post: BlogPost,
}
const BlogPost = () => {
const { id } = useParams()
const { data, isLoading } = useAdminCustomQuery<
AdminBlogPostQuery,
AdminBlogPostRes
>(
`/blog/posts/${id}`, // path
["blog-post", id], // queryKey
{
expand: "author", // query
type BlogPost = {
title: string,
content: string,
author_id: string,
}
)
return (
<>
{isLoading && <span>Loading...</span>}
{data && data.post && <span>{data.post.title}</span>}
</>
)
}
export default BlogPost
```
</TabItem>
<TabItem value="posts-page" label="src/admin/routes/blog/author/[id]/posts/page.tsx">
```tsx
import { useAdminCustomQuery } from "medusa-react"
import { useParams } from "react-router-dom"
type BlogPost = {
title: string,
content: string,
author_id: string,
}
type AdminBlogPostsRes = {
posts: BlogPost[],
count: number
}
type AdminBlogPostsQuery = {
author_id: string,
created_at?: string,
expand?: string,
fields?: string
}
const AuthorsBlogPosts = () => {
const { id } = useParams()
const { data, isLoading } = useAdminCustomQuery<
AdminBlogPostsQuery, AdminBlogPostsRes
>(
`/blog/posts`, // path
["blog-posts", "list", id], // queryKey
{
expand: "author", // query
author_id: "auth_123",
// Single post
type AdminBlogPostQuery = {
expand?: string,
fields?: string
}
)
return (
<>
{isLoading && <span>Loading...</span>}
{data && data.posts && (
<span>
{data.posts.map((post, index) => (
<span key={index}>{post.title}</span>
))}
</span>
)}
</>
)
}
type AdminBlogPostRes = {
post: BlogPost,
}
export default AuthorsBlogPosts
```
const BlogPost = () => {
const { id } = useParams()
</TabItem>
const { data, isLoading } = useAdminCustomQuery<
AdminBlogPostQuery,
AdminBlogPostRes
>(
`/blog/posts/${id}`, // path
["blog-post", id], // queryKey
{
expand: "author", // query
}
)
return (
<>
{isLoading && <span>Loading...</span>}
{data && data.post && <span>{data.post.title}</span>}
</>
)
}
export default BlogPost
```
</TabItem>
<TabItem value="posts-page" label="src/admin/routes/blog/author/[id]/posts/page.tsx">
```tsx
import { useAdminCustomQuery } from "medusa-react"
import { useParams } from "react-router-dom"
type BlogPost = {
title: string,
content: string,
author_id: string,
}
type AdminBlogPostsRes = {
posts: BlogPost[],
count: number
}
type AdminBlogPostsQuery = {
author_id: string,
created_at?: string,
expand?: string,
fields?: string
}
const AuthorsBlogPosts = () => {
const { id } = useParams()
const { data, isLoading } = useAdminCustomQuery<
AdminBlogPostsQuery, AdminBlogPostsRes
>(
`/blog/posts`, // path
["blog-posts", "list", id], // queryKey
{
expand: "author", // query
author_id: "auth_123",
}
)
return (
<>
{isLoading && <span>Loading...</span>}
{data && data.posts && (
<span>
{data.posts.map((post, index) => (
<span key={index}>{post.title}</span>
))}
</span>
)}
</>
)
}
export default AuthorsBlogPosts
```
</TabItem>
</Tabs>
#### useAdminCustomPost
@@ -53,60 +53,60 @@ It's also assumed you already have [used CartProvider higher in your component t
You can create a cart with the following code snippet:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.carts.create()
.then(({ cart }) => {
localStorage.setItem("cart_id", cart.id)
// assuming you have a state variable to store the cart
setCart(cart)
})
```
```ts
medusa.carts.create()
.then(({ cart }) => {
localStorage.setItem("cart_id", cart.id)
// assuming you have a state variable to store the cart
setCart(cart)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCart } from "medusa-react"
```tsx
import { useCart } from "medusa-react"
const Cart = () => {
const { cart, createCart } = useCart()
const Cart = () => {
const { cart, createCart } = useCart()
const handleCreateCart = () => {
createCart.mutate(
{}, // create an empty cart
{
onSuccess: ({ cart }) => {
localStorage.setItem("cart_id", cart.id)
},
const handleCreateCart = () => {
createCart.mutate(
{}, // create an empty cart
{
onSuccess: ({ cart }) => {
localStorage.setItem("cart_id", cart.id)
},
}
)
}
)
}
// ...
}
// ...
}
export default Cart
```
export default Cart
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URLL>/store/carts`, {
method: "POST",
credentials: "include",
})
.then((response) => response.json())
.then(({ cart }) => {
localStorage.setItem("cart_id", cart.id)
// assuming you have a state variable to store the cart
setCart(cart)
})
```
```ts
fetch(`<BACKEND_URLL>/store/carts`, {
method: "POST",
credentials: "include",
})
.then((response) => response.json())
.then(({ cart }) => {
localStorage.setItem("cart_id", cart.id)
// assuming you have a state variable to store the cart
setCart(cart)
})
```
</TabItem>
</TabItem>
</Tabs>
This request does not require any parameters. It returns the created cart in the response.
@@ -116,70 +116,70 @@ The cart by default will have a random region assigned to it. You can specify th
Otherwise, you can assign it a specific region during creation:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```jsx
medusa.carts.create({
region_id,
})
.then(({ cart }) => {
localStorage.setItem("cart_id", cart.id)
// assuming you have a state variable to store the cart
setCart(cart)
})
```
```jsx
medusa.carts.create({
region_id,
})
.then(({ cart }) => {
localStorage.setItem("cart_id", cart.id)
// assuming you have a state variable to store the cart
setCart(cart)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCart } from "medusa-react"
```tsx
import { useCart } from "medusa-react"
const Cart = () => {
const { cart, createCart } = useCart()
const Cart = () => {
const { cart, createCart } = useCart()
const handleCreateCart = () => {
createCart.mutate(
{
region_id,
},
{
onSuccess: ({ cart }) => {
localStorage.setItem("cart_id", cart.id)
},
const handleCreateCart = () => {
createCart.mutate(
{
region_id,
},
{
onSuccess: ({ cart }) => {
localStorage.setItem("cart_id", cart.id)
},
}
)
}
)
}
// ...
}
// ...
}
export default Cart
```
export default Cart
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```jsx
fetch(`<BACKEND_URLL>/store/carts`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
region_id,
}),
})
.then((response) => response.json())
.then(({ cart }) => {
localStorage.setItem("cart_id", cart.id)
// assuming you have a state variable to store the cart
setCart(cart)
})
```
```jsx
fetch(`<BACKEND_URLL>/store/carts`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
region_id,
}),
})
.then((response) => response.json())
.then(({ cart }) => {
localStorage.setItem("cart_id", cart.id)
// assuming you have a state variable to store the cart
setCart(cart)
})
```
</TabItem>
</TabItem>
</Tabs>
Check out the [API Reference](https://docs.medusajs.com/api/store#carts_postcart) for a full list of available request body parameters.
@@ -199,52 +199,52 @@ Notice that in the previous code snippets, you set the cart’s ID in the local
You can retrieve the cart at any given point using its ID with the following code snippet:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
const id = localStorage.getItem("cart_id")
```ts
const id = localStorage.getItem("cart_id")
if (id) {
medusa.carts.retrieve(id)
.then(({ cart }) => setCart(cart))
}
```
if (id) {
medusa.carts.retrieve(id)
.then(({ cart }) => setCart(cart))
}
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React" default>
</TabItem>
<TabItem value="medusa-react" label="Medusa React" default>
```tsx
import { useCart } from "medusa-react"
```tsx
import { useCart } from "medusa-react"
const Cart = () => {
const { cart } = useCart()
const Cart = () => {
const { cart } = useCart()
return (
<div>
Items in Cart: {cart?.items.length || 0}
</div>
)
}
return (
<div>
Items in Cart: {cart?.items.length || 0}
</div>
)
}
export default Cart
```
export default Cart
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
const id = localStorage.getItem("cart_id")
```ts
const id = localStorage.getItem("cart_id")
if (id) {
fetch(`<BACKEND_URLL>/store/carts/${id}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ cart }) => setCart(cart))
}
```
if (id) {
fetch(`<BACKEND_URLL>/store/carts/${id}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ cart }) => setCart(cart))
}
```
</TabItem>
</TabItem>
</Tabs>
This request accepts the ID of the cart as a path parameter and returns the cart of that ID.
@@ -266,57 +266,57 @@ A cart has different data associated with it including the region, email, addres
You can use the following snippet to update any of the cart’s data:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.carts.update(cartId, {
region_id,
})
.then(({ cart }) => setCart(cart))
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCart } from "medusa-react"
const Cart = () => {
// ...
const { updateCart } = useCart()
const changeRegionId = (region_id: string) => {
updateCart.mutate({
```ts
medusa.carts.update(cartId, {
region_id,
})
}
.then(({ cart }) => setCart(cart))
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default Cart
```
```tsx
import { useCart } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const Cart = () => {
// ...
```ts
fetch(`<BACKEND_URLL>/store/carts/${cartId}`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
region_id,
}),
})
.then((response) => response.json())
.then(({ cart }) => setCart(cart))
```
const { updateCart } = useCart()
</TabItem>
const changeRegionId = (region_id: string) => {
updateCart.mutate({
region_id,
})
}
// ...
}
export default Cart
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URLL>/store/carts/${cartId}`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
region_id,
}),
})
.then((response) => response.json())
.then(({ cart }) => setCart(cart))
```
</TabItem>
</Tabs>
This request accepts the ID of the cart as a path parameter. In its body, you can pass any data you want to update in the cart such as the region.
@@ -332,57 +332,57 @@ A customer might add items to their cart, then creates an account or log in. In
You can do that using the same update operation:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.carts.update(cartId, {
customer_id,
})
.then(({ cart }) => setCart(cart))
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCart } from "medusa-react"
const Cart = () => {
// ...
const { updateCart } = useCart()
const changeCustomerId = (customer_id: string) => {
updateCart.mutate({
```ts
medusa.carts.update(cartId, {
customer_id,
})
}
.then(({ cart }) => setCart(cart))
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default Cart
```
```tsx
import { useCart } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const Cart = () => {
// ...
```ts
fetch(`<BACKEND_URLL>/store/carts/${cartId}`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
customer_id,
}),
})
.then((response) => response.json())
.then(({ cart }) => setCart(cart))
```
const { updateCart } = useCart()
</TabItem>
const changeCustomerId = (customer_id: string) => {
updateCart.mutate({
customer_id,
})
}
// ...
}
export default Cart
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URLL>/store/carts/${cartId}`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
customer_id,
}),
})
.then((response) => response.json())
.then(({ cart }) => setCart(cart))
```
</TabItem>
</Tabs>
This updates the `customer_id` associated with the cart to make sure it belongs to a specific customer.
@@ -394,57 +394,57 @@ In case the customer doesn't want to use their own account, you must at least as
You can do that using the same update operation:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.carts.update(cartId, {
email: "user@example.com",
})
.then(({ cart }) => setCart(cart))
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCart } from "medusa-react"
const Cart = () => {
// ...
const { updateCart } = useCart()
const changeEmail = (email: string) => {
updateCart.mutate({
email,
```ts
medusa.carts.update(cartId, {
email: "user@example.com",
})
}
.then(({ cart }) => setCart(cart))
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default Cart
```
```tsx
import { useCart } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const Cart = () => {
// ...
```ts
fetch(`<BACKEND_URLL>/store/carts/${cartId}`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: "user@example.com",
}),
})
.then((response) => response.json())
.then(({ cart }) => setCart(cart))
```
const { updateCart } = useCart()
</TabItem>
const changeEmail = (email: string) => {
updateCart.mutate({
email,
})
}
// ...
}
export default Cart
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URLL>/store/carts/${cartId}`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: "user@example.com",
}),
})
.then((response) => response.json())
.then(({ cart }) => setCart(cart))
```
</TabItem>
</Tabs>
---
@@ -454,60 +454,60 @@ fetch(`<BACKEND_URLL>/store/carts/${cartId}`, {
To create a line item of a product and add it to a cart, you can use the following code snippet:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```jsx
medusa.carts.lineItems.create(cartId, {
variant_id,
quantity: 1,
})
.then(({ cart }) => setCart(cart))
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCreateLineItem } from "medusa-react"
const Cart = () => {
// ...
const createLineItem = useCreateLineItem(cart_id)
const handleAddItem = () => {
createLineItem.mutate({
```jsx
medusa.carts.lineItems.create(cartId, {
variant_id,
quantity,
quantity: 1,
})
}
.then(({ cart }) => setCart(cart))
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default Cart
```
```tsx
import { useCreateLineItem } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const Cart = () => {
// ...
```jsx
fetch(`<BACKEND_URLL>/store/carts/${cartId}/line-items`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
variant_id,
quantity: 1,
}),
})
.then((response) => response.json())
.then(({ cart }) => setCart(cart))
```
const createLineItem = useCreateLineItem(cart_id)
</TabItem>
const handleAddItem = () => {
createLineItem.mutate({
variant_id,
quantity,
})
}
// ...
}
export default Cart
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```jsx
fetch(`<BACKEND_URLL>/store/carts/${cartId}/line-items`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
variant_id,
quantity: 1,
}),
})
.then((response) => response.json())
.then(({ cart }) => setCart(cart))
```
</TabItem>
</Tabs>
This request accepts the ID of the cart as a path parameter. In the body, it's required to send the ID of the product variant you want to add to the cart and its quantity.
@@ -529,60 +529,60 @@ If you’re using Sales Channels, make sure that the cart and the product belong
To update a line item's quantity in the cart, you can use the following code snippet:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.carts.lineItems.update(cartId, lineItemId, {
quantity: 3,
})
.then(({ cart }) => setCart(cart))
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useUpdateLineItem } from "medusa-react"
const Cart = () => {
// ...
const updateLineItem = useUpdateLineItem(cart_id)
const handleUpdateItem = () => {
updateLineItem.mutate({
lineId,
```ts
medusa.carts.lineItems.update(cartId, lineItemId, {
quantity: 3,
})
}
.then(({ cart }) => setCart(cart))
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default Cart
```
```tsx
import { useUpdateLineItem } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const Cart = () => {
// ...
const updateLineItem = useUpdateLineItem(cart_id)
const handleUpdateItem = () => {
updateLineItem.mutate({
lineId,
quantity: 3,
})
}
// ...
}
export default Cart
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URLL>/store/carts/${cartId}/line-items/${lineItemId}`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
quantity: 3,
}),
})
.then((response) => response.json())
.then(({ cart }) => setCart(cart))
```
```ts
fetch(`<BACKEND_URLL>/store/carts/${cartId}/line-items/${lineItemId}`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
quantity: 3,
}),
})
.then((response) => response.json())
.then(({ cart }) => setCart(cart))
```
</TabItem>
</TabItem>
</Tabs>
This request accepts the ID of the cart and the ID of the line item as path parameters. In the body, it accepts the quantity of the line item.
@@ -596,51 +596,51 @@ It returns the updated cart.
To delete a line item from the cart, you can use the following code snippet:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.carts.lineItems.delete(cartId, lineItemId)
.then(({ cart }) => setCart(cart))
```
```ts
medusa.carts.lineItems.delete(cartId, lineItemId)
.then(({ cart }) => setCart(cart))
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useDeleteLineItem } from "medusa-react"
```tsx
import { useDeleteLineItem } from "medusa-react"
const Cart = () => {
// ...
const Cart = () => {
// ...
const deleteLineItem = useDeleteLineItem(cart_id)
const deleteLineItem = useDeleteLineItem(cart_id)
const handleDeleteItem = () => {
deleteLineItem.mutate({
lineId,
})
}
const handleDeleteItem = () => {
deleteLineItem.mutate({
lineId,
})
}
// ...
}
// ...
}
export default Cart
```
export default Cart
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URLL>/store/carts/${cartId}/line-items/${lineItemId}`, {
method: "DELETE",
credentials: "include",
})
.then((response) => response.json())
.then(({ cart }) => setCart(cart))
```
```ts
fetch(`<BACKEND_URLL>/store/carts/${cartId}/line-items/${lineItemId}`, {
method: "DELETE",
credentials: "include",
})
.then((response) => response.json())
.then(({ cart }) => setCart(cart))
```
</TabItem>
</TabItem>
</Tabs>
This request accepts the ID of the cart and the ID of the line item as path parameters.
@@ -63,95 +63,95 @@ In this step, the customer generally enters their shipping info, then chooses th
After the customer enters their shipping address information, you must send a `POST` request to the [Update a Cart API Route](https://docs.medusajs.com/api/store#carts_postcartscart):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.carts.update(cartId, {
shipping_address: {
company,
first_name,
last_name,
address_1,
address_2,
city,
country_code,
province,
postal_code,
phone,
},
})
.then(({ cart }) => {
console.log(cart.shipping_address)
})
```
```ts
medusa.carts.update(cartId, {
shipping_address: {
company,
first_name,
last_name,
address_1,
address_2,
city,
country_code,
province,
postal_code,
phone,
},
})
.then(({ cart }) => {
console.log(cart.shipping_address)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCart } from "medusa-react"
```tsx
import { useCart } from "medusa-react"
const Cart = () => {
// ...
const Cart = () => {
// ...
const { updateCart } = useCart()
const { updateCart } = useCart()
const addShippingAddress =
(address: Record<string, string>) => {
updateCart.mutate({
shipping_address: {
company: address.company,
first_name: address.first_name,
last_name: address.last_name,
address_1: address.address_1,
address_2: address.address_2,
city: address.city,
country_code: address.country_code,
province: address.province,
postal_code: address.postal_code,
phone: address.phone,
},
})
const addShippingAddress =
(address: Record<string, string>) => {
updateCart.mutate({
shipping_address: {
company: address.company,
first_name: address.first_name,
last_name: address.last_name,
address_1: address.address_1,
address_2: address.address_2,
city: address.city,
country_code: address.country_code,
province: address.province,
postal_code: address.postal_code,
phone: address.phone,
},
})
}
// ...
}
// ...
}
export default Cart
```
export default Cart
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/carts/${cartId}`, {
method: "POST",
credentials: "include",
body: JSON.stringify({
shipping_address: {
company,
first_name,
last_name,
address_1,
address_2,
city,
country_code,
province,
postal_code,
phone,
},
}),
headers: {
"Content-Type": "application/json",
},
})
.then((response) => response.json())
.then(({ cart }) => {
console.log(cart.shipping_address)
})
```
```ts
fetch(`<BACKEND_URL>/store/carts/${cartId}`, {
method: "POST",
credentials: "include",
body: JSON.stringify({
shipping_address: {
company,
first_name,
last_name,
address_1,
address_2,
city,
country_code,
province,
postal_code,
phone,
},
}),
headers: {
"Content-Type": "application/json",
},
})
.then((response) => response.json())
.then(({ cart }) => {
console.log(cart.shipping_address)
})
```
</TabItem>
</TabItem>
</Tabs>
This request accepts the ID of the cart as a path parameter and the new shipping address in the request body.
@@ -167,67 +167,67 @@ After updating the cart with the customer’s address, the list of available [sh
You can retrieve the list of shipping options by sending a `GET` request to the [Retrieve Shipping Options for Cart API Route](https://docs.medusajs.com/api/store#shipping-options_getshippingoptionscartid):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.shippingOptions.listCartOptions(cartId)
.then(({ shipping_options }) => {
console.log(shipping_options.length)
})
```
```ts
medusa.shippingOptions.listCartOptions(cartId)
.then(({ shipping_options }) => {
console.log(shipping_options.length)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCartShippingOptions } from "medusa-react"
```tsx
import { useCartShippingOptions } from "medusa-react"
type Props = {
cartId: string
}
type Props = {
cartId: string
}
const ShippingOptions = ({ cartId }: Props) => {
const { shipping_options, isLoading } =
useCartShippingOptions(cartId)
const ShippingOptions = ({ cartId }: Props) => {
const { shipping_options, isLoading } =
useCartShippingOptions(cartId)
return (
<div>
{isLoading && <span>Loading...</span>}
{shipping_options && !shipping_options.length && (
<span>No shipping options</span>
)}
{shipping_options && (
<ul>
{shipping_options.map(
(shipping_option) => (
<li key={shipping_option.id}>
{shipping_option.name}
</li>
)
return (
<div>
{isLoading && <span>Loading...</span>}
{shipping_options && !shipping_options.length && (
<span>No shipping options</span>
)}
</ul>
)}
</div>
)
}
{shipping_options && (
<ul>
{shipping_options.map(
(shipping_option) => (
<li key={shipping_option.id}>
{shipping_option.name}
</li>
)
)}
</ul>
)}
</div>
)
}
export default ShippingOptions
```
export default ShippingOptions
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/shipping-options/${cartId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ shipping_options }) => {
console.log(shipping_options.length)
})
```
```ts
fetch(`<BACKEND_URL>/store/shipping-options/${cartId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ shipping_options }) => {
console.log(shipping_options.length)
})
```
</TabItem>
</TabItem>
</Tabs>
The request accepts the ID of the cart as a path parameter. It returns the array of [shipping options](https://docs.medusajs.com/api/store#shipping-options_getshippingoptions). Typically you would display those options to the customer to choose from.
@@ -237,61 +237,61 @@ The request accepts the ID of the cart as a path parameter. It returns the array
Once the customer chooses one of the available shipping options, send a `POST` request to the [Add a Shipping Method API Route](https://docs.medusajs.com/api/store#carts_postcartscartshippingmethod). This will create a [shipping method](../shipping.md#shipping-method) based on the shipping option chosen and will associate it with the customer’s cart:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.carts.addShippingMethod(cartId, {
option_id: shippingOptionId, // the ID of the selected option
})
.then(({ cart }) => {
console.log(cart.shipping_methods)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAddShippingMethodToCart } from "medusa-react"
// ...
const ShippingOptions = ({ cartId }: Props) => {
// ...
const addShippingMethod = useAddShippingMethodToCart(cartId)
const handleAddShippingMethod = (option_id: string) => {
addShippingMethod.mutate({
option_id,
```ts
medusa.carts.addShippingMethod(cartId, {
option_id: shippingOptionId, // the ID of the selected option
})
}
.then(({ cart }) => {
console.log(cart.shipping_methods)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default ShippingOptions
```
```tsx
import { useAddShippingMethodToCart } from "medusa-react"
// ...
</TabItem>
<TabItem value="fetch" label="Fetch API">
const ShippingOptions = ({ cartId }: Props) => {
// ...
const addShippingMethod = useAddShippingMethodToCart(cartId)
```ts
fetch(`<BACKEND_URL>/store/carts/${cartId}/shipping-methods`, {
method: "POST",
credentials: "include",
body: JSON.stringify({
option_id: shippingOptionId, // ID of the selected option
}),
headers: {
"Content-Type": "application/json",
},
})
.then((response) => response.json())
.then(({ cart }) => {
console.log(cart.shipping_methods)
})
```
const handleAddShippingMethod = (option_id: string) => {
addShippingMethod.mutate({
option_id,
})
}
</TabItem>
// ...
}
export default ShippingOptions
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/carts/${cartId}/shipping-methods`, {
method: "POST",
credentials: "include",
body: JSON.stringify({
option_id: shippingOptionId, // ID of the selected option
}),
headers: {
"Content-Type": "application/json",
},
})
.then((response) => response.json())
.then(({ cart }) => {
console.log(cart.shipping_methods)
})
```
</TabItem>
</Tabs>
The request accepts the ID of the cart as a path parameter and its body the ID of the selected shipping option.
@@ -311,65 +311,65 @@ When the page opens and before the payment providers are displayed to the custom
To initialize the payment sessions, send a `POST` request to the [Initialize Payment Sessions API Route](https://docs.medusajs.com/api/store#carts_postcartscartpaymentsession):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.carts.createPaymentSessions(cartId)
.then(({ cart }) => {
console.log(cart.payment_sessions)
})
```
```ts
medusa.carts.createPaymentSessions(cartId)
.then(({ cart }) => {
console.log(cart.payment_sessions)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCart } from "medusa-react"
import { useEffect } from "react"
```tsx
import { useCart } from "medusa-react"
import { useEffect } from "react"
const PaymentProviders = () => {
const { cart, startCheckout } = useCart()
const PaymentProviders = () => {
const { cart, startCheckout } = useCart()
useEffect(() => {
startCheckout.mutate()
}, [])
useEffect(() => {
startCheckout.mutate()
}, [])
return (
<div>
{!cart?.payment_sessions.length && (
<span>No payment processors</span>
)}
<ul>
{cart?.payment_sessions.map(
(paymentSession) => (
<li key={paymentSession.id}>
{paymentSession.provider_id}
</li>
)
)}
</ul>
</div>
)
}
return (
<div>
{!cart?.payment_sessions.length && (
<span>No payment processors</span>
)}
<ul>
{cart?.payment_sessions.map(
(paymentSession) => (
<li key={paymentSession.id}>
{paymentSession.provider_id}
</li>
)
)}
</ul>
</div>
)
}
export default PaymentProviders
```
export default PaymentProviders
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/carts/${cartId}/payment-sessions`, {
method: "POST",
credentials: "include",
})
.then((response) => response.json())
.then(({ cart }) => {
console.log(cart.payment_sessions)
})
```
```ts
fetch(`<BACKEND_URL>/store/carts/${cartId}/payment-sessions`, {
method: "POST",
credentials: "include",
})
.then((response) => response.json())
.then(({ cart }) => {
console.log(cart.payment_sessions)
})
```
</TabItem>
</TabItem>
</Tabs>
This API Route accepts the ID of the cart as a path parameter. It returns the updated cart with the initialized payment sessions available on `cart.payment_sessions`.
@@ -379,62 +379,62 @@ This API Route accepts the ID of the cart as a path parameter. It returns the up
When the customer chooses the payment processor they want to complete purchase with, you should select the payment session associated with that payment processor. To do that, send a `POST` request to the [Select a Payment Session API Route](https://docs.medusajs.comapi/store#carts_postcartscartpaymentsession):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.carts.setPaymentSession(cartId, {
// retrieved from the payment session selected by the customer
provider_id: paymentProviderId,
})
.then(({ cart }) => {
console.log(cart.payment_session)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCart } from "medusa-react"
const PaymentProviders = () => {
const { cart, startCheckout, pay } = useCart()
// ...
const handleSetPaymentSession = (provider_id: string) => {
pay.mutate({
provider_id,
```ts
medusa.carts.setPaymentSession(cartId, {
// retrieved from the payment session selected by the customer
provider_id: paymentProviderId,
})
}
// ...
}
.then(({ cart }) => {
console.log(cart.payment_session)
})
```
export default PaymentProviders
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```tsx
import { useCart } from "medusa-react"
```ts
fetch(`<BACKEND_URL>/store/carts/${cartId}/payment-session`, {
method: "POST",
credentials: "include",
body: JSON.stringify({
// the payment session selected by the customer
provider_id: paymentProviderId,
}),
headers: {
"Content-Type": "application/json",
},
})
.then((response) => response.json())
.then(({ cart }) => {
console.log(cart.payment_session)
})
```
const PaymentProviders = () => {
const { cart, startCheckout, pay } = useCart()
// ...
</TabItem>
const handleSetPaymentSession = (provider_id: string) => {
pay.mutate({
provider_id,
})
}
// ...
}
export default PaymentProviders
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/carts/${cartId}/payment-session`, {
method: "POST",
credentials: "include",
body: JSON.stringify({
// the payment session selected by the customer
provider_id: paymentProviderId,
}),
headers: {
"Content-Type": "application/json",
},
})
.then((response) => response.json())
.then(({ cart }) => {
console.log(cart.payment_session)
})
```
</TabItem>
</Tabs>
The request accepts the ID of the cart as a path parameter, and the ID of the payment processor in the request's body.
@@ -454,79 +454,79 @@ This step is optional and is only necessary for some payment processors. As ment
If you need to update that data at any point before the purchase is made, send a request to [Update a Payment Session API Route](https://docs.medusajs.com/api/store#carts_postcartscartpaymentsessionupdate):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.carts.updatePaymentSession(cartId, paymentProviderId, {
data: {
// pass any data you want to add in the `data` attribute
// for example:
"test": true,
},
})
.then(({ cart }) => {
console.log(cart.payment_session.data)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useUpdatePaymentSession, useCart } from "medusa-react"
// ...
const PaymentProviders = () => {
const { cart } = useCart()
const updatePaymentSession = useUpdatePaymentSession(cart.id)
// ...
const handleUpdatePaymentSession = (
provider_id: string,
data: Record<string, any>
) => {
updatePaymentSession.mutate({
provider_id,
data,
})
}
// ...
}
export default PaymentProviders
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(
`<BACKEND_URL>/store/carts/${cartId}/payment-sessions/${paymentProviderId}`,
{
method: "POST",
credentials: "include",
body: JSON.stringify({
```ts
medusa.carts.updatePaymentSession(cartId, paymentProviderId, {
data: {
// pass any data you want to add in the `data` attribute
// for example:
"test": true,
},
}),
headers: {
"Content-Type": "application/json",
},
}
)
.then((response) => response.json())
.then(({ cart }) => {
console.log(cart.payment_session.data)
})
```
})
.then(({ cart }) => {
console.log(cart.payment_session.data)
})
```
</TabItem>
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useUpdatePaymentSession, useCart } from "medusa-react"
// ...
const PaymentProviders = () => {
const { cart } = useCart()
const updatePaymentSession = useUpdatePaymentSession(cart.id)
// ...
const handleUpdatePaymentSession = (
provider_id: string,
data: Record<string, any>
) => {
updatePaymentSession.mutate({
provider_id,
data,
})
}
// ...
}
export default PaymentProviders
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(
`<BACKEND_URL>/store/carts/${cartId}/payment-sessions/${paymentProviderId}`,
{
method: "POST",
credentials: "include",
body: JSON.stringify({
data: {
// pass any data you want to add in the `data` attribute
// for example:
"test": true,
},
}),
headers: {
"Content-Type": "application/json",
},
}
)
.then((response) => response.json())
.then(({ cart }) => {
console.log(cart.payment_session.data)
})
```
</TabItem>
</Tabs>
This request accepts the ID of the cart and the ID of the payment session's payment processor as path parameters. In the request's body, it accepts a `data` object where you can pass any data relevant for the payment processor.
@@ -540,54 +540,54 @@ The last step is to place the order by completing the cart. When you complete th
To complete a cart, send a `POST` request to the [Complete a Cart API Route](https://docs.medusajs.com/api/store#carts_postcartscartcomplete):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.carts.complete(cartId)
.then(({ type, data }) => {
console.log(type, data)
})
```
```ts
medusa.carts.complete(cartId)
.then(({ type, data }) => {
console.log(type, data)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCart } from "medusa-react"
// ...
```tsx
import { useCart } from "medusa-react"
// ...
const Cart = () => {
const { completeCheckout } = useCart()
// ...
const Cart = () => {
const { completeCheckout } = useCart()
// ...
const handleCompleteCheckout = () => {
completeCheckout.mutate()
}
const handleCompleteCheckout = () => {
completeCheckout.mutate()
}
// ...
}
// ...
}
export default Cart
```
export default Cart
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/carts/${cartId}/complete`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
})
.then((response) => response.json())
.then(({ type, data }) => {
console.log(type, data)
})
```
```ts
fetch(`<BACKEND_URL>/store/carts/${cartId}/complete`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
})
.then((response) => response.json())
.then(({ type, data }) => {
console.log(type, data)
})
```
</TabItem>
</TabItem>
</Tabs>
This request accepts the ID of the cart as a path parameter.
File diff suppressed because it is too large. Load diff
@@ -55,67 +55,67 @@ You can learn more about [authenticating as an admin user in the API reference](
You can show a list of customers by sending a request to the [List Customers API Route](https://docs.medusajs.com/api/admin#customers_getcustomers):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.customers.list()
.then(({ customers, limit, offset, count }) => {
console.log(customers.length)
})
```
```ts
medusa.admin.customers.list()
.then(({ customers, limit, offset, count }) => {
console.log(customers.length)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { Customer } from "@medusajs/medusa"
import { useAdminCustomers } from "medusa-react"
```tsx
import { Customer } from "@medusajs/medusa"
import { useAdminCustomers } from "medusa-react"
const Customers = () => {
const { customers, isLoading } = useAdminCustomers()
const Customers = () => {
const { customers, isLoading } = useAdminCustomers()
return (
<div>
{isLoading && <span>Loading...</span>}
{customers && !customers.length && (
<span>No customers</span>
)}
{customers && customers.length > 0 && (
<ul>
{customers.map((customer: Customer) => (
<li key={customer.id}>{customer.first_name}</li>
))}
</ul>
)}
</div>
)
}
return (
<div>
{isLoading && <span>Loading...</span>}
{customers && !customers.length && (
<span>No customers</span>
)}
{customers && customers.length > 0 && (
<ul>
{customers.map((customer: Customer) => (
<li key={customer.id}>{customer.first_name}</li>
))}
</ul>
)}
</div>
)
}
export default Customers
```
export default Customers
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/customers`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ customers, limit, offset, count }) => {
console.log(customers.length)
})
```
```ts
fetch(`<BACKEND_URL>/admin/customers`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ customers, limit, offset, count }) => {
console.log(customers.length)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/customers' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/customers' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This request doesn’t require any path or query parameters. You can pass it optional parameters used for filtering and pagination. Check out the [API reference](https://docs.medusajs.com/api/admin#customers_getcustomers) to learn more.
@@ -142,91 +142,91 @@ Admins can create customer accounts. They have to supply the customer’s creden
You can create a customer account by sending a request to the [Create a Customer API Route](https://docs.medusajs.com/api/admin#customers_postcustomers):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.customers.create({
email,
password,
first_name,
last_name,
})
.then(({ customer }) => {
console.log(customer.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCreateCustomer } from "medusa-react"
const CreateCustomer = () => {
const createCustomer = useAdminCreateCustomer()
// ...
const handleCreate = () => {
// ...
createCustomer.mutate({
first_name,
last_name,
```ts
medusa.admin.customers.create({
email,
password,
first_name,
last_name,
})
}
.then(({ customer }) => {
console.log(customer.id)
})
```
// ...
return (
<form>
{/* Render form */}
</form>
)
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default CreateCustomer
```
```tsx
import { useAdminCreateCustomer } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const CreateCustomer = () => {
const createCustomer = useAdminCreateCustomer()
// ...
```ts
fetch(`<BACKEND_URL>/admin/customers`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email,
password,
first_name,
last_name,
}),
})
.then((response) => response.json())
.then(({ customer }) => {
console.log(customer.id)
})
```
const handleCreate = () => {
// ...
createCustomer.mutate({
first_name,
last_name,
email,
password,
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
return (
<form>
{/* Render form */}
</form>
)
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/customers' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"email": "<EMAIL>",
"first_name": "<FIRST_NAME>",
"last_name": "<LAST_NAME>",
"password": "<PASSWORD>"
}'
```
export default CreateCustomer
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/customers`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email,
password,
first_name,
last_name,
}),
})
.then((response) => response.json())
.then(({ customer }) => {
console.log(customer.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/customers' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"email": "<EMAIL>",
"first_name": "<FIRST_NAME>",
"last_name": "<LAST_NAME>",
"password": "<PASSWORD>"
}'
```
</TabItem>
</Tabs>
This request requires the following body parameters:
@@ -249,82 +249,82 @@ An admin can edit a customer’s basic information and credentials.
You can edit a customer’s information by sending a request to the [Update a Customer API Route](https://docs.medusajs.com/api/admin#customers_postcustomerscustomer):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.customers.update(customerId, {
first_name,
})
.then(({ customer }) => {
console.log(customer.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminUpdateCustomer } from "medusa-react"
const UpdateCustomer = () => {
const updateCustomer = useAdminUpdateCustomer(customerId)
// ...
const handleUpdate = () => {
// ...
updateCustomer.mutate({
email,
password,
```ts
medusa.admin.customers.update(customerId, {
first_name,
last_name,
})
}
.then(({ customer }) => {
console.log(customer.id)
})
```
// ...
return (
<form>
{/* Render form */}
</form>
)
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default UpdateCustomer
```
```tsx
import { useAdminUpdateCustomer } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const UpdateCustomer = () => {
const updateCustomer = useAdminUpdateCustomer(customerId)
// ...
```ts
fetch(`<BACKEND_URL>/admin/customers/${customerId}`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
first_name,
}),
})
.then((response) => response.json())
.then(({ customer }) => {
console.log(customer.id)
})
```
const handleUpdate = () => {
// ...
updateCustomer.mutate({
email,
password,
first_name,
last_name,
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
return (
<form>
{/* Render form */}
</form>
)
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/customers/<CUSTOMER_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"first_name": "<FIRST_NAME>"
}'
```
export default UpdateCustomer
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/customers/${customerId}`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
first_name,
}),
})
.then((response) => response.json())
.then(({ customer }) => {
console.log(customer.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/customers/<CUSTOMER_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"first_name": "<FIRST_NAME>"
}'
```
</TabItem>
</Tabs>
This request accepts any of the customer’s fields as body parameters. In this example, you update the customer’s first name. You can learn more about accepted body parameters in the [API reference](https://docs.medusajs.com/api/admin#customers_postcustomerscustomer).
@@ -61,76 +61,76 @@ A customer can register with an email and a password to store and manage their d
You can register a new customer by sending a request to the [Create a Customer API Route](https://docs.medusajs.com/api/store#customers_postcustomers):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.customers.create({
email,
password,
first_name,
last_name,
})
.then(({ customer }) => {
console.log(customer.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCreateCustomer } from "medusa-react"
const RegisterCustomer = () => {
const createCustomer = useCreateCustomer()
// ...
const handleCreate = () => {
// ...
createCustomer.mutate({
first_name,
last_name,
```ts
medusa.customers.create({
email,
password,
first_name,
last_name,
})
}
.then(({ customer }) => {
console.log(customer.id)
})
```
// ...
return (
<form>
{/* Render form */}
</form>
)
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default RegisterCustomer
```
```tsx
import { useCreateCustomer } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const RegisterCustomer = () => {
const createCustomer = useCreateCustomer()
// ...
```ts
fetch(`<BACKEND_URL>/store/customers`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email,
password,
first_name,
last_name,
}),
})
.then((response) => response.json())
.then(({ customer }) => {
console.log(customer.id)
})
```
const handleCreate = () => {
// ...
createCustomer.mutate({
first_name,
last_name,
email,
password,
})
}
</TabItem>
// ...
return (
<form>
{/* Render form */}
</form>
)
}
export default RegisterCustomer
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/customers`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email,
password,
first_name,
last_name,
}),
})
.then((response) => response.json())
.then(({ customer }) => {
console.log(customer.id)
})
```
</TabItem>
</Tabs>
This request requires the following body parameters:
@@ -153,40 +153,40 @@ A customer can log in to your store to manage their data and make purchases usin
You can log in a customer into your store by sending a request to the [Customer Login API Route](https://docs.medusajs.com/api/store#auth_postauth):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.auth.authenticate({
email,
password,
})
.then(({ customer }) => {
console.log(customer.id)
})
```
```ts
medusa.auth.authenticate({
email,
password,
})
.then(({ customer }) => {
console.log(customer.id)
})
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/auth`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email,
password,
}),
})
.then((response) => response.json())
.then(({ customer }) => {
console.log(customer.id)
})
```
```ts
fetch(`<BACKEND_URL>/store/auth`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email,
password,
}),
})
.then((response) => response.json())
.then(({ customer }) => {
console.log(customer.id)
})
```
</TabItem>
</TabItem>
</Tabs>
This request requires the body parameters `email` and `password`. It returns the customer object in the response.
@@ -202,29 +202,29 @@ However, if you’re using the Fetch API, you must include the option `credentia
You can log out a customer by sending a request to the [Customer Logout API Route](https://docs.medusajs.com/api/store#auth_deleteauth):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.auth.deleteSession()
.then(() => {
// success
})
```
```ts
medusa.auth.deleteSession()
.then(() => {
// success
})
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/auth`, {
method: "DELETE",
credentials: "include",
})
.then(() => {
// success
})
```
```ts
fetch(`<BACKEND_URL>/store/auth`, {
method: "DELETE",
credentials: "include",
})
.then(() => {
// success
})
```
</TabItem>
</TabItem>
</Tabs>
If this request is successful, the customer’s session will be deleted and they’ll be logged out.
@@ -242,43 +242,43 @@ The customer must first enter their account’s email. Then, if an account with
You can request to reset a customer’s password by sending a request to the [Request Password Reset API Route](https://docs.medusajs.com/api/store#customers_postcustomerscustomerpasswordtoken):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.customers.generatePasswordToken({
email,
})
.then(() => {
// successful
})
.catch(() => {
// failed
})
```
```ts
medusa.customers.generatePasswordToken({
email,
})
.then(() => {
// successful
})
.catch(() => {
// failed
})
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/customers/password-token`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email,
}),
})
.then(() => {
// successful
})
.catch(() => {
// failed
})
```
```ts
fetch(`<BACKEND_URL>/store/customers/password-token`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email,
}),
})
.then(() => {
// successful
})
.catch(() => {
// failed
})
```
</TabItem>
</TabItem>
</Tabs>
This request requires the body parameter `email`. Its value must be the email associated with the customer’s account.
@@ -298,42 +298,42 @@ After the first step, the customer should receive an email with a link to a page
You can then reset the customer’s password to the new password they enter by sending a request to the [Reset Password API Route](https://docs.medusajs.com/api/store#customers_postcustomersresetpassword):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.customers.resetPassword({
email,
password,
token,
})
.then(({ customer }) => {
console.log(customer.id)
})
```
```ts
medusa.customers.resetPassword({
email,
password,
token,
})
.then(({ customer }) => {
console.log(customer.id)
})
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/customers/password-reset`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email,
password,
token,
}),
})
.then((response) => response.json())
.then(({ customer }) => {
console.log(customer.id)
})
```
```ts
fetch(`<BACKEND_URL>/store/customers/password-reset`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email,
password,
token,
}),
})
.then((response) => response.json())
.then(({ customer }) => {
console.log(customer.id)
})
```
</TabItem>
</TabItem>
</Tabs>
This request requires the following body parameters:
@@ -353,68 +353,68 @@ A logged-in customer can edit their info, such as their first name or email addr
You can edit a customer’s info using the [Update Customer API Route](https://docs.medusajs.com/api/store#customers_postcustomerscustomer):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.customers.update({
first_name,
})
.then(({ customer }) => {
console.log(customer.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useUpdateMe } from "medusa-react"
const UpdateCustomer = () => {
const updateCustomer = useUpdateMe()
// ...
const handleUpdate = () => {
// ...
updateCustomer.mutate({
id: customer_id,
```ts
medusa.customers.update({
first_name,
})
}
.then(({ customer }) => {
console.log(customer.id)
})
```
// ...
return (
<form>
{/* Render form */}
</form>
)
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default UpdateCustomer
```
```tsx
import { useUpdateMe } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const UpdateCustomer = () => {
const updateCustomer = useUpdateMe()
// ...
```ts
fetch(`<BACKEND_URL>/store/customers/me`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
first_name,
}),
})
.then((response) => response.json())
.then(({ customer }) => {
console.log(customer.id)
})
```
const handleUpdate = () => {
// ...
updateCustomer.mutate({
id: customer_id,
first_name,
})
}
</TabItem>
// ...
return (
<form>
{/* Render form */}
</form>
)
}
export default UpdateCustomer
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/customers/me`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
first_name,
}),
})
.then((response) => response.json())
.then(({ customer }) => {
console.log(customer.id)
})
```
</TabItem>
</Tabs>
This request accepts any of the customer’s details that should be updated as body parameters. In the example above, the `first_name` of the customer is updated. You can check out the [API reference](https://docs.medusajs.com/api/api/store#customers_postcustomerscustomer) for a full list of accepted body parameters.
@@ -438,62 +438,62 @@ The customer object returned in the requests mentioned in this document include
You can add a shipping address to a customer’s account by sending a request to the [Add a Shipping Address API Route](https://docs.medusajs.com/api/store#customers_postcustomerscustomeraddresses):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.customers.addresses.addAddress({
address: {
first_name,
last_name,
address_1,
city,
country_code,
postal_code,
phone,
company,
address_2,
province,
metadata,
},
})
.then(({ customer }) => {
console.log(customer.id)
})
```
```ts
medusa.customers.addresses.addAddress({
address: {
first_name,
last_name,
address_1,
city,
country_code,
postal_code,
phone,
company,
address_2,
province,
metadata,
},
})
.then(({ customer }) => {
console.log(customer.id)
})
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/customers/me/addresses`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
address: {
first_name,
last_name,
address_1,
city,
country_code,
postal_code,
phone,
company,
address_2,
province,
metadata,
},
}),
})
.then((response) => response.json())
.then(({ customer }) => {
console.log(customer.id)
})
```
```ts
fetch(`<BACKEND_URL>/store/customers/me/addresses`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
address: {
first_name,
last_name,
address_1,
city,
country_code,
postal_code,
phone,
company,
address_2,
province,
metadata,
},
}),
})
.then((response) => response.json())
.then(({ customer }) => {
console.log(customer.id)
})
```
</TabItem>
</TabItem>
</Tabs>
This request requires an `address` object as a body parameter. The `address` object must have the following properties:
@@ -514,40 +514,40 @@ This request returns the updated customer object in the response.
You can edit a customer’s shipping address using the [Update a Shipping Address API Route](https://docs.medusajs.com/api/store#customers_postcustomerscustomeraddressesaddress):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.customers.addresses.updateAddress(addressId, {
first_name,
})
.then(({ customer }) => {
console.log(customer.id)
})
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/customers/me/addresses/${addressId}`,
{
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
```ts
medusa.customers.addresses.updateAddress(addressId, {
first_name,
}),
}
)
.then((response) => response.json())
.then(({ customer }) => {
console.log(customer.id)
})
```
})
.then(({ customer }) => {
console.log(customer.id)
})
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/customers/me/addresses/${addressId}`,
{
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
first_name,
}),
}
)
.then((response) => response.json())
.then(({ customer }) => {
console.log(customer.id)
})
```
</TabItem>
</Tabs>
This request requires the address’s ID as a path parameter. It accepts as a body parameter any of the address’s properties. In the example above, the `first_name` of the shipping address is updated. You can check the [API reference](https://docs.medusajs.com/api/store#customers_postcustomerscustomeraddressesaddress) for all the available body parameters.
@@ -559,32 +559,32 @@ This request returns the updated customer object in the response.
You can delete a shipping address by sending a request to the [Delete an Address API Route](https://docs.medusajs.com/api/store#customers_deletecustomerscustomeraddressesaddress):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.customers.addresses.deleteAddress(addressId)
.then(({ customer }) => {
console.log(customer.id)
})
```
```ts
medusa.customers.addresses.deleteAddress(addressId)
.then(({ customer }) => {
console.log(customer.id)
})
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/customers/me/addresses/${addressId}`,
{
method: "DELETE",
credentials: "include",
}
)
.then((response) => response.json())
.then(({ customer }) => {
console.log(customer.id)
})
```
```ts
fetch(`<BACKEND_URL>/store/customers/me/addresses/${addressId}`,
{
method: "DELETE",
credentials: "include",
}
)
.then((response) => response.json())
.then(({ customer }) => {
console.log(customer.id)
})
```
</TabItem>
</TabItem>
</Tabs>
This request requires the address’s ID as a path parameter. It returns in the response the updated customer object.
@@ -598,58 +598,58 @@ Logged-in customers can see their orders along with the orders’ details.
You can retrieve a customer’s orders by sending a request to the [List Orders API Route](https://docs.medusajs.com/api/store#customers_getcustomerscustomerorders):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.customers.listOrders()
.then(({ orders, limit, offset, count }) => {
console.log(orders)
})
```
```ts
medusa.customers.listOrders()
.then(({ orders, limit, offset, count }) => {
console.log(orders)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCustomerOrders } from "medusa-react"
import { Order } from "@medusajs/medusa"
```tsx
import { useCustomerOrders } from "medusa-react"
import { Order } from "@medusajs/medusa"
const Orders = () => {
// refetch a function that can be used to
// re-retrieve orders after the customer logs in
const { orders, isLoading, refetch } = useCustomerOrders()
const Orders = () => {
// refetch a function that can be used to
// re-retrieve orders after the customer logs in
const { orders, isLoading, refetch } = useCustomerOrders()
return (
<div>
{isLoading && <span>Loading orders...</span>}
{orders?.length && (
<ul>
{orders.map((order: Order) => (
<li key={order.id}>{order.display_id}</li>
))}
</ul>
)}
</div>
)
}
return (
<div>
{isLoading && <span>Loading orders...</span>}
{orders?.length && (
<ul>
{orders.map((order: Order) => (
<li key={order.id}>{order.display_id}</li>
))}
</ul>
)}
</div>
)
}
export default Orders
```
export default Orders
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/customers/me/orders`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ orders, limit, offset, count }) => {
console.log(orders)
})
```
```ts
fetch(`<BACKEND_URL>/store/customers/me/orders`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ orders, limit, offset, count }) => {
console.log(orders)
})
```
</TabItem>
</TabItem>
</Tabs>
This request doesn’t require any path or query parameters. You can, however, send optional query parameters used for filters, pagination, and sorting. You can learn more in the [API reference](https://docs.medusajs.com/api/store#customers_getcustomerscustomerorders).
File diff suppressed because it is too large. Load diff
@@ -65,81 +65,81 @@ The customer can enter a discount code during the checkout flow to benefit from
You can add a discount to a customer’s cart by sending the [Update Cart request](https://docs.medusajs.com/api/store#carts_postcartscart):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.carts.update(cartId, {
discounts: [
{
code,
},
],
})
.then(({ cart }) => {
console.log(cart.discounts)
})
.catch((e) => {
// display an error to the customer
alert("Discount is invalid")
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCart } from "medusa-react"
const Cart = () => {
// ...
const { updateCart } = useCart()
const addDiscount = (code: string) => {
updateCart.mutate({
```ts
medusa.carts.update(cartId, {
discounts: [
{
code,
},
],
})
}
.then(({ cart }) => {
console.log(cart.discounts)
})
.catch((e) => {
// display an error to the customer
alert("Discount is invalid")
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default Cart
```
```tsx
import { useCart } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const Cart = () => {
// ...
```ts
fetch(`<BACKEND_URL>/store/carts/${cartId}`, {
method: "POST",
credentials: "include",
body: JSON.stringify({
discounts: [
{
code,
const { updateCart } = useCart()
const addDiscount = (code: string) => {
updateCart.mutate({
discounts: [
{
code,
},
],
})
}
// ...
}
export default Cart
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/carts/${cartId}`, {
method: "POST",
credentials: "include",
body: JSON.stringify({
discounts: [
{
code,
},
],
}),
headers: {
"Content-Type": "application/json",
},
],
}),
headers: {
"Content-Type": "application/json",
},
})
.then((response) => response.json())
.then(({ cart }) => {
console.log(cart.discounts)
})
.catch((e) => {
// display an error to the customer
alert("Discount is invalid")
})
```
})
.then((response) => response.json())
.then(({ cart }) => {
console.log(cart.discounts)
})
.catch((e) => {
// display an error to the customer
alert("Discount is invalid")
})
```
</TabItem>
</TabItem>
</Tabs>
This request requires the customer’s cart ID as a path parameter. In the body of the request, you can update many cart-related details, including adding discounts by passing the `discounts` field. It is an array of objects, with each object having a property `code` with its value being the discount’s unique code.
@@ -256,30 +256,30 @@ The customer can choose to remove a discount from their cart.
You can remove a discount from a customer’s cart using the [Remove Discount request](https://docs.medusajs.com/api/store#carts_deletecartscartdiscountsdiscount):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.carts.deleteDiscount(cartId, code)
.then(({ cart }) => {
console.log(cart.discounts)
})
```
```ts
medusa.carts.deleteDiscount(cartId, code)
.then(({ cart }) => {
console.log(cart.discounts)
})
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/carts/${cartId}/discounts/${code}`, {
method: "DELETE",
credentials: "include",
})
.then((response) => response.json())
.then(({ cart }) => {
console.log(cart.discounts)
})
```
```ts
fetch(`<BACKEND_URL>/store/carts/${cartId}/discounts/${code}`, {
method: "DELETE",
credentials: "include",
})
.then((response) => response.json())
.then(({ cart }) => {
console.log(cart.discounts)
})
```
</TabItem>
</TabItem>
</Tabs>
This request accepts the cart ID and the code of the discount to remove. If the discount is removed successfully, the request returns the updated cart object, where you won’t find the discount in the `discounts` array anymore.
File diff suppressed because it is too large. Load diff
@@ -61,72 +61,72 @@ Customers should be able to view gift cards before they make the purchase. Gift
You can retrieve the gift card product using the [List Products API Route](https://docs.medusajs.com/api/store#products_getproducts), but passing it the `is_giftcard` query parameter:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.products.list({
is_giftcard: true,
})
.then(({ products, limit, offset, count }) => {
if (products.length) {
// gift card products exist
} else {
// no gift card products are created
}
})
```
```ts
medusa.products.list({
is_giftcard: true,
})
.then(({ products, limit, offset, count }) => {
if (products.length) {
// gift card products exist
} else {
// no gift card products are created
}
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { Product } from "@medusajs/medusa"
import { useProducts } from "medusa-react"
```tsx
import { Product } from "@medusajs/medusa"
import { useProducts } from "medusa-react"
const GiftCards = () => {
const { products, isLoading } = useProducts({
is_giftcard: true,
})
const GiftCards = () => {
const { products, isLoading } = useProducts({
is_giftcard: true,
})
return (
<div>
{isLoading && <span>Loading...</span>}
{products && products.length > 0 && (
<ul>
{products.map((product: Product) => (
<li key={product.id}>{product.title}</li>
))}
</ul>
)}
{products && !products.length && (
<span>No Gift Cards</span>
)}
</div>
)
}
return (
<div>
{isLoading && <span>Loading...</span>}
{products && products.length > 0 && (
<ul>
{products.map((product: Product) => (
<li key={product.id}>{product.title}</li>
))}
</ul>
)}
{products && !products.length && (
<span>No Gift Cards</span>
)}
</div>
)
}
export default GiftCards
```
export default GiftCards
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/products?is_giftcard=true`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ products, limit, offset, count }) => {
if (products.length) {
// gift card products exist
} else {
// no gift card products are created
}
})
```
```ts
fetch(`<BACKEND_URL>/store/products?is_giftcard=true`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ products, limit, offset, count }) => {
if (products.length) {
// gift card products exist
} else {
// no gift card products are created
}
})
```
</TabItem>
</TabItem>
</Tabs>
The request does not require any parameters. You can pass query parameters to filter the returned products.
@@ -150,56 +150,56 @@ After the customer purchases the gift card, they’ll receive a code to redeem t
You can retrieve the details of a gift card by sending a request to the [Get Gift Card by Code API Route](https://docs.medusajs.com/api/store#gift-cards_getgiftcardscode):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.giftCards.retrieve(code)
.then(({ gift_card }) => {
console.log(gift_card.id)
})
.catch((e) => {
// gift card doesn't exist or is disabled
})
```
```ts
medusa.giftCards.retrieve(code)
.then(({ gift_card }) => {
console.log(gift_card.id)
})
.catch((e) => {
// gift card doesn't exist or is disabled
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useGiftCard } from "medusa-react"
```tsx
import { useGiftCard } from "medusa-react"
const GiftCard = () => {
const { gift_card, isLoading, isError } = useGiftCard("code")
const GiftCard = () => {
const { gift_card, isLoading, isError } = useGiftCard("code")
return (
<div>
{isLoading && <span>Loading...</span>}
{gift_card && <span>{gift_card.value}</span>}
{isError && <span>Gift Card does not exist</span>}
</div>
)
}
return (
<div>
{isLoading && <span>Loading...</span>}
{gift_card && <span>{gift_card.value}</span>}
{isError && <span>Gift Card does not exist</span>}
</div>
)
}
export default GiftCard
```
export default GiftCard
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/gift-cards/${code}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ gift_card }) => {
console.log(gift_card.id)
})
.catch((e) => {
// gift card doesn't exist or is disabled
})
```
```ts
fetch(`<BACKEND_URL>/store/gift-cards/${code}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ gift_card }) => {
console.log(gift_card.id)
})
.catch((e) => {
// gift card doesn't exist or is disabled
})
```
</TabItem>
</TabItem>
</Tabs>
This request requires the code of the gift card passed as a path parameter.
@@ -225,79 +225,79 @@ A customer can redeem more than one gift card during checkout. The cart’s tota
You can redeem a gift card during checkout by sending a request to the [Update Cart API Route](https://docs.medusajs.com/api/store#carts_postcartscart):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.carts.update(cartId, {
gift_cards: [
{
code,
},
],
})
.then(({ cart }) => {
console.log(cart.gift_cards.length)
})
.catch((e) => {
// gift card doesn't exist or is disabled
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCart } from "medusa-react"
const Cart = () => {
// ...
const { updateCart } = useCart()
const setGiftCard = (code: string) => {
updateCart.mutate({
```ts
medusa.carts.update(cartId, {
gift_cards: [
{
code,
},
],
})
}
.then(({ cart }) => {
console.log(cart.gift_cards.length)
})
.catch((e) => {
// gift card doesn't exist or is disabled
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default Cart
```
```tsx
import { useCart } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const Cart = () => {
// ...
```ts
fetch(`<BACKEND_URL>/store/cart/${cartId}`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
gift_cards: [
{
code,
const { updateCart } = useCart()
const setGiftCard = (code: string) => {
updateCart.mutate({
gift_cards: [
{
code,
},
],
})
}
// ...
}
export default Cart
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/cart/${cartId}`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
],
}),
})
.then((response) => response.json())
.then(({ cart }) => {
console.log(cart.gift_cards.length)
})
.catch((e) => {
// gift card doesn't exist or is disabled
})
```
body: JSON.stringify({
gift_cards: [
{
code,
},
],
}),
})
.then((response) => response.json())
.then(({ cart }) => {
console.log(cart.gift_cards.length)
})
.catch((e) => {
// gift card doesn't exist or is disabled
})
```
</TabItem>
</TabItem>
</Tabs>
This request requires the ID of the cart as a path parameter. It allows passing any cart property you want to update in its body parameters.
File diff suppressed because it is too large. Load diff
@@ -79,84 +79,84 @@ Item allocations are created automatically for items that are associated with pr
You can create an item allocation by sending a request to the [Create a Reservation API Route](https://docs.medusajs.com/api/admin#reservations_postreservations):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.reservations.create({
line_item_id,
location_id,
inventory_item_id,
quantity,
})
.then(({ reservation }) => {
console.log(reservation.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCreateReservation } from "medusa-react"
const CreateReservation = () => {
const createReservation = useAdminCreateReservation()
// ...
const handleCreate = () => {
createReservation.mutate({
```ts
medusa.admin.reservations.create({
line_item_id,
location_id,
inventory_item_id,
quantity,
})
}
.then(({ reservation }) => {
console.log(reservation.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default CreateReservation
```
```tsx
import { useAdminCreateReservation } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const CreateReservation = () => {
const createReservation = useAdminCreateReservation()
// ...
```ts
fetch(`<BACKEND_URL>/admin/reservations`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
line_item_id,
location_id,
inventory_item_id,
quantity,
}),
})
.then((response) => response.json())
.then(({ reservation }) => {
console.log(reservation.id)
})
```
const handleCreate = () => {
createReservation.mutate({
line_item_id,
location_id,
inventory_item_id,
quantity,
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/reservations' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"line_item_id": "<LINE_ITEM_ID>",
"location_id": "<LOC_ID>",
"inventory_item_id": "<INV_ITEM_ID>",
"quantity": 1
}'
```
export default CreateReservation
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/reservations`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
line_item_id,
location_id,
inventory_item_id,
quantity,
}),
})
.then((response) => response.json())
.then(({ reservation }) => {
console.log(reservation.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/reservations' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"line_item_id": "<LINE_ITEM_ID>",
"location_id": "<LOC_ID>",
"inventory_item_id": "<INV_ITEM_ID>",
"quantity": 1
}'
```
</TabItem>
</Tabs>
This API Route requires the following body parameters:
@@ -175,72 +175,72 @@ When listing item allocations, by default, you’ll be retrieving all item alloc
You can retrieve the item allocations of a line item in an order using the [List Reservations API Route](https://docs.medusajs.com/api/admin#reservations_getreservations):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.reservations.list({
line_item_id,
})
.then(({ reservations, count, limit, offset }) => {
console.log(reservations.length)
})
```
```ts
medusa.admin.reservations.list({
line_item_id,
})
.then(({ reservations, count, limit, offset }) => {
console.log(reservations.length)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminReservations } from "medusa-react"
```tsx
import { useAdminReservations } from "medusa-react"
function Reservations() {
const { reservations, isLoading } = useAdminReservations({
line_item_id,
})
function Reservations() {
const { reservations, isLoading } = useAdminReservations({
line_item_id,
})
return (
<div>
{isLoading && <span>Loading...</span>}
{reservations && !reservations.length && (
<span>No Reservations</span>
)}
{reservations && reservations.length > 0 && (
<ul>
{reservations.map((reservation) => (
<li key={reservation.id}>{reservation.quantity}</li>
))}
</ul>
)}
</div>
)
}
return (
<div>
{isLoading && <span>Loading...</span>}
{reservations && !reservations.length && (
<span>No Reservations</span>
)}
{reservations && reservations.length > 0 && (
<ul>
{reservations.map((reservation) => (
<li key={reservation.id}>{reservation.quantity}</li>
))}
</ul>
)}
</div>
)
}
export default Reservations
```
export default Reservations
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/reservations?line_item_id=${lineItemId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ reservations, count, limit, offset }) => {
console.log(reservations.length)
})
```
```ts
fetch(`<BACKEND_URL>/admin/reservations?line_item_id=${lineItemId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ reservations, count, limit, offset }) => {
console.log(reservations.length)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/reservations?line_item_id=<LINE_ITEM_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/reservations?line_item_id=<LINE_ITEM_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route doesn't require any path or query parameters. As mentioned earlier, you can pass query parameters to filter the reservations. In the code snippets above, you filter the reservations by a line item ID. You can, however, filter by other attributes, such as the ID of the location. You can refer to the [API reference](https://docs.medusajs.com/api/admin#reservations_getreservations) for a full list of query parameters.
@@ -252,61 +252,61 @@ The request returns the reservations along with [pagination fields](https://docs
You can retrieve a single item allocation by its ID using the [Get a Reservation API Route](https://docs.medusajs.com/api/admin#reservations_getreservationsreservation):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.reservations.retrieve(reservationId)
.then(({ reservation }) => {
console.log(reservation.id)
})
```
```ts
medusa.admin.reservations.retrieve(reservationId)
.then(({ reservation }) => {
console.log(reservation.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminReservation } from "medusa-react"
```tsx
import { useAdminReservation } from "medusa-react"
function Reservation() {
const {
reservation,
isLoading } = useAdminReservation(reservationId)
function Reservation() {
const {
reservation,
isLoading } = useAdminReservation(reservationId)
return (
<div>
{isLoading && <span>Loading...</span>}
{reservation && (
<span>{reservation.quantity}</span>
)}
</div>
)
}
return (
<div>
{isLoading && <span>Loading...</span>}
{reservation && (
<span>{reservation.quantity}</span>
)}
</div>
)
}
export default Reservation
```
export default Reservation
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ reservation }) => {
console.log(reservation.id)
})
```
```ts
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ reservation }) => {
console.log(reservation.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the reservation’s ID as a path parameter.
@@ -318,74 +318,74 @@ The request returns the reservation as an object.
You can update an item allocation to change the location to allocate from or the quantity to allocate by sending a request to the [Update Reservation API Route](https://docs.medusajs.com/api/admin#reservations_postreservationsreservation):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.reservations.update(reservationId, {
quantity,
})
.then(({ reservation }) => {
console.log(reservation.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminUpdateReservation } from "medusa-react"
const UpdateReservation = () => {
const updateReservation = useAdminUpdateReservation(
reservationId
)
// ...
const handleCreate = () => {
updateReservation.mutate({
```ts
medusa.admin.reservations.update(reservationId, {
quantity,
})
}
.then(({ reservation }) => {
console.log(reservation.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default UpdateReservation
```
```tsx
import { useAdminUpdateReservation } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const UpdateReservation = () => {
const updateReservation = useAdminUpdateReservation(
reservationId
)
// ...
```ts
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
quantity,
}),
})
.then((response) => response.json())
.then(({ reservation }) => {
console.log(reservation.id)
})
```
const handleCreate = () => {
updateReservation.mutate({
quantity,
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"quantity": 3
}'
```
export default UpdateReservation
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
quantity,
}),
})
.then((response) => response.json())
.then(({ reservation }) => {
console.log(reservation.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"quantity": 3
}'
```
</TabItem>
</Tabs>
This API Route requires the ID of the reservation as a path parameter.
@@ -405,60 +405,60 @@ Deleting an item allocation means that the quantity that was previously reserved
You can delete an item allocation by sending a request to the [Delete Reservation API Route](https://docs.medusajs.com/api/admin#reservations_deletereservationsreservation):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.reservations.delete(reservationId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
medusa.admin.reservations.delete(reservationId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminDeleteReservation } from "medusa-react"
```tsx
import { useAdminDeleteReservation } from "medusa-react"
const DeleteReservation = () => {
const deleteReservation = useAdminDeleteReservation(
reservationId
)
// ...
const DeleteReservation = () => {
const deleteReservation = useAdminDeleteReservation(
reservationId
)
// ...
const handleDelete = () => {
deleteReservation.mutate()
}
const handleDelete = () => {
deleteReservation.mutate()
}
// ...
}
// ...
}
export default DeleteReservation
```
export default DeleteReservation
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the reservation ID to be passed as a path parameter.
@@ -476,36 +476,10 @@ The request returns the following fields:
When you create a fulfillment of an order, you can specify the location to fulfill the item from by passing the `location_id` parameter:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.orders.createFulfillment(orderId, {
items: [
{
item_id,
quantity,
},
],
// ...other parameters
location_id,
})
.then(({ order }) => {
console.log(order.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCreateFulfillment } from "medusa-react"
const CreateFulfillment = () => {
const createFulfillment = useAdminCreateFulfillment(orderId)
// ...
const handleCreate = () => {
createFulfillment.mutate({
```ts
medusa.admin.orders.createFulfillment(orderId, {
items: [
{
item_id,
@@ -515,60 +489,86 @@ const CreateFulfillment = () => {
// ...other parameters
location_id,
})
}
.then(({ order }) => {
console.log(order.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default CreateFulfillment
```
```tsx
import { useAdminCreateFulfillment } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const CreateFulfillment = () => {
const createFulfillment = useAdminCreateFulfillment(orderId)
// ...
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/fulfillment`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
items: [
{
item_id,
quantity,
const handleCreate = () => {
createFulfillment.mutate({
items: [
{
item_id,
quantity,
},
],
// ...other parameters
location_id,
})
}
// ...
}
export default CreateFulfillment
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/fulfillment`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
],
// ...other parameters
location_id,
}),
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/fulfillment' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"items": [
body: JSON.stringify({
items: [
{
"item_id": "<LINE_ITEM_ID>",
"quantity": 1
}
item_id,
quantity,
},
],
"location_id": "<LOC_ID>"
}'
```
// ...other parameters
location_id,
}),
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.id)
})
```
</TabItem>
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/fulfillment' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"items": [
{
"item_id": "<LINE_ITEM_ID>",
"quantity": 1
}
],
"location_id": "<LOC_ID>"
}'
```
</TabItem>
</Tabs>
The `location_id` is an optional parameter that allows you to specify where to fulfill the item from. This subsequently decrements the stock quantity of the product variant in that location.
@@ -582,99 +582,99 @@ You can learn more about this API Route's parameters and response in the [API re
When requesting a return, you can specify the location to return the item to by passing the `location_id` parameter:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.orders.requestReturn(orderId, {
items: [
{
item_id,
quantity: 1,
},
],
// other parameters...
location_id,
})
.then(({ order }) => {
console.log(order.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminRequestReturn } from "medusa-react"
const RequestReturn = () => {
const requestReturn = useAdminRequestReturn(orderId)
// ...
const handleRequest = () => {
requestReturn.mutate({
```ts
medusa.admin.orders.requestReturn(orderId, {
items: [
{
item_id,
quantity,
quantity: 1,
},
],
// ...other parameters
// other parameters...
location_id,
})
}
.then(({ order }) => {
console.log(order.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default RequestReturn
```
```tsx
import { useAdminRequestReturn } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const RequestReturn = () => {
const requestReturn = useAdminRequestReturn(orderId)
// ...
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/return`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
items: [
{
item_id,
quantity,
const handleRequest = () => {
requestReturn.mutate({
items: [
{
item_id,
quantity,
},
],
// ...other parameters
location_id,
})
}
// ...
}
export default RequestReturn
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/return`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
],
// ...other parameters
location_id,
}),
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/return' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"items": [
body: JSON.stringify({
items: [
{
"item_id": "<LINE_ITEM_ID>",
"quantity": 1
}
item_id,
quantity,
},
],
"location_id": "<LOC_ID>"
}'
```
// ...other parameters
location_id,
}),
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.id)
})
```
</TabItem>
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/return' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"items": [
{
"item_id": "<LINE_ITEM_ID>",
"quantity": 1
}
],
"location_id": "<LOC_ID>"
}'
```
</TabItem>
</Tabs>
The `location_id` is an optional parameter that allows you to specify where to return the item to. This subsequently increments the stock quantity of the product variant in that location.
@@ -72,66 +72,66 @@ You can learn more about [authenticating as an admin user in the API reference](
You can list all reservations in your store by sending a request to the [List Reservations API Route](https://docs.medusajs.com/api/admin#reservations_getreservations):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.reservations.list()
.then(({ reservations, limit, count, offset }) => {
console.log(reservations.length)
})
```
```ts
medusa.admin.reservations.list()
.then(({ reservations, limit, count, offset }) => {
console.log(reservations.length)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminReservations } from "medusa-react"
```tsx
import { useAdminReservations } from "medusa-react"
const Reservations = () => {
const { reservations, isLoading } = useAdminReservations()
const Reservations = () => {
const { reservations, isLoading } = useAdminReservations()
return (
<div>
{isLoading && <span>Loading...</span>}
{reservations && !reservations.length && (
<span>No Reservations</span>
)}
{reservations && reservations.length > 0 && (
<ul>
{reservations.map((reservation) => (
<li key={reservation.id}>{reservation.quantity}</li>
))}
</ul>
)}
</div>
)
}
return (
<div>
{isLoading && <span>Loading...</span>}
{reservations && !reservations.length && (
<span>No Reservations</span>
)}
{reservations && reservations.length > 0 && (
<ul>
{reservations.map((reservation) => (
<li key={reservation.id}>{reservation.quantity}</li>
))}
</ul>
)}
</div>
)
}
export default Reservations
```
export default Reservations
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/reservations`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ reservations, limit, count, offset }) => {
console.log(reservations.length)
})
```
```ts
fetch(`<BACKEND_URL>/admin/reservations`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ reservations, limit, count, offset }) => {
console.log(reservations.length)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/reservations' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/reservations' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route doesn't require any query or path parameters. You can pass it query parameters for filtering or pagination purposes. Check out the [API reference](https://docs.medusajs.com/api/admin#reservations_getreservations) for a list of accepted query parameters.
@@ -151,80 +151,80 @@ Before you create a reservation for a product variant, make sure you’ve create
You can create a reservation by sending a request to the [Create Reservation API Route](https://docs.medusajs.com/api/admin#reservations_postreservations):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.reservations.create({
location_id,
inventory_item_id,
quantity,
})
.then(({ reservation }) => {
console.log(reservation.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCreateReservation } from "medusa-react"
const CreateReservation = () => {
const createReservation = useAdminCreateReservation()
// ...
const handleCreate = () => {
createReservation.mutate({
```ts
medusa.admin.reservations.create({
location_id,
inventory_item_id,
quantity,
})
}
.then(({ reservation }) => {
console.log(reservation.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default CreateReservation
```
```tsx
import { useAdminCreateReservation } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const CreateReservation = () => {
const createReservation = useAdminCreateReservation()
// ...
```ts
fetch(`<BACKEND_URL>/admin/reservations`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
location_id,
inventory_item_id,
quantity,
}),
})
.then((response) => response.json())
.then(({ reservation }) => {
console.log(reservation.id)
})
```
const handleCreate = () => {
createReservation.mutate({
location_id,
inventory_item_id,
quantity,
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/reservations' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"location_id": "<LOC_ID>",
"inventory_item_id": "<INV_ITEM_ID>",
"quantity": 1
}'
```
export default CreateReservation
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/reservations`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
location_id,
inventory_item_id,
quantity,
}),
})
.then((response) => response.json())
.then(({ reservation }) => {
console.log(reservation.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/reservations' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"location_id": "<LOC_ID>",
"inventory_item_id": "<INV_ITEM_ID>",
"quantity": 1
}'
```
</TabItem>
</Tabs>
This API Route requires the following body parameters:
@@ -242,74 +242,74 @@ The request returns the created reservation as an object.
You can update a reservation by sending a request to the [Update Reservation API Route](https://docs.medusajs.com/api/admin#reservations_postreservationsreservation):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.reservations.update(reservationId, {
quantity,
})
.then(({ reservation }) => {
console.log(reservation.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminUpdateReservation } from "medusa-react"
const UpdateReservation = () => {
const updateReservation = useAdminUpdateReservation(
reservationId
)
// ...
const handleCreate = () => {
updateReservation.mutate({
```ts
medusa.admin.reservations.update(reservationId, {
quantity,
})
}
.then(({ reservation }) => {
console.log(reservation.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default UpdateReservation
```
```tsx
import { useAdminUpdateReservation } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const UpdateReservation = () => {
const updateReservation = useAdminUpdateReservation(
reservationId
)
// ...
```ts
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
quantity,
}),
})
.then((response) => response.json())
.then(({ reservation }) => {
console.log(reservation.id)
})
```
const handleCreate = () => {
updateReservation.mutate({
quantity,
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"quantity": 3
}'
```
export default UpdateReservation
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
quantity,
}),
})
.then((response) => response.json())
.then(({ reservation }) => {
console.log(reservation.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"quantity": 3
}'
```
</TabItem>
</Tabs>
This API Route requires the ID of the reservation as a path parameter.
@@ -329,60 +329,60 @@ The request returns the updated reservation as an object.
You can delete a reservation by sending a request to the [Delete Reservation API Route](https://docs.medusajs.com/api/admin#reservations_deletereservationsreservation):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.reservations.delete(reservationId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
medusa.admin.reservations.delete(reservationId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminDeleteReservation } from "medusa-react"
```tsx
import { useAdminDeleteReservation } from "medusa-react"
const DeleteReservation = () => {
const deleteReservation = useAdminDeleteReservation(
reservationId
)
// ...
const DeleteReservation = () => {
const deleteReservation = useAdminDeleteReservation(
reservationId
)
// ...
const handleDelete = () => {
deleteReservation.mutate()
}
const handleDelete = () => {
deleteReservation.mutate()
}
// ...
}
// ...
}
export default DeleteReservation
```
export default DeleteReservation
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the reservation ID to be passed as a path parameter.
@@ -62,70 +62,70 @@ You can learn more about [authenticating as an admin user in the API reference](
You can list stock locations by using the [List Stock Locations API Route](https://docs.medusajs.com/api/admin#stock-locations_getstocklocations):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.stockLocations.list()
.then(({ stock_locations, limit, offset, count }) => {
console.log(stock_locations.length)
})
```
```ts
medusa.admin.stockLocations.list()
.then(({ stock_locations, limit, offset, count }) => {
console.log(stock_locations.length)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminStockLocations } from "medusa-react"
```tsx
import { useAdminStockLocations } from "medusa-react"
function StockLocations() {
const {
stock_locations,
isLoading } = useAdminStockLocations()
function StockLocations() {
const {
stock_locations,
isLoading } = useAdminStockLocations()
return (
<div>
{isLoading && <span>Loading...</span>}
{stock_locations && !stock_locations.length && (
<span>No Locations</span>
)}
{stock_locations && stock_locations.length > 0 && (
<ul>
{stock_locations.map(
(location) => (
<li key={location.id}>{location.name}</li>
)
return (
<div>
{isLoading && <span>Loading...</span>}
{stock_locations && !stock_locations.length && (
<span>No Locations</span>
)}
</ul>
)}
</div>
)
}
{stock_locations && stock_locations.length > 0 && (
<ul>
{stock_locations.map(
(location) => (
<li key={location.id}>{location.name}</li>
)
)}
</ul>
)}
</div>
)
}
export default StockLocations
```
export default StockLocations
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/stock-locations`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ stock_locations, limit, offset, count }) => {
console.log(stock_locations.length)
})
```
```ts
fetch(`<BACKEND_URL>/admin/stock-locations`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ stock_locations, limit, offset, count }) => {
console.log(stock_locations.length)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/stock-locations' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/stock-locations' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route doesn't require any path or query parameters. You can, however, pass it query parameters to search or filter the list of stock locations. For example, you can pass the `q` query parameter to search through the locations by name. You can learn about available query parameters in the [API reference](https://docs.medusajs.com/api/admin#stock-locations_getstocklocations).
@@ -139,72 +139,72 @@ The request returns an array of stock location objects along with [pagination pa
You can create a stock location using the [Create a Stock Location API Route](https://docs.medusajs.com/api/admin#stock-locations_poststocklocations):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.stockLocations.create({
name: "Main Warehouse",
})
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCreateStockLocation } from "medusa-react"
const CreateStockLocation = () => {
const createStockLocation = useAdminCreateStockLocation()
// ...
const handleCreate = () => {
createStockLocation.mutate({
```ts
medusa.admin.stockLocations.create({
name: "Main Warehouse",
})
}
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default CreateStockLocation
```
```tsx
import { useAdminCreateStockLocation } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const CreateStockLocation = () => {
const createStockLocation = useAdminCreateStockLocation()
// ...
```ts
fetch(`<BACKEND_URL>/admin/stock-locations`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Main Warehouse",
}),
})
.then((response) => response.json())
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
const handleCreate = () => {
createStockLocation.mutate({
name: "Main Warehouse",
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/stock-locations' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"name": "Main Warehouse"
}'
```
export default CreateStockLocation
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/stock-locations`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Main Warehouse",
}),
})
.then((response) => response.json())
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/stock-locations' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"name": "Main Warehouse"
}'
```
</TabItem>
</Tabs>
This API Route requires in its body parameters the `name` field, which is the name of the stock location. You can also pass in the request body parameters other fields related to the address or metadata. You can learn more in the [API reference](https://docs.medusajs.com/api/admin#stock-locations_poststocklocations).
@@ -218,63 +218,63 @@ This request returns the created stock location as an object.
You can retrieve a stock location by sending a request to the [Get Stock Location API Route](https://docs.medusajs.com/api/admin#stock-locations_getstocklocationsstocklocation):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.stockLocations.retrieve(stockLocationId)
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
```ts
medusa.admin.stockLocations.retrieve(stockLocationId)
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminStockLocation } from "medusa-react"
```tsx
import { useAdminStockLocation } from "medusa-react"
function StockLocation() {
const {
stock_location,
isLoading } = useAdminStockLocation(stockLocationId)
function StockLocation() {
const {
stock_location,
isLoading } = useAdminStockLocation(stockLocationId)
return (
<div>
{isLoading && <span>Loading...</span>}
{stock_location && (
<span>{stock_location.name}</span>
)}
</div>
)
}
return (
<div>
{isLoading && <span>Loading...</span>}
{stock_location && (
<span>{stock_location.name}</span>
)}
</div>
)
}
export default StockLocation
```
export default StockLocation
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/stock-locations/${stockLocationId}`,
{
credentials: "include",
}
)
.then((response) => response.json())
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
```ts
fetch(`<BACKEND_URL>/admin/stock-locations/${stockLocationId}`,
{
credentials: "include",
}
)
.then((response) => response.json())
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/stock-locations/<LOC_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/stock-locations/<LOC_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the stock location ID to be passed as a path parameter. It also accepts query parameters related to expanding and selecting fields. You can learn more in the [API reference](https://docs.medusajs.com/api/admin#stock-locations_getstocklocationsstocklocation).
@@ -288,73 +288,73 @@ It returns the stock location as an object.
You can associate a stock location with a sales channel by sending a request to the [Associate Stock Channel API Route](https://docs.medusajs.com/api/admin#sales-channels_postsaleschannelssaleschannelstocklocation):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.salesChannels.addLocation(salesChannelId, {
location_id,
})
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminAddLocationToSalesChannel } from "medusa-react"
function StockLocation() {
const addLocation = useAdminAddLocationToSalesChannel()
// ...
const handleAdd = () => {
addLocation.mutate({
sales_channel_id,
```ts
medusa.admin.salesChannels.addLocation(salesChannelId, {
location_id,
})
}
}
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
export default StockLocation
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```tsx
import { useAdminAddLocationToSalesChannel } from "medusa-react"
function StockLocation() {
const addLocation = useAdminAddLocationToSalesChannel()
// ...
const handleAdd = () => {
addLocation.mutate({
sales_channel_id,
location_id,
})
}
}
export default StockLocation
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/sales-channels/${salesChannelId}/stock-locations`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
location_id,
}),
})
.then((response) => response.json())
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
```ts
fetch(`<BACKEND_URL>/admin/sales-channels/${salesChannelId}/stock-locations`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
location_id,
}),
})
.then((response) => response.json())
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/sales-channels/<CHANNEL_ID>/stock-locations' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"location_id": "<LOC_ID>"
}'
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/sales-channels/<CHANNEL_ID>/stock-locations' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"location_id": "<LOC_ID>"
}'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the ID of the sales channel as a path parameter. In its body parameters, it requires the ID of the stock location you’re associating the sales channel with.
@@ -374,76 +374,76 @@ You can associate a location with more than one sales channel, and you can assoc
You can remove the association between a stock location and a sales channel by sending a request to the [Remove Stock Location Association API Route](https://docs.medusajs.com/api/admin#sales-channels_deletesaleschannelssaleschannelstocklocation):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.salesChannels.removeLocation(salesChannelId, {
location_id,
})
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import {
useAdminRemoveLocationFromSalesChannel,
} from "medusa-react"
function StockLocation() {
const removeLocation =
useAdminRemoveLocationFromSalesChannel()
// ...
const handleRemove = () => {
removeLocation.mutate({
sales_channel_id,
```ts
medusa.admin.salesChannels.removeLocation(salesChannelId, {
location_id,
})
}
}
.then(({ id, object, deleted }) => {
console.log(id)
})
```
export default StockLocation
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```tsx
import {
useAdminRemoveLocationFromSalesChannel,
} from "medusa-react"
function StockLocation() {
const removeLocation =
useAdminRemoveLocationFromSalesChannel()
// ...
const handleRemove = () => {
removeLocation.mutate({
sales_channel_id,
location_id,
})
}
}
export default StockLocation
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/sales-channels/${salesChannelId}/stock-locations`, {
credentials: "include",
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
location_id,
}),
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
fetch(`<BACKEND_URL>/admin/sales-channels/${salesChannelId}/stock-locations`, {
credentials: "include",
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
location_id,
}),
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/sales-channels/<CHANNEL_ID>/stock-locations' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"location_id": "<LOC_ID>"
}'
```
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/sales-channels/<CHANNEL_ID>/stock-locations' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"location_id": "<LOC_ID>"
}'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the ID of the sales channel as a path parameter. In its body parameters, it requires the ID of the stock location you’re removing the association of the sales channel with.
@@ -467,74 +467,74 @@ This request does not delete the stock location. It only removes the association
You can update a stock location by sending a request to the [Update Stock Location API Route](https://docs.medusajs.com/api/admin#stock-locations_poststocklocationsstocklocation):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.stockLocations.update(stockLocationId, {
name: "Warehouse",
})
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminUpdateStockLocation } from "medusa-react"
function StockLocation() {
const updateLocation = useAdminUpdateStockLocation(
stockLocationId
)
// ...
const handleRemove = () => {
updateLocation.mutate({
```ts
medusa.admin.stockLocations.update(stockLocationId, {
name: "Warehouse",
})
}
}
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
export default StockLocation
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```tsx
import { useAdminUpdateStockLocation } from "medusa-react"
```ts
fetch(`<BACKEND_URL>/admin/stock-locations/${stockLocationId}`,
{
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Warehouse",
}),
}
)
.then((response) => response.json())
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
function StockLocation() {
const updateLocation = useAdminUpdateStockLocation(
stockLocationId
)
// ...
</TabItem>
<TabItem value="curl" label="cURL">
const handleRemove = () => {
updateLocation.mutate({
name: "Warehouse",
})
}
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/stock-locations/<LOC_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"name": "Main Warehouse"
}'
```
export default StockLocation
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/stock-locations/${stockLocationId}`,
{
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Warehouse",
}),
}
)
.then((response) => response.json())
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/stock-locations/<LOC_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"name": "Main Warehouse"
}'
```
</TabItem>
</Tabs>
This API Route requires the ID of a stock location as a path parameter. In its body parameters, you can pass any of the location’s attributes to update, such as the name or address. You can learn more in the [API reference](https://docs.medusajs.com/api/admin#stock-locations_poststocklocationsstocklocation).
@@ -548,60 +548,60 @@ This request returns the updated stock location as an object.
You can delete a stock location by sending a request to the [Delete Stock Location API Route](https://docs.medusajs.com/api/admin#stock-locations_deletestocklocationsstocklocation):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.stockLocations.delete(stockLocationId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
medusa.admin.stockLocations.delete(stockLocationId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminDeleteStockLocation } from "medusa-react"
```tsx
import { useAdminDeleteStockLocation } from "medusa-react"
function StockLocation() {
const deleteLocation = useAdminDeleteStockLocation(
stockLocationId
)
// ...
function StockLocation() {
const deleteLocation = useAdminDeleteStockLocation(
stockLocationId
)
// ...
const handleDelete = () => {
deleteLocation.mutate()
}
}
const handleDelete = () => {
deleteLocation.mutate()
}
}
export default StockLocation
```
export default StockLocation
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/stock-locations/${stockLocationId}`,
{
credentials: "include",
method: "DELETE",
}
)
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
fetch(`<BACKEND_URL>/admin/stock-locations/${stockLocationId}`,
{
credentials: "include",
method: "DELETE",
}
)
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/stock-locations/<LOC_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/stock-locations/<LOC_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the ID of the stock location as a path parameter.
File diff suppressed because it is too large. Load diff
@@ -61,72 +61,72 @@ You can learn more about [authenticating as an admin user in the API reference](
To view an order’s claims, you can retrieve the order using the [Get Order API Route](https://docs.medusajs.com/api/admin#orders_getordersorder) and access the order’s claims:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.orders.retrieve(orderId)
.then(({ order }) => {
console.log(order.claims)
})
```
```ts
medusa.admin.orders.retrieve(orderId)
.then(({ order }) => {
console.log(order.claims)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminOrder } from "medusa-react"
```tsx
import { useAdminOrder } from "medusa-react"
const Order = () => {
const {
order,
isLoading,
} = useAdminOrder(orderId)
return (
<div>
{isLoading && <span>Loading...</span>}
{order && (
<>
<span>{order.display_id}</span>
{order.claims?.length > 0 && (
<ul>
{order.claims.map((claim) => (
<li key={claim.id}>{claim.id}</li>
))}
</ul>
const Order = () => {
const {
order,
isLoading,
} = useAdminOrder(orderId)
return (
<div>
{isLoading && <span>Loading...</span>}
{order && (
<>
<span>{order.display_id}</span>
{order.claims?.length > 0 && (
<ul>
{order.claims.map((claim) => (
<li key={claim.id}>{claim.id}</li>
))}
</ul>
)}
</>
)}
</>
)}
</div>
)
}
</div>
)
}
export default Order
```
export default Order
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.claims)
})
```
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.claims)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/orders/<ORDER_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/orders/<ORDER_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This request requires the order’s ID as a path parameter.
@@ -140,35 +140,10 @@ The request returns the order as an object. In that object, you can access an ar
You can create a claim by sending a request to the [Create Claim API Route](https://docs.medusajs.com/api/admin#orders_postordersorderclaims):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.orders.createClaim(orderId, {
type: "refund",
claim_items: [
{
item_id,
quantity: 1,
},
],
})
.then(({ order }) => {
console.log(order.claims)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCreateClaim } from "medusa-react"
const CreateClaim = () => {
const createClaim = useAdminCreateClaim(orderId)
// ...
const handleCreate = () => {
createClaim.mutate({
```ts
medusa.admin.orders.createClaim(orderId, {
type: "refund",
claim_items: [
{
@@ -177,59 +152,84 @@ const CreateClaim = () => {
},
],
})
}
.then(({ order }) => {
console.log(order.claims)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default CreateClaim
```
```tsx
import { useAdminCreateClaim } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const CreateClaim = () => {
const createClaim = useAdminCreateClaim(orderId)
// ...
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/claims`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
type: "refund",
claim_items: [
{
item_id,
quantity: 1,
},
],
}),
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.claims)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"type": "refund",
"claim_items": [
{
"item_id": "<ITEM_ID>",
"quantity": 1
const handleCreate = () => {
createClaim.mutate({
type: "refund",
claim_items: [
{
item_id,
quantity: 1,
},
],
})
}
]
}'
```
</TabItem>
// ...
}
export default CreateClaim
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/claims`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
type: "refund",
claim_items: [
{
item_id,
quantity: 1,
},
],
}),
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.claims)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"type": "refund",
"claim_items": [
{
"item_id": "<ITEM_ID>",
"quantity": 1
}
]
}'
```
</TabItem>
</Tabs>
This API Route requires the order ID to be passed as a path parameter.
@@ -258,76 +258,76 @@ The request returns the updated order as an object. You can access the order’s
You can update a claim by sending a request to the [Update Claim API Route](https://docs.medusajs.com/api/admin#orders_postordersorderclaimsclaim):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.orders.updateClaim(orderId, claimId, {
no_notification: true,
})
.then(({ order }) => {
console.log(order.claims)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminUpdateClaim } from "medusa-react"
const UpdateClaim = () => {
const updateClaim = useAdminUpdateClaim(orderId)
// ...
const handleUpdate = () => {
updateClaim.mutate({
claim_id,
```ts
medusa.admin.orders.updateClaim(orderId, claimId, {
no_notification: true,
})
}
.then(({ order }) => {
console.log(order.claims)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default UpdateClaim
```
```tsx
import { useAdminUpdateClaim } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const UpdateClaim = () => {
const updateClaim = useAdminUpdateClaim(orderId)
// ...
```ts
fetch(
`<BACKEND_URL>/admin/orders/${orderId}/claims/${claimId}`,
{
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
no_notification: true,
}),
}
)
.then((response) => response.json())
.then(({ order }) => {
console.log(order.claims)
})
```
const handleUpdate = () => {
updateClaim.mutate({
claim_id,
no_notification: true,
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"no_notification": true
}'
```
export default UpdateClaim
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(
`<BACKEND_URL>/admin/orders/${orderId}/claims/${claimId}`,
{
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
no_notification: true,
}),
}
)
.then((response) => response.json())
.then(({ order }) => {
console.log(order.claims)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"no_notification": true
}'
```
</TabItem>
</Tabs>
This API Route requires the ID of the order and the claim to be passed as path parameters.
@@ -349,63 +349,63 @@ Fulfillments are available on a claim object under the `fulfillments` property,
You can create a fulfillment for a claim by sending a request to the [Create Claim Fulfillment API Route](https://docs.medusajs.com/api/admin#orders_postordersorderclaimsclaimfulfillments):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.orders.fulfillClaim(orderId, claimId, {
})
.then(({ order }) => {
console.log(order.claims)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminFulfillClaim } from "medusa-react"
const FulfillClaim = () => {
const fulfillClaim = useAdminFulfillClaim(orderId)
// ...
const handleFulfill = () => {
fulfillClaim.mutate({
claim_id,
```ts
medusa.admin.orders.fulfillClaim(orderId, claimId, {
})
}
.then(({ order }) => {
console.log(order.claims)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default FulfillClaim
```
```tsx
import { useAdminFulfillClaim } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const FulfillClaim = () => {
const fulfillClaim = useAdminFulfillClaim(orderId)
// ...
const handleFulfill = () => {
fulfillClaim.mutate({
claim_id,
})
}
// ...
}
export default FulfillClaim
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/claims/${claimId}/fulfillments`, {
credentials: "include",
method: "POST",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.claims)
})
```
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/claims/${claimId}/fulfillments`, {
credentials: "include",
method: "POST",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.claims)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>/fulfillments' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>/fulfillments' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the order and claim IDs as path parameters.
@@ -419,75 +419,75 @@ The request returns the updated order as an object. You can access the order’s
You can create a shipment for a claim by sending a request to the [Create Claim Shipment API Route](https://docs.medusajs.com/api/admin#orders_postordersorderclaimsclaimshipments):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.orders.createClaimShipment(orderId, claimId, {
fulfillment_id,
})
.then(({ order }) => {
console.log(order.claims)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCreateClaimShipment } from "medusa-react"
const CreateShipment = () => {
const createShipment = useAdminCreateClaimShipment(orderId)
// ...
const handleCreate = () => {
createShipment.mutate({
claim_id,
```ts
medusa.admin.orders.createClaimShipment(orderId, claimId, {
fulfillment_id,
})
}
.then(({ order }) => {
console.log(order.claims)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default CreateShipment
```
```tsx
import { useAdminCreateClaimShipment } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const CreateShipment = () => {
const createShipment = useAdminCreateClaimShipment(orderId)
// ...
const handleCreate = () => {
createShipment.mutate({
claim_id,
fulfillment_id,
})
}
// ...
}
export default CreateShipment
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/claims/${claimId}/shipments`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
fulfillment_id,
}),
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.claims)
})
```
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/claims/${claimId}/shipments`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
fulfillment_id,
}),
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.claims)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>/shipments' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"fulfillment_id": "<FUL_ID>"
}'
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>/shipments' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"fulfillment_id": "<FUL_ID>"
}'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the order and claim IDs as path parameters.
@@ -511,69 +511,69 @@ You can’t cancel a fulfillment that has a shipment
You can cancel a fulfillment by sending a request to the [Cancel Fulfillment API Route](https://docs.medusajs.com/api/admin#orders_postordersclaimfulfillmentscancel):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.orders.cancelClaimFulfillment(
orderId,
claimId,
fulfillmentId
)
.then(({ order }) => {
console.log(order.claims)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCancelClaimFulfillment } from "medusa-react"
const CancelFulfillment = () => {
const cancelFulfillment = useAdminCancelClaimFulfillment(
orderId
)
// ...
const handleCancel = () => {
cancelFulfillment.mutate({
claim_id,
fulfillment_id,
```ts
medusa.admin.orders.cancelClaimFulfillment(
orderId,
claimId,
fulfillmentId
)
.then(({ order }) => {
console.log(order.claims)
})
}
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default CancelFulfillment
```
```tsx
import { useAdminCancelClaimFulfillment } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const CancelFulfillment = () => {
const cancelFulfillment = useAdminCancelClaimFulfillment(
orderId
)
// ...
const handleCancel = () => {
cancelFulfillment.mutate({
claim_id,
fulfillment_id,
})
}
// ...
}
export default CancelFulfillment
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/claims/${claimId}/fulfillments/${fulfillmentId}/cancel`, {
credentials: "include",
method: "POST",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.claims)
})
```
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/claims/${claimId}/fulfillments/${fulfillmentId}/cancel`, {
credentials: "include",
method: "POST",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.claims)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>/fulfillments/<FUL_ID>/cancel' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>/fulfillments/<FUL_ID>/cancel' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the order, claim, and fulfillment IDs to be passed as path parameters.
@@ -595,60 +595,60 @@ You can’t cancel a claim that has been refunded. You must also cancel the clai
You can cancel a claim by sending a request to the [Cancel Claim API Route](https://docs.medusajs.com/api/admin#orders_postordersclaimcancel):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.orders.cancelClaim(orderId, claimId)
.then(({ order }) => {
console.log(order.claims)
})
```
```ts
medusa.admin.orders.cancelClaim(orderId, claimId)
.then(({ order }) => {
console.log(order.claims)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCancelClaim } from "medusa-react"
```tsx
import { useAdminCancelClaim } from "medusa-react"
const CancelClaim = () => {
const cancelClaim = useAdminCancelClaim(orderId)
// ...
const CancelClaim = () => {
const cancelClaim = useAdminCancelClaim(orderId)
// ...
const handleCancel = () => {
cancelClaim.mutate(claimId)
}
const handleCancel = () => {
cancelClaim.mutate(claimId)
}
// ...
}
// ...
}
export default CancelClaim
```
export default CancelClaim
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/claims/${claimId}/cancel`, {
credentials: "include",
method: "POST",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.claims)
})
```
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/claims/${claimId}/cancel`, {
credentials: "include",
method: "POST",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.claims)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>/cancel' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>/cancel' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the order and claim IDs as path parameters.
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -60,68 +60,68 @@ Return reasons allow you to specify why an item is returned. They are especially
You can list available return reasons using the [List Return Reasons API Route](https://docs.medusajs.com/api/admin#return-reasons_getreturnreasons):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.returnReasons.list()
.then(({ return_reasons }) => {
console.log(return_reasons.length)
})
```
```ts
medusa.admin.returnReasons.list()
.then(({ return_reasons }) => {
console.log(return_reasons.length)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminReturnReasons } from "medusa-react"
```tsx
import { useAdminReturnReasons } from "medusa-react"
const ReturnReasons = () => {
const { return_reasons, isLoading } = useAdminReturnReasons()
const ReturnReasons = () => {
const { return_reasons, isLoading } = useAdminReturnReasons()
return (
<div>
{isLoading && <span>Loading...</span>}
{return_reasons && !return_reasons.length && (
<span>No Return Reasons</span>
)}
{return_reasons && return_reasons.length > 0 && (
<ul>
{return_reasons.map((reason) => (
<li key={reason.id}>
{reason.label}: {reason.value}
</li>
))}
</ul>
)}
</div>
)
}
return (
<div>
{isLoading && <span>Loading...</span>}
{return_reasons && !return_reasons.length && (
<span>No Return Reasons</span>
)}
{return_reasons && return_reasons.length > 0 && (
<ul>
{return_reasons.map((reason) => (
<li key={reason.id}>
{reason.label}: {reason.value}
</li>
))}
</ul>
)}
</div>
)
}
export default ReturnReasons
```
export default ReturnReasons
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/return-reasons`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ return_reasons }) => {
console.log(return_reasons.length)
})
```
```ts
fetch(`<BACKEND_URL>/admin/return-reasons`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ return_reasons }) => {
console.log(return_reasons.length)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/return-reasons' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/return-reasons' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route doesn't require or accept any path or query parameters.
@@ -133,76 +133,76 @@ The request returns an array of return reason objects.
You can create a return reason using the [Create Return Reason API Route](https://docs.medusajs.com/api/admin#return-reasons_postreturnreasons):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.returnReasons.create({
label: "Damaged",
value: "damaged",
})
.then(({ return_reason }) => {
console.log(return_reason.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCreateReturnReason } from "medusa-react"
const CreateReturnReason = () => {
const createReturnReason = useAdminCreateReturnReason()
// ...
const handleCreate = () => {
createReturnReason.mutate({
```ts
medusa.admin.returnReasons.create({
label: "Damaged",
value: "damaged",
})
}
.then(({ return_reason }) => {
console.log(return_reason.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default CreateReturnReason
```
```tsx
import { useAdminCreateReturnReason } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const CreateReturnReason = () => {
const createReturnReason = useAdminCreateReturnReason()
// ...
```ts
fetch(`<BACKEND_URL>/admin/return-reasons`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
label: "Damaged",
value: "damaged",
}),
})
.then((response) => response.json())
.then(({ return_reason }) => {
console.log(return_reason.id)
})
```
const handleCreate = () => {
createReturnReason.mutate({
label: "Damaged",
value: "damaged",
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/return-reasons' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"label": "Damaged",
"value": "damaged"
}'
```
export default CreateReturnReason
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/return-reasons`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
label: "Damaged",
value: "damaged",
}),
})
.then((response) => response.json())
.then(({ return_reason }) => {
console.log(return_reason.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/return-reasons' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"label": "Damaged",
"value": "damaged"
}'
```
</TabItem>
</Tabs>
This API Route requires the following request body parameters:
@@ -219,74 +219,74 @@ This request returns the created return reason as an object.
You can update a return reason by sending a request to the [Update Return Reason API Route](https://docs.medusajs.com/api/admin#return-reasons_postreturnreasonsreason):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.returnReasons.update(returnReasonId, {
label: "Damaged",
})
.then(({ return_reason }) => {
console.log(return_reason.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminUpdateReturnReason } from "medusa-react"
const UpdateReturnReason = () => {
const updateReturnReason = useAdminUpdateReturnReason(
returnReasonId
)
// ...
const handleUpdate = () => {
updateReturnReason.mutate({
```ts
medusa.admin.returnReasons.update(returnReasonId, {
label: "Damaged",
})
}
.then(({ return_reason }) => {
console.log(return_reason.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default UpdateReturnReason
```
```tsx
import { useAdminUpdateReturnReason } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const UpdateReturnReason = () => {
const updateReturnReason = useAdminUpdateReturnReason(
returnReasonId
)
// ...
```ts
fetch(`<BACKEND_URL>/admin/return-reasons/${returnReasonId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
label: "Damaged",
}),
})
.then((response) => response.json())
.then(({ return_reason }) => {
console.log(return_reason.id)
})
```
const handleUpdate = () => {
updateReturnReason.mutate({
label: "Damaged",
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/return-reasons/<REASON_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"label": "Damaged"
}'
```
export default UpdateReturnReason
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/return-reasons/${returnReasonId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
label: "Damaged",
}),
})
.then((response) => response.json())
.then(({ return_reason }) => {
console.log(return_reason.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/return-reasons/<REASON_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"label": "Damaged"
}'
```
</TabItem>
</Tabs>
This API Route requires the return reason ID to be passed as a path parameter.
@@ -300,60 +300,60 @@ The request returns the updated return reason as an object.
You can delete a return reason by sending a request to the [Delete Return Reason API Route](https://docs.medusajs.com/api/admin#return-reasons_deletereturnreason):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.returnReasons.delete(returnReasonId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
medusa.admin.returnReasons.delete(returnReasonId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminDeleteReturnReason } from "medusa-react"
```tsx
import { useAdminDeleteReturnReason } from "medusa-react"
const DeleteReturnReason = () => {
const deleteReturnReason = useAdminDeleteReturnReason(
returnReasonId
)
// ...
const DeleteReturnReason = () => {
const deleteReturnReason = useAdminDeleteReturnReason(
returnReasonId
)
// ...
const handleDelete = () => {
deleteReturnReason.mutate()
}
const handleDelete = () => {
deleteReturnReason.mutate()
}
// ...
}
// ...
}
export default DeleteReturnReason
```
export default DeleteReturnReason
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/return-reasons/${returnReasonId}`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
fetch(`<BACKEND_URL>/admin/return-reasons/${returnReasonId}`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/return-reasons/<REASON_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/return-reasons/<REASON_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the return reason ID as a path parameter.
@@ -377,72 +377,72 @@ You can view all returns in your commerce system, regardless of which order they
When you retrieve an order using the [Get Order API Route](https://docs.medusajs.com/api/admin#orders_getordersorder), you can access the returns within the order object:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.orders.retrieve(orderId)
.then(({ order }) => {
console.log(order.returns)
})
```
```ts
medusa.admin.orders.retrieve(orderId)
.then(({ order }) => {
console.log(order.returns)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminOrder } from "medusa-react"
```tsx
import { useAdminOrder } from "medusa-react"
const Order = () => {
const {
order,
isLoading,
} = useAdminOrder(orderId)
return (
<div>
{isLoading && <span>Loading...</span>}
{order && (
<>
<span>{order.display_id}</span>
{order.returns?.length > 0 && (
<ul>
{order.returns.map((orderReturn) => (
<li key={orderReturn.id}>{orderReturn.id}</li>
))}
</ul>
const Order = () => {
const {
order,
isLoading,
} = useAdminOrder(orderId)
return (
<div>
{isLoading && <span>Loading...</span>}
{order && (
<>
<span>{order.display_id}</span>
{order.returns?.length > 0 && (
<ul>
{order.returns.map((orderReturn) => (
<li key={orderReturn.id}>{orderReturn.id}</li>
))}
</ul>
)}
</>
)}
</>
)}
</div>
)
}
</div>
)
}
export default Order
```
export default Order
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.returns)
})
```
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.returns)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/orders/<ORDER_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/orders/<ORDER_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the order ID as a path parameter.
@@ -470,89 +470,89 @@ You can retrieve a claim using the Get Order API Route as explained [here](./man
You can mark a return as received by sending a request to the [Receive a Return API Route](https://docs.medusajs.com/api/admin#returns_postreturnsreturnreceive):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.returns.receive(return_id, {
items: [
{
item_id,
quantity: 1,
},
],
})
.then((data) => {
console.log(data.return.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminReceiveReturn } from "medusa-react"
const ReceiveReturn = () => {
const receiveReturn = useAdminReceiveReturn(
returnId
)
// ...
const handleReceive = () => {
receiveReturn.mutate({
email,
```ts
medusa.admin.returns.receive(return_id, {
items: [
{
item_id,
quantity: 1,
},
],
})
}
.then((data) => {
console.log(data.return.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default ReceiveReturn
```
```tsx
import { useAdminReceiveReturn } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const ReceiveReturn = () => {
const receiveReturn = useAdminReceiveReturn(
returnId
)
// ...
```ts
fetch(`<BACKEND_URL>/admin/returns/${returnId}/receive`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
items: [
{
item_id,
quantity: 1,
},
],
}),
})
.then((response) => response.json())
.then((data) => {
console.log(data.return.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/returns/<RETURN_ID>/receive' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"items": [
{
"item_id": "<ITEM_ID>",
"quantity": 1
const handleReceive = () => {
receiveReturn.mutate({
email,
})
}
]
}'
```
</TabItem>
// ...
}
export default ReceiveReturn
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/returns/${returnId}/receive`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
items: [
{
item_id,
quantity: 1,
},
],
}),
})
.then((response) => response.json())
.then((data) => {
console.log(data.return.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/returns/<RETURN_ID>/receive' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"items": [
{
"item_id": "<ITEM_ID>",
"quantity": 1
}
]
}'
```
</TabItem>
</Tabs>
This API Route requires the ID of the return as a path parameter.
@@ -579,60 +579,60 @@ A received return can’t be canceled.
You can cancel a return by sending a request to the [Cancel Return API Route](https://docs.medusajs.com/api/admin#returns_postreturnsreturncancel):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.returns.cancel(returnId)
.then(({ order }) => {
console.log(order.returns)
})
```
```ts
medusa.admin.returns.cancel(returnId)
.then(({ order }) => {
console.log(order.returns)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCancelReturn } from "medusa-react"
```tsx
import { useAdminCancelReturn } from "medusa-react"
const CancelReturn = () => {
const cancelReturn = useAdminCancelReturn(
returnId
)
// ...
const CancelReturn = () => {
const cancelReturn = useAdminCancelReturn(
returnId
)
// ...
const handleCancel = () => {
cancelReturn.mutate()
}
const handleCancel = () => {
cancelReturn.mutate()
}
// ...
}
// ...
}
export default CancelReturn
```
export default CancelReturn
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/returns/${returnId}/cancel`, {
credentials: "include",
method: "POST",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.returns)
})
```
```ts
fetch(`<BACKEND_URL>/admin/returns/${returnId}/cancel`, {
credentials: "include",
method: "POST",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.returns)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/returns/<RETURN_ID>/cancel' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/returns/<RETURN_ID>/cancel' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the return ID to be passed as a path parameter.
@@ -68,71 +68,71 @@ If you want to view all swaps in your system, and not swaps specific to an order
You can view an order’s swaps by retrieving the order using the [Get Order API Route](https://docs.medusajs.com/api/admin#orders_getordersorder):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.orders.retrieve(orderId)
.then(({ order }) => {
console.log(order.swaps)
})
```
```ts
medusa.admin.orders.retrieve(orderId)
.then(({ order }) => {
console.log(order.swaps)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminOrder } from "medusa-react"
```tsx
import { useAdminOrder } from "medusa-react"
const Order = () => {
const {
order,
isLoading,
} = useAdminOrder(orderId)
return (
<div>
{isLoading && <span>Loading...</span>}
{order && (
<>
<span>{order.display_id}</span>
{order.swaps?.length > 0 && (
<ul>
{order.swaps.map((swap) => (
<li key={swap.id}>{swap.difference_due}</li>
))}
</ul>
const Order = () => {
const {
order,
isLoading,
} = useAdminOrder(orderId)
return (
<div>
{isLoading && <span>Loading...</span>}
{order && (
<>
<span>{order.display_id}</span>
{order.swaps?.length > 0 && (
<ul>
{order.swaps.map((swap) => (
<li key={swap.id}>{swap.difference_due}</li>
))}
</ul>
)}
</>
)}
</>
)}
</div>
)
}
</div>
)
}
export default Order
```
export default Order
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.swaps)
})
```
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.swaps)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/orders/<ORDER_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/orders/<ORDER_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the order ID to be passed as a path parameter.
@@ -148,62 +148,62 @@ Processing a swap’s payment can mean either refunding or capturing payment, de
Regardless of whether you need to refund or capture the payment, you can process the swap’s payment by sending a request to the [Process Swap Payment API Route](https://docs.medusajs.com/api/admin#orders_postordersorderswapsswapprocesspayment):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.orders.processSwapPayment(orderId, swapId)
.then(({ order }) => {
console.log(order.swaps)
})
```
```ts
medusa.admin.orders.processSwapPayment(orderId, swapId)
.then(({ order }) => {
console.log(order.swaps)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminProcessSwapPayment } from "medusa-react"
```tsx
import { useAdminProcessSwapPayment } from "medusa-react"
const ProcessPayment = () => {
const processPayment = useAdminProcessSwapPayment(
orderId
)
// ...
const ProcessPayment = () => {
const processPayment = useAdminProcessSwapPayment(
orderId
)
// ...
const handleProcess = () => {
processPayment.mutate(swapId)
}
const handleProcess = () => {
processPayment.mutate(swapId)
}
// ...
}
// ...
}
export default ProcessPayment
```
export default ProcessPayment
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/swaps/${swapId}/process-payment`, {
credentials: "include",
method: "POST",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.swaps)
})
```
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/swaps/${swapId}/process-payment`, {
credentials: "include",
method: "POST",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.swaps)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/swaps/<SWAP_ID>/process-payment' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/swaps/<SWAP_ID>/process-payment' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the order ID and the swap ID as path parameters.
@@ -223,65 +223,65 @@ Fulfillments are available on a swap object under the `fulfillments` property, w
You can create a fulfillment for a swap by sending a request to the [Create Swap Fulfillment API Route](https://docs.medusajs.com/api/admin#orders_postordersorderswapsswapfulfillments):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.orders.fulfillSwap(orderId, swapId, {
})
.then(({ order }) => {
console.log(order.swaps)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminFulfillSwap } from "medusa-react"
const FulfillSwap = () => {
const fulfillSwap = useAdminFulfillSwap(
orderId
)
// ...
const handleFulfill = () => {
fulfillSwap.mutate({
swap_id: swapId,
```ts
medusa.admin.orders.fulfillSwap(orderId, swapId, {
})
}
.then(({ order }) => {
console.log(order.swaps)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default FulfillSwap
```
```tsx
import { useAdminFulfillSwap } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const FulfillSwap = () => {
const fulfillSwap = useAdminFulfillSwap(
orderId
)
// ...
const handleFulfill = () => {
fulfillSwap.mutate({
swap_id: swapId,
})
}
// ...
}
export default FulfillSwap
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/swaps/${swapId}/fulfillments`, {
credentials: "include",
method: "POST",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.swaps)
})
```
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/swaps/${swapId}/fulfillments`, {
credentials: "include",
method: "POST",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.swaps)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/swaps/<SWAP_ID>/fulfillments' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/swaps/<SWAP_ID>/fulfillments' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the order ID and swap ID as path parameters.
@@ -295,77 +295,77 @@ The request returns the updated order as an object. You can access the order’s
You can create a shipment for a swap’s fulfillment using the [Create Swap Shipment API Route](https://docs.medusajs.com/api/admin#orders_postordersorderswapsswapshipments):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.orders.createSwapShipment(orderId, swapId, {
fulfillment_id,
})
.then(({ order }) => {
console.log(order.swaps)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCreateSwapShipment } from "medusa-react"
const CreateShipment = () => {
const createShipment = useAdminCreateSwapShipment(
orderId
)
// ...
const handleCreate = () => {
createShipment.mutate({
swap_id,
```ts
medusa.admin.orders.createSwapShipment(orderId, swapId, {
fulfillment_id,
})
}
.then(({ order }) => {
console.log(order.swaps)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default CreateShipment
```
```tsx
import { useAdminCreateSwapShipment } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const CreateShipment = () => {
const createShipment = useAdminCreateSwapShipment(
orderId
)
// ...
const handleCreate = () => {
createShipment.mutate({
swap_id,
fulfillment_id,
})
}
// ...
}
export default CreateShipment
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/swaps/${swapId}/shipments`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
fulfillment_id,
}),
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.swaps)
})
```
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/swaps/${swapId}/shipments`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
fulfillment_id,
}),
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.swaps)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/swaps/<SWAP_ID>/shipments' \
-H 'Authorization: Bearer <API_TOKEN>'\
-H 'Content-Type: application/json' \
--data-raw '{
"fulfillment_id": "<FUL_ID>"
}'
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/swaps/<SWAP_ID>/shipments' \
-H 'Authorization: Bearer <API_TOKEN>'\
-H 'Content-Type: application/json' \
--data-raw '{
"fulfillment_id": "<FUL_ID>"
}'
```
</TabItem>
</TabItem>
</Tabs>
This API Route expects the order and swap IDs to be passed as path parameters.
@@ -389,69 +389,69 @@ You can’t cancel a fulfillment that has a shipment
You can cancel a fulfillment by sending a request to the [Cancel Swap Fulfillment API Route](https://docs.medusajs.com/api/admin#orders_postordersswapfulfillmentscancel):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.orders.cancelSwapFulfillment(
orderId,
swapId,
fulfillmentId
)
.then(({ order }) => {
console.log(order.swaps)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCancelSwapFulfillment } from "medusa-react"
const CancelFulfillment = () => {
const cancelFulfillment = useAdminCancelSwapFulfillment(
orderId
)
// ...
const handleCancel = () => {
cancelFulfillment.mutate({
swap_id,
fulfillment_id,
```ts
medusa.admin.orders.cancelSwapFulfillment(
orderId,
swapId,
fulfillmentId
)
.then(({ order }) => {
console.log(order.swaps)
})
}
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default CancelFulfillment
```
```tsx
import { useAdminCancelSwapFulfillment } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const CancelFulfillment = () => {
const cancelFulfillment = useAdminCancelSwapFulfillment(
orderId
)
// ...
const handleCancel = () => {
cancelFulfillment.mutate({
swap_id,
fulfillment_id,
})
}
// ...
}
export default CancelFulfillment
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/swaps/${swapId}/shipments/${fulfillmentId}/cancel`, {
credentials: "include",
method: "POST",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.swaps)
})
```
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/swaps/${swapId}/shipments/${fulfillmentId}/cancel`, {
credentials: "include",
method: "POST",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.swaps)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/swaps/<SWAP_ID>/fulfillments/<FUL_ID>/cancel' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/swaps/<SWAP_ID>/fulfillments/<FUL_ID>/cancel' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the order, swap, and fulfillment IDs to be passed as path parameters.
@@ -473,62 +473,62 @@ You can’t cancel a swap that has been refunded. You must also cancel all swap
You can cancel a swap by sending a request to the [Cancel Swap API Route](https://docs.medusajs.com/api/admin#orders_postordersswapcancel):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.orders.cancelSwap(orderId, swapId)
.then(({ order }) => {
console.log(order.swaps)
})
```
```ts
medusa.admin.orders.cancelSwap(orderId, swapId)
.then(({ order }) => {
console.log(order.swaps)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCancelSwap } from "medusa-react"
```tsx
import { useAdminCancelSwap } from "medusa-react"
const CancelSwap = () => {
const cancelSwap = useAdminCancelSwap(
orderId
)
// ...
const CancelSwap = () => {
const cancelSwap = useAdminCancelSwap(
orderId
)
// ...
const handleCancel = () => {
cancelSwap.mutate(swapId)
}
const handleCancel = () => {
cancelSwap.mutate(swapId)
}
// ...
}
// ...
}
export default CancelSwap
```
export default CancelSwap
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/swaps/${swapId}/cancel`, {
credentials: "include",
method: "POST",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.swaps)
})
```
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/swaps/${swapId}/cancel`, {
credentials: "include",
method: "POST",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.swaps)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/swaps/<SWAP_ID>/cancel' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/swaps/<SWAP_ID>/cancel' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the order and swap IDs as path parameters.
@@ -60,65 +60,65 @@ When a customer wants to create a return, they must choose the items they want t
You can optionally allow customers to choose a return shipping option that they’ll use to return the items. To show the customers the available return shipping options, send a request to the Get [Shipping Options API Route](https://docs.medusajs.com/api/store#shipping-options_getshippingoptions):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.shippingOptions.list({
is_return: "true",
})
.then(({ shipping_options }) => {
console.log(shipping_options.length)
})
```
```ts
medusa.shippingOptions.list({
is_return: "true",
})
.then(({ shipping_options }) => {
console.log(shipping_options.length)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useShippingOptions } from "medusa-react"
```tsx
import { useShippingOptions } from "medusa-react"
const ReturnShippingOptions = () => {
const {
shipping_options,
isLoading,
} = useShippingOptions({
is_return: "true",
})
return (
<div>
{isLoading && <span>Loading...</span>}
{shipping_options?.length &&
shipping_options?.length > 0 && (
<ul>
{shipping_options?.map((shipping_option) => (
<li key={shipping_option.id}>
{shipping_option.id}
</li>
))}
</ul>
)}
</div>
)
}
const ReturnShippingOptions = () => {
const {
shipping_options,
isLoading,
} = useShippingOptions({
is_return: "true",
})
return (
<div>
{isLoading && <span>Loading...</span>}
{shipping_options?.length &&
shipping_options?.length > 0 && (
<ul>
{shipping_options?.map((shipping_option) => (
<li key={shipping_option.id}>
{shipping_option.id}
</li>
))}
</ul>
)}
</div>
)
}
export default ReturnShippingOptions
```
export default ReturnShippingOptions
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/shipping-options?is_return=true`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ shipping_options }) => {
console.log(shipping_options.length)
})
```
```ts
fetch(`<BACKEND_URL>/store/shipping-options?is_return=true`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ shipping_options }) => {
console.log(shipping_options.length)
})
```
</TabItem>
</TabItem>
</Tabs>
This API Route allows you to pass the `is_return` query parameter to indicate whether the shipping options should be return shipping options. You can learn about other available filters in the [API reference](https://docs.medusajs.com/api/store#shipping-options_getshippingoptions).
@@ -132,38 +132,10 @@ The request returns an array of shipping option objects.
You can create the return by sending a request to the [Create Return API Route](https://docs.medusajs.com/api/store#returns_postreturns):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.returns.create({
order_id,
items: [
{
item_id,
quantity: 1,
},
],
return_shipping: {
option_id,
},
})
.then((data) => {
console.log(data.return.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCreateReturn } from "medusa-react"
const CreateReturn = () => {
const createReturn = useCreateReturn()
// ...
const handleCreate = () => {
createReturn.mutate({
```ts
medusa.returns.create({
order_id,
items: [
{
@@ -175,44 +147,72 @@ const CreateReturn = () => {
option_id,
},
})
}
.then((data) => {
console.log(data.return.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default CreateReturn
```
```tsx
import { useCreateReturn } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const CreateReturn = () => {
const createReturn = useCreateReturn()
// ...
```ts
fetch(`<BACKEND_URL>/store/returns`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
order_id,
items: [
{
item_id,
quantity: 1,
const handleCreate = () => {
createReturn.mutate({
order_id,
items: [
{
item_id,
quantity: 1,
},
],
return_shipping: {
option_id,
},
})
}
// ...
}
export default CreateReturn
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/returns`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
],
return_shipping: {
option_id,
},
}),
})
.then((response) => response.json())
.then((data) => {
console.log(data.return.id)
})
```
body: JSON.stringify({
order_id,
items: [
{
item_id,
quantity: 1,
},
],
return_shipping: {
option_id,
},
}),
})
.then((response) => response.json())
.then((data) => {
console.log(data.return.id)
})
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the following request body parameters:
@@ -63,42 +63,10 @@ You can optionally allow customers to choose a return shipping option that they
After collecting the swap details in step 1, you can create a swap in the Medusa backend by sending a request to the [Create Swap API Route](https://docs.medusajs.com/api/store#swaps_postswaps):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.swaps.create({
order_id,
return_items: [
{
item_id,
quantity: 1,
},
],
additional_items: [
{
variant_id,
quantity: 1,
},
],
return_shipping_option,
})
.then(({ swap }) => {
console.log(swap.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCreateSwap } from "medusa-react"
const CreateSwap = () => {
const createSwap = useCreateSwap()
// ...
const handleCreate = () => {
createSwap.mutate({
```ts
medusa.swaps.create({
order_id,
return_items: [
{
@@ -114,48 +82,80 @@ const CreateSwap = () => {
],
return_shipping_option,
})
}
.then(({ swap }) => {
console.log(swap.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default CreateSwap
```
```tsx
import { useCreateSwap } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const CreateSwap = () => {
const createSwap = useCreateSwap()
// ...
```ts
fetch(`<BACKEND_URL>/store/swaps`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
order_id,
return_items: [
{
item_id,
quantity: 1,
const handleCreate = () => {
createSwap.mutate({
order_id,
return_items: [
{
item_id,
quantity: 1,
},
],
additional_items: [
{
variant_id,
quantity: 1,
},
],
return_shipping_option,
})
}
// ...
}
export default CreateSwap
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/swaps`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
],
additional_items: [
{
variant_id,
quantity: 1,
},
],
return_shipping_option,
}),
})
.then((response) => response.json())
.then(({ swap }) => {
console.log(swap.id)
})
```
body: JSON.stringify({
order_id,
return_items: [
{
item_id,
quantity: 1,
},
],
additional_items: [
{
variant_id,
quantity: 1,
},
],
return_shipping_option,
}),
})
.then((response) => response.json())
.then(({ swap }) => {
console.log(swap.id)
})
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the following request body parameters:
@@ -191,53 +191,53 @@ When you complete the cart, the returned `type` field can be used to indicate th
During your checkout flow, you might need to retrieve the swap using the cart’s ID. For example, if you want to display the swap’s details after the cart is successfully completed. You can do that using the [Get by Cart ID API Route](https://docs.medusajs.com/api/store#swaps_getswapsswapcartid):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.swaps.retrieveByCartId(cartId)
.then(({ swap }) => {
console.log(swap.id)
})
```
```ts
medusa.swaps.retrieveByCartId(cartId)
.then(({ swap }) => {
console.log(swap.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCartSwap } from "medusa-react"
```tsx
import { useCartSwap } from "medusa-react"
const Swap = () => {
const {
swap,
isLoading,
} = useCartSwap(cartId)
return (
<div>
{isLoading && <span>Loading...</span>}
{swap && <span>{swap.id}</span>}
</div>
)
}
const Swap = () => {
const {
swap,
isLoading,
} = useCartSwap(cartId)
return (
<div>
{isLoading && <span>Loading...</span>}
{swap && <span>{swap.id}</span>}
</div>
)
}
export default Swap
```
export default Swap
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/swaps/${cartId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ swap }) => {
console.log(swap.id)
})
```
```ts
fetch(`<BACKEND_URL>/store/swaps/${cartId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ swap }) => {
console.log(swap.id)
})
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the ID of the cart as a path parameter.
@@ -73,44 +73,44 @@ You must have an existing order edit in the “request” state.
You can retrieve a single order edit by its ID by sending a request to the [Get Order Edit API Route](https://docs.medusajs.com/api/store#order-edits_getordereditsorderedit):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.orderEdits.retrieve(orderEditId)
.then(({ order_edit }) => {
console.log(order_edit.changes)
// show changed items to the customer
})
```
```ts
medusa.orderEdits.retrieve(orderEditId)
.then(({ order_edit }) => {
console.log(order_edit.changes)
// show changed items to the customer
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useOrderEdit } from "medusa-react"
```tsx
import { useOrderEdit } from "medusa-react"
const OrderEdit = () => {
const { order_edit, isLoading } = useOrderEdit(orderEditId)
const OrderEdit = () => {
const { order_edit, isLoading } = useOrderEdit(orderEditId)
// ...
}
// ...
}
export default OrderEdit
```
export default OrderEdit
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/order-edits/${orderEditId}`)
.then((response) => response.json())
.then(({ order_edit }) => {
console.log(order_edit.changes)
// show changed items to the customer
})
```
```ts
fetch(`<BACKEND_URL>/store/order-edits/${orderEditId}`)
.then((response) => response.json())
.then(({ order_edit }) => {
console.log(order_edit.changes)
// show changed items to the customer
})
```
</TabItem>
</TabItem>
</Tabs>
The request requires the order edit’s ID as a path parameter.
@@ -201,132 +201,132 @@ If `difference_due` is greater than 0, then additional payment from the customer
2. When the customer selects the payment processor, initialize the payment session of that provider in the payment collection. You can do that by sending a request to the [Manage Payment Sessions API Route](https://docs.medusajs.com/api/store#payment-collections_postpaymentcollectionspaymentcollectionsessionsbatch), passing it the payment collection’s ID as a path parameter, and the payment processor's ID as a request body parameter:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
<!-- eslint-disable max-len -->
```ts
medusa.paymentCollections.managePaymentSession(paymentCollectionId, {
provider_id,
})
.then(({ payment_collection }) => {
console.log(payment_collection.payment_sessions)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useManagePaymentSession } from "medusa-react"
const OrderEditPayment = () => {
const managePaymentSession = useManagePaymentSession(
paymentCollectionId
)
// ...
const handleAdditionalPayment = (provider_id: string) => {
managePaymentSession.mutate({
```ts
medusa.paymentCollections.managePaymentSession(paymentCollectionId, {
provider_id,
})
}
.then(({ payment_collection }) => {
console.log(payment_collection.payment_sessions)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default OrderEditPayment
```
```tsx
import { useManagePaymentSession } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const OrderEditPayment = () => {
const managePaymentSession = useManagePaymentSession(
paymentCollectionId
)
// ...
const handleAdditionalPayment = (provider_id: string) => {
managePaymentSession.mutate({
provider_id,
})
}
// ...
}
export default OrderEditPayment
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(
`<BACKEND_URL>/store/payment-collections/${paymentCollectionId}/sessions`,
{
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
provider_id,
}),
}
)
.then((response) => response.json())
.then(({ payment_collection }) => {
console.log(payment_collection.payment_sessions)
})
```
```ts
fetch(
`<BACKEND_URL>/store/payment-collections/${paymentCollectionId}/sessions`,
{
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
provider_id,
}),
}
)
.then((response) => response.json())
.then(({ payment_collection }) => {
console.log(payment_collection.payment_sessions)
})
```
</TabItem>
</TabItem>
</Tabs>
1. Show the customer the payment details form based on the payment session’s provider. For example, if the provider ID of a payment session is `stripe`, you must show Stripe’s card component to enter the customer’s card details.
2. Authorize the payment using the payment processor. The [Authorize Payment Session API Route](https://docs.medusajs.com/api/store#payment-collections_postpaymentcollectionssessionssessionauthorize) accepts the payment collection’s ID and the ID of the payment session as path parameters:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa
.paymentCollection
.authorizePaymentSession(
paymentCollectionId,
paymentSessionId
)
.then(({ payment_session }) => {
console.log(payment_session.id)
})
```
```ts
medusa
.paymentCollection
.authorizePaymentSession(
paymentCollectionId,
paymentSessionId
)
.then(({ payment_session }) => {
console.log(payment_session.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAuthorizePaymentSession } from "medusa-react"
```tsx
import { useAuthorizePaymentSession } from "medusa-react"
const OrderEditPayment = () => {
const authorizePaymentSession = useAuthorizePaymentSession(
paymentCollectionId
)
// ...
const OrderEditPayment = () => {
const authorizePaymentSession = useAuthorizePaymentSession(
paymentCollectionId
)
// ...
const handleAuthorizePayment = (paymentSessionId: string) => {
authorizePaymentSession.mutate(paymentSessionId)
}
const handleAuthorizePayment = (paymentSessionId: string) => {
authorizePaymentSession.mutate(paymentSessionId)
}
// ...
}
// ...
}
export default OrderEditPayment
```
export default OrderEditPayment
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(
`<BACKEND_URL>/store/payment-collection/${paymentCollectionId}` +
`/sessions/${paymentSessionId}/authorize`,
{
method: "POST",
credentials: "include",
}
)
.then((response) => response.json())
.then(({ payment_session }) => {
console.log(payment_session.id)
})
```
```ts
fetch(
`<BACKEND_URL>/store/payment-collection/${paymentCollectionId}` +
`/sessions/${paymentSessionId}/authorize`,
{
method: "POST",
credentials: "include",
}
)
.then((response) => response.json())
.then(({ payment_session }) => {
console.log(payment_session.id)
})
```
</TabItem>
</TabItem>
</Tabs>
After performing the above steps, you can [complete the Order Edit](#complete-the-order-edit).
@@ -338,52 +338,52 @@ After performing the above steps, you can [complete the Order Edit](#complete-th
To confirm and complete the order edit, send a request to the [Complete Order Edit API Route](https://docs.medusajs.com/api/store#order-edits_postordereditsordereditcomplete):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.orderEdits.complete(orderEditId)
.then(({ order_edit }) => {
console.log(order_edit.confirmed_at)
})
```
```ts
medusa.orderEdits.complete(orderEditId)
.then(({ order_edit }) => {
console.log(order_edit.confirmed_at)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCompleteOrderEdit } from "medusa-react"
```tsx
import { useCompleteOrderEdit } from "medusa-react"
const OrderEdit = () => {
const completeOrderEdit = useCompleteOrderEdit(orderEditId)
// ...
const OrderEdit = () => {
const completeOrderEdit = useCompleteOrderEdit(orderEditId)
// ...
const handleCompleteOrderEdit = () => {
completeOrderEdit.mutate()
}
const handleCompleteOrderEdit = () => {
completeOrderEdit.mutate()
}
// ...
}
// ...
}
export default OrderEdit
```
export default OrderEdit
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/store/order-edits/${orderEditId}/complete`, {
method: "POST",
credentials: "include",
})
.then((response) => response.json())
.then(({ order_edit }) => {
console.log(order_edit.confirmed_at)
})
```
```ts
fetch(`<BACKEND_URL>/store/order-edits/${orderEditId}/complete`, {
method: "POST",
credentials: "include",
})
.then((response) => response.json())
.then(({ order_edit }) => {
console.log(order_edit.confirmed_at)
})
```
</TabItem>
</TabItem>
</Tabs>
This request accepts the order edit’s ID as a path parameter.
@@ -405,63 +405,63 @@ If the payment isn’t authorized first, the order edit completion will fail.
If the customer wants to decline the Order Edit, you can do that by sending a request to the Decline Order Edit API Route:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.orderEdits.decline(orderEditId, {
decline_reason: "I am not satisfied",
})
.then(({ order_edit }) => {
console.log(order_edit.declined_at)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useDeclineOrderEdit } from "medusa-react"
const OrderEdit = () => {
const declineOrderEdit = useDeclineOrderEdit(orderEditId)
// ...
const handleDeclineOrderEdit = () => {
declineOrderEdit.mutate({
declined_reason: "I am not satisfied",
})
}
// ...
}
export default OrderEdit
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(
`<BACKEND_URL>/store/order-edits/${orderEditId}/decline`,
{
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
```ts
medusa.orderEdits.decline(orderEditId, {
decline_reason: "I am not satisfied",
}),
}
)
.then((response) => response.json())
.then(({ order_edit }) => {
console.log(order_edit.declined_at)
})
```
})
.then(({ order_edit }) => {
console.log(order_edit.declined_at)
})
```
</TabItem>
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useDeclineOrderEdit } from "medusa-react"
const OrderEdit = () => {
const declineOrderEdit = useDeclineOrderEdit(orderEditId)
// ...
const handleDeclineOrderEdit = () => {
declineOrderEdit.mutate({
declined_reason: "I am not satisfied",
})
}
// ...
}
export default OrderEdit
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(
`<BACKEND_URL>/store/order-edits/${orderEditId}/decline`,
{
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
decline_reason: "I am not satisfied",
}),
}
)
.then((response) => response.json())
.then(({ order_edit }) => {
console.log(order_edit.declined_at)
})
```
</TabItem>
</Tabs>
The request requires passing the order edit’s ID as a path parameter.
@@ -80,47 +80,47 @@ When the customer wants to claim an order, they must supply its ID.
To allow the customer to claim an order, send a request to the Claim an Order API Route:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.orders.requestCustomerOrders({
order_ids: [
order_id,
],
})
.then(() => {
// successful
})
.catch(() => {
// an error occurred
})
```
```ts
medusa.orders.requestCustomerOrders({
order_ids: [
order_id,
],
})
.then(() => {
// successful
})
.catch(() => {
// an error occurred
})
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/orders/batch/customer/token`, {
method: "POST",
credentials: "include",
body: JSON.stringify({
order_ids: [
order_id,
],
}),
headers: {
"Content-Type": "application/json",
},
})
.then(() => {
// successful
})
.catch(() => {
// display an error to the customer
})
```
```ts
fetch(`<BACKEND_URL>/store/orders/batch/customer/token`, {
method: "POST",
credentials: "include",
body: JSON.stringify({
order_ids: [
order_id,
],
}),
headers: {
"Content-Type": "application/json",
},
})
.then(() => {
// successful
})
.catch(() => {
// display an error to the customer
})
```
</TabItem>
</TabItem>
</Tabs>
This request accepts as a body parameter the array `order_ids`. Each item in the array is the ID of an order that the customer wants to claim. You can pass more than one ID.
@@ -138,65 +138,65 @@ The link in the email that the customer receives should be a page in your storef
Then, you send a request to the Verify Claim Order API Route:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.orders.confirmRequest({
token,
})
.then(() => {
// successful
})
.catch(() => {
// an error occurred
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useGrantOrderAccess } from "medusa-react"
const ClaimOrder = () => {
const grantOrderAccess = useGrantOrderAccess()
// ...
const handleVerifyOrderClaim = (token: string) => {
grantOrderAccess.mutate(({
```ts
medusa.orders.confirmRequest({
token,
}))
}
})
.then(() => {
// successful
})
.catch(() => {
// an error occurred
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default ClaimOrder
```
```tsx
import { useGrantOrderAccess } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const ClaimOrder = () => {
const grantOrderAccess = useGrantOrderAccess()
// ...
```ts
fetch(`<BACKEND_URL>/store/orders/customer/confirm`, {
method: "POST",
credentials: "include",
body: JSON.stringify({
token,
}),
headers: {
"Content-Type": "application/json",
},
})
.then(() => {
// successful
})
.catch(() => {
// display an error to the customer
})
```
const handleVerifyOrderClaim = (token: string) => {
grantOrderAccess.mutate(({
token,
}))
}
</TabItem>
// ...
}
export default ClaimOrder
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/orders/customer/confirm`, {
method: "POST",
credentials: "include",
body: JSON.stringify({
token,
}),
headers: {
"Content-Type": "application/json",
},
})
.then(() => {
// successful
})
.catch(() => {
// display an error to the customer
})
```
</TabItem>
</Tabs>
This request accepts as a body parameter the string `token`. This would be the token passed as a parameter to your storefront page through the link in the email.
@@ -39,53 +39,53 @@ Retrieving an order by its ID is useful for different scenarios, such as using a
You can retrieve an order by its ID using the [Get Order API Route](https://docs.medusajs.com/api/store#orders_getordersorder):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.orders.retrieve(orderId)
.then(({ order }) => {
console.log(order.id)
})
```
```ts
medusa.orders.retrieve(orderId)
.then(({ order }) => {
console.log(order.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useOrder } from "medusa-react"
```tsx
import { useOrder } from "medusa-react"
const Order = () => {
const {
order,
isLoading,
} = useOrder(orderId)
return (
<div>
{isLoading && <span>Loading...</span>}
{order && <span>{order.display_id}</span>}
</div>
)
}
const Order = () => {
const {
order,
isLoading,
} = useOrder(orderId)
return (
<div>
{isLoading && <span>Loading...</span>}
{order && <span>{order.display_id}</span>}
</div>
)
}
export default Order
```
export default Order
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/orders/${orderId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.id)
})
```
```ts
fetch(`<BACKEND_URL>/store/orders/${orderId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.id)
})
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the order’s ID to be passed as a path parameter. You can utilize the [expand](https://docs.medusajs.com/api/store#expanding-fields) and [fields](https://docs.medusajs.com/api/store#selecting-fields) query parameters to select parameters and relations to return.
@@ -101,61 +101,61 @@ Display IDs allow you to show human-readable IDs to your customers. Retrieving a
You can retrieve an order by its display ID using the [Look Up Order API Route](https://docs.medusajs.com/api/store#orders_getorders):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.orders.lookupOrder({
display_id: 1,
email: "user@example.com",
})
.then(({ order }) => {
console.log(order.id)
})
```
```ts
medusa.orders.lookupOrder({
display_id: 1,
email: "user@example.com",
})
.then(({ order }) => {
console.log(order.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useOrders } from "medusa-react"
```tsx
import { useOrders } from "medusa-react"
const Order = () => {
const {
order,
isLoading,
} = useOrders({
display_id: 1,
email: "user@example.com",
})
return (
<div>
{isLoading && <span>Loading...</span>}
{order && <span>{order.display_id}</span>}
</div>
)
}
const Order = () => {
const {
order,
isLoading,
} = useOrders({
display_id: 1,
email: "user@example.com",
})
return (
<div>
{isLoading && <span>Loading...</span>}
{order && <span>{order.display_id}</span>}
</div>
)
}
export default Order
```
export default Order
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/store/orders?display_id=1&email=user@example.com`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.id)
})
```
```ts
fetch(`<BACKEND_URL>/store/orders?display_id=1&email=user@example.com`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.id)
})
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires two query parameters:
@@ -176,53 +176,53 @@ In certain scenarios, you may need to retrieve an order’s details using the ID
You can retrieve an order by the cart ID using the [Get by Cart ID API Route](https://docs.medusajs.com/api/store#orders_getordersordercartid):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.orders.retrieveByCartId(cartId)
.then(({ order }) => {
console.log(order.id)
})
```
```ts
medusa.orders.retrieveByCartId(cartId)
.then(({ order }) => {
console.log(order.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCartOrder } from "medusa-react"
```tsx
import { useCartOrder } from "medusa-react"
const Order = () => {
const {
order,
isLoading,
} = useCartOrder(cartId)
return (
<div>
{isLoading && <span>Loading...</span>}
{order && <span>{order.display_id}</span>}
</div>
)
}
const Order = () => {
const {
order,
isLoading,
} = useCartOrder(cartId)
return (
<div>
{isLoading && <span>Loading...</span>}
{order && <span>{order.display_id}</span>}
</div>
)
}
export default Order
```
export default Order
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/orders/cart/${cartId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.id)
})
```
```ts
fetch(`<BACKEND_URL>/store/orders/cart/${cartId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.id)
})
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the ID of the cart as a path parameter.
@@ -3,8 +3,9 @@ description: 'Learn how to bulk-import prices into Medusa using the Admin REST A
addHowToData: true
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
import Details from "@site/src/theme/MDXProvider/Details"
# How to Bulk Import Prices
@@ -39,81 +40,79 @@ Part of the process of importing prices is uploading a CSV file. This requires a
You must have a CSV file that you will use to import prices into your Medusa backend. You can check [this CSV example file](https://medusa-doc-files.s3.amazonaws.com/price-list-import-template.csv) to see which format is required for your import.
<details>
<summary>
Expected columns
</summary>
<Details>
<Summary>Expected columns</Summary>
<table class="reference-table">
<thead>
<tr>
<th>
Column Name
</th>
<th>
Description
</th>
<th>
Is required?
</th>
</tr>
</thead>
<table class="reference-table">
<thead>
<tr>
<th>
Column Name
</th>
<th>
Description
</th>
<th>
Is required?
</th>
</tr>
</thead>
<tbody>
<tbody>
<tr>
<td>
Product Variant ID
</td>
<td>
The ID of the product variant this price belongs to.
</td>
<td>
Either this or the SKU column are required.
</td>
</tr>
<tr>
<td>
Product Variant ID
</td>
<td>
The ID of the product variant this price belongs to.
</td>
<td>
Either this or the SKU column are required.
</td>
</tr>
<tr>
<td>
SKU
</td>
<td>
The SKU of the product variant this price belongs to.
</td>
<td>
Either this or the Product Variant ID column are required.
</td>
</tr>
<tr>
<td>
SKU
</td>
<td>
The SKU of the product variant this price belongs to.
</td>
<td>
Either this or the Product Variant ID column are required.
</td>
</tr>
<tr>
<td>
Price (region name)
</td>
<td>
The price amount in a region, where (region name) is the name of the region.
</td>
<td>
No
</td>
</tr>
<tr>
<td>
Price (region name)
</td>
<td>
The price amount in a region, where (region name) is the name of the region.
</td>
<td>
No
</td>
</tr>
<tr>
<td>
Price (currency code)
</td>
<td>
The price amount for a currency, where (currency code) is the 3 character iso code of the currency. For example, "Price USD".
</td>
<td>
No
</td>
</tr>
<tr>
<td>
Price (currency code)
</td>
<td>
The price amount for a currency, where (currency code) is the 3 character iso code of the currency. For example, "Price USD".
</td>
<td>
No
</td>
</tr>
</tbody>
</tbody>
</table>
</table>
</details>
</Details>
### JS Client
@@ -148,67 +147,67 @@ The first step is to upload the CSV file to import prices from.
You can do that by sending the following request to the [Upload Files API Route](https://docs.medusajs.com/api/admin#uploads_postuploads):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.uploads.create(file) // file is an instance of File
.then(({ uploads }) => {
const key = uploads[0].key
})
```
```ts
medusa.admin.uploads.create(file) // file is an instance of File
.then(({ uploads }) => {
const key = uploads[0].key
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminUploadFile } from "medusa-react"
```tsx
import { useAdminUploadFile } from "medusa-react"
const ImportPrices = () => {
const uploadFile = useAdminUploadFile()
// ...
const ImportPrices = () => {
const uploadFile = useAdminUploadFile()
// ...
const handleFileUpload = (file: File) => {
uploadFile.mutate(file)
}
const handleFileUpload = (file: File) => {
uploadFile.mutate(file)
}
// ...
}
// ...
}
export default ImportPrices
```
export default ImportPrices
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
const formData = new FormData()
formData.append("files", file) // file is an instance of File
```ts
const formData = new FormData()
formData.append("files", file) // file is an instance of File
fetch(`<BACKEND_URL>/admin/uploads`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "multipart/form-data",
},
body: formData,
})
.then((response) => response.json())
.then(({ uploads }) => {
const key = uploads[0].key
})
```
fetch(`<BACKEND_URL>/admin/uploads`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "multipart/form-data",
},
body: formData,
})
.then((response) => response.json())
.then(({ uploads }) => {
const key = uploads[0].key
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/uploads' \
-H 'Authorization: Bearer {api_token}' \
-H 'Content-Type: text/csv' \
-F 'files=@"<FILE_PATH_1>"'
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/uploads' \
-H 'Authorization: Bearer {api_token}' \
-H 'Content-Type: text/csv' \
-F 'files=@"<FILE_PATH_1>"'
```
</TabItem>
</TabItem>
</Tabs>
This request returns an array of uploads. Each item in the array is an object that includes the properties `url` and `key`. You’ll need the `key` to import the prices next.
@@ -222,93 +221,93 @@ To start a new price import, you must create a batch job.
You can do that by sending the following request to the [Create a Batch Job API Route](https://docs.medusajs.com/api/admin#batch-jobs_postbatchjobs):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.batchJobs.create({
type: "price-list-import",
context: {
fileKey: key, // obtained from previous step
price_list_id,
},
dry_run: true,
})
.then(( batch_job ) => {
console.log(batch_job.status)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCreateBatchJob } from "medusa-react"
const ImportPrices = () => {
const createBatchJob = useAdminCreateBatchJob()
// ...
const handleCreateBatchJob = () => {
createBatchJob.mutate({
```ts
medusa.admin.batchJobs.create({
type: "price-list-import",
context: {
fileKey: key, // obtained from previous step
price_list_id,
},
dry_run: true,
})
}
.then(( batch_job ) => {
console.log(batch_job.status)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default ImportPrices
```
```tsx
import { useAdminCreateBatchJob } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const ImportPrices = () => {
const createBatchJob = useAdminCreateBatchJob()
// ...
```ts
fetch(`<BACKEND_URL>/admin/batch-jobs`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
type: "price-list-import",
context: {
fileKey: key, // obtained from previous step
price_list_id,
},
dry_run: true,
}),
})
.then((response) => response.json())
.then(({ batch_job }) => {
console.log(batch_job.status)
})
```
const handleCreateBatchJob = () => {
createBatchJob.mutate({
type: "price-list-import",
context: {
fileKey: key, // obtained from previous step
},
dry_run: true,
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/batch-jobs' \
-H 'Authorization: Bearer {api_token}' \
-H 'Content-Type: application/json' \
--data-raw '{
"type": "price-list-import",
"context": {
"fileKey": "<KEY>",
"price_list_id": "<PRICE_LIST_ID>"
},
"dry_run": true
}'
# <KEY> is the key you obtained from the previous step
# <PRICE_LIST_ID> is the ID of the price list to import prices into
```
export default ImportPrices
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/batch-jobs`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
type: "price-list-import",
context: {
fileKey: key, // obtained from previous step
price_list_id,
},
dry_run: true,
}),
})
.then((response) => response.json())
.then(({ batch_job }) => {
console.log(batch_job.status)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/batch-jobs' \
-H 'Authorization: Bearer {api_token}' \
-H 'Content-Type: application/json' \
--data-raw '{
"type": "price-list-import",
"context": {
"fileKey": "<KEY>",
"price_list_id": "<PRICE_LIST_ID>"
},
"dry_run": true
}'
# <KEY> is the key you obtained from the previous step
# <PRICE_LIST_ID> is the ID of the price list to import prices into
```
</TabItem>
</Tabs>
In the body of the request, you must pass the following parameters:
@@ -336,65 +335,65 @@ After creating the batch job, it will be pre-processed. At this point, the CSV f
You can retrieve all the details of the batch job, including its status and the brief statistics related to the prices by sending the following request:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.batchJobs.retrieve(batchJobId)
.then(( batch_job ) => {
console.log(batch_job.status, batch_job.result)
})
```
```ts
medusa.admin.batchJobs.retrieve(batchJobId)
.then(( batch_job ) => {
console.log(batch_job.status, batch_job.result)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminBatchJob } from "medusa-react"
```tsx
import { useAdminBatchJob } from "medusa-react"
const ImportPrices = () => {
const { batch_job, isLoading } = useAdminBatchJob(batchJobId)
// ...
const ImportPrices = () => {
const { batch_job, isLoading } = useAdminBatchJob(batchJobId)
// ...
return (
<div>
{/* ... */}
{isLoading && <span>Loading</span>}
{batch_job && (
<span>
Status: {batch_job.status}.
Number of Prices: {batch_job.result.count}
</span>
)}
</div>
)
}
return (
<div>
{/* ... */}
{isLoading && <span>Loading</span>}
{batch_job && (
<span>
Status: {batch_job.status}.
Number of Prices: {batch_job.result.count}
</span>
)}
</div>
)
}
export default ImportPrices
```
export default ImportPrices
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/batch-jobs/${batchJobId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ batch_job }) => {
console.log(batch_job.status, batch_job.result)
})
```
```ts
fetch(`<BACKEND_URL>/admin/batch-jobs/${batchJobId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ batch_job }) => {
console.log(batch_job.status, batch_job.result)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/batch-jobs/<BATCH_JOB_ID>' \
-H 'Authorization: Bearer {api_token}'
# <BATCH_JOB_ID> is the ID of the batch job
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/batch-jobs/<BATCH_JOB_ID>' \
-H 'Authorization: Bearer {api_token}'
# <BATCH_JOB_ID> is the ID of the batch job
```
</TabItem>
</TabItem>
</Tabs>
This request accepts the batch job’s ID as a parameter, which can be retrieved from the previous request. It returns the batch job in the response.
@@ -426,59 +425,59 @@ A batch job can be confirmed only once the batch job has the status `pre_process
To confirm a batch job send the following request:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.batchJobs.confirm(batchJobId)
.then(( batch_job ) => {
console.log(batch_job.status)
})
```
```ts
medusa.admin.batchJobs.confirm(batchJobId)
.then(( batch_job ) => {
console.log(batch_job.status)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminConfirmBatchJob } from "medusa-react"
```tsx
import { useAdminConfirmBatchJob } from "medusa-react"
const ImportPrices = () => {
const confirmBatchJob = useAdminConfirmBatchJob(batchJobId)
// ...
const ImportPrices = () => {
const confirmBatchJob = useAdminConfirmBatchJob(batchJobId)
// ...
const handleConfirmJob = () => {
confirmBatchJob.mutate()
}
// ...
}
const handleConfirmJob = () => {
confirmBatchJob.mutate()
}
// ...
}
export default ImportPrices
```
export default ImportPrices
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/batch-jobs/${batchJobId}/confirm`, {
method: "POST",
credentials: "include",
})
.then((response) => response.json())
.then(({ batch_job }) => {
console.log(batch_job.status)
})
```
```ts
fetch(`<BACKEND_URL>/admin/batch-jobs/${batchJobId}/confirm`, {
method: "POST",
credentials: "include",
})
.then((response) => response.json())
.then(({ batch_job }) => {
console.log(batch_job.status)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/batch-jobs/<BATCH_JOB_ID>/confirm' \
-H 'Authorization: Bearer {api_token}'
# <BATCH_JOB_ID> is the ID of the batch job
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/batch-jobs/<BATCH_JOB_ID>/confirm' \
-H 'Authorization: Bearer {api_token}'
# <BATCH_JOB_ID> is the ID of the batch job
```
</TabItem>
</TabItem>
</Tabs>
This request accepts the ID of the batch job as a path parameter and returns the updated batch job. The returned batch job should have the status `confirmed`, which indicates that the batch job will now start processing.
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -54,73 +54,73 @@ You can learn more about [authenticating as an admin user in the API reference](
You can retrieve available categories by sending a request to the [List Categories API Route](https://docs.medusajs.com/api/admin#product-categories_getproductcategories):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.productCategories.list()
.then(({ product_categories, limit, offset, count }) => {
console.log(product_categories.length)
// display categories
})
```
```ts
medusa.admin.productCategories.list()
.then(({ product_categories, limit, offset, count }) => {
console.log(product_categories.length)
// display categories
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminProductCategories } from "medusa-react"
import { ProductCategory } from "@medusajs/medusa"
```tsx
import { useAdminProductCategories } from "medusa-react"
import { ProductCategory } from "@medusajs/medusa"
function Categories() {
const {
product_categories,
isLoading } = useAdminProductCategories()
function Categories() {
const {
product_categories,
isLoading } = useAdminProductCategories()
return (
<div>
{isLoading && <span>Loading...</span>}
{product_categories && !product_categories.length && (
<span>No Categories</span>
)}
{product_categories && product_categories.length > 0 && (
<ul>
{product_categories.map(
(category: ProductCategory) => (
<li key={category.id}>{category.name}</li>
)
return (
<div>
{isLoading && <span>Loading...</span>}
{product_categories && !product_categories.length && (
<span>No Categories</span>
)}
</ul>
)}
</div>
)
}
{product_categories && product_categories.length > 0 && (
<ul>
{product_categories.map(
(category: ProductCategory) => (
<li key={category.id}>{category.name}</li>
)
)}
</ul>
)}
</div>
)
}
export default Categories
```
export default Categories
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/product-categories`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ product_categories, limit, offset, count }) => {
console.log(product_categories.length)
// display product categories
})
```
```ts
fetch(`<BACKEND_URL>/admin/product-categories`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ product_categories, limit, offset, count }) => {
console.log(product_categories.length)
// display product categories
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/product-categories' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/product-categories' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This request returns an array of product categories, as well as [pagination fields](https://docs.medusajs.com/api/admin#pagination).
@@ -134,72 +134,72 @@ You can also pass filters and other selection query parameters to the request. C
You can create a category by sending a request to the [Create a Category API Route](https://docs.medusajs.com/api/admin#product-categories_postproductcategories):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.productCategories.create({
name: "Skinny Jeans",
})
.then(({ product_category }) => {
console.log(product_category.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCreateProductCategory } from "medusa-react"
const CreateCategory = () => {
const createCategory = useAdminCreateProductCategory()
// ...
const handleCreate = () => {
createCategory.mutate({
```ts
medusa.admin.productCategories.create({
name: "Skinny Jeans",
})
}
.then(({ product_category }) => {
console.log(product_category.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default CreateCategory
```
```tsx
import { useAdminCreateProductCategory } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const CreateCategory = () => {
const createCategory = useAdminCreateProductCategory()
// ...
```ts
fetch(`<BACKEND_URL>/admin/product-categories`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Skinny Jeans",
}),
})
.then((response) => response.json())
.then(({ product_category }) => {
console.log(product_category.id)
})
```
const handleCreate = () => {
createCategory.mutate({
name: "Skinny Jeans",
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/product-categories' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"name": "Skinny Jeans"
}'
```
export default CreateCategory
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/product-categories`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Skinny Jeans",
}),
})
.then((response) => response.json())
.then(({ product_category }) => {
console.log(product_category.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/product-categories' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"name": "Skinny Jeans"
}'
```
</TabItem>
</Tabs>
This request requires one body parameter `name`, which is the name of the category. The request also accepts the following optional body parameters:
@@ -218,63 +218,63 @@ The request returns the newly created product category.
You can retrieve a product category by sending a request to the [Get a Product Category API Route](https://docs.medusajs.com/api/admin#product-categories_getproductcategoriescategory):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.productCategories.retrieve(productCategoryId)
.then(({ product_category }) => {
console.log(product_category.id)
})
```
```ts
medusa.admin.productCategories.retrieve(productCategoryId)
.then(({ product_category }) => {
console.log(product_category.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminProductCategory } from "medusa-react"
```tsx
import { useAdminProductCategory } from "medusa-react"
const Category = () => {
const {
product_category,
isLoading,
} = useAdminProductCategory(productCategoryId)
return (
<div>
{isLoading && <span>Loading...</span>}
{product_category && <span>{product_category.name}</span>}
</div>
)
}
const Category = () => {
const {
product_category,
isLoading,
} = useAdminProductCategory(productCategoryId)
return (
<div>
{isLoading && <span>Loading...</span>}
{product_category && <span>{product_category.name}</span>}
</div>
)
}
export default Category
```
export default Category
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ product_category }) => {
console.log(product_category.id)
})
```
```ts
fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ product_category }) => {
console.log(product_category.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/product-categories/<CAT_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/product-categories/<CAT_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This request requires the ID of the category to be passed as a path parameter.
@@ -288,76 +288,76 @@ It returns the full object of the product category.
You can edit a product category by sending a request to the [Update a Product Category API Route](https://docs.medusajs.com/api/admin#product-categories_postproductcategoriescategory):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.productCategories.update(productCategoryId, {
name: "Skinny Jeans",
})
.then(({ product_category }) => {
console.log(product_category.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminUpdateProductCategory } from "medusa-react"
const UpdateCategory = () => {
const updateCategory = useAdminUpdateProductCategory(
productCategoryId
)
// ...
const handleUpdate = () => {
updateCategory.mutate({
name: "Skinny Jeans",
```ts
medusa.admin.productCategories.update(productCategoryId, {
name: "Skinny Jeans",
})
}
.then(({ product_category }) => {
console.log(product_category.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default UpdateCategory
```
```tsx
import { useAdminUpdateProductCategory } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const UpdateCategory = () => {
const updateCategory = useAdminUpdateProductCategory(
productCategoryId
)
// ...
const handleUpdate = () => {
updateCategory.mutate({
name: "Skinny Jeans",
})
}
// ...
}
export default UpdateCategory
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Skinny Jeans",
}),
})
.then((response) => response.json())
.then(({ product_category }) => {
console.log(product_category.id)
})
```
```ts
fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Skinny Jeans",
}),
})
.then((response) => response.json())
.then(({ product_category }) => {
console.log(product_category.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/product-categories/<CAT_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"name": "Skinny Jeans",
}'
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/product-categories/<CAT_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"name": "Skinny Jeans",
}'
```
</TabItem>
</TabItem>
</Tabs>
This request requires the ID of the category to be passed as a path parameter.
@@ -383,38 +383,10 @@ You can manage the categories of each product individually using the [product AP
You can add more than one product to a category using the [Add Products to a Category API Route](https://docs.medusajs.com/api/admin#product-categories_postproductcategoriescategoryproductsbatch):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.productCategories.addProducts(productCategoryId, {
product_ids: [
{
id: productId1,
},
{
id: productId2,
},
],
})
.then(({ product_category }) => {
console.log(product_category.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminAddProductsToCategory } from "medusa-react"
const UpdateProductsInCategory = () => {
const addProductsToCategory = useAdminAddProductsToCategory(
productCategoryId
)
// ...
const handleAdd = () => {
addProductsToCategory.mutate({
```ts
medusa.admin.productCategories.addProducts(productCategoryId, {
product_ids: [
{
id: productId1,
@@ -424,63 +396,91 @@ const UpdateProductsInCategory = () => {
},
],
})
}
.then(({ product_category }) => {
console.log(product_category.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default UpdateProductsInCategory
```
```tsx
import { useAdminAddProductsToCategory } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const UpdateProductsInCategory = () => {
const addProductsToCategory = useAdminAddProductsToCategory(
productCategoryId
)
// ...
const handleAdd = () => {
addProductsToCategory.mutate({
product_ids: [
{
id: productId1,
},
{
id: productId2,
},
],
})
}
// ...
}
export default UpdateProductsInCategory
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}/products/batch`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
product_ids: [
{
id: productId1,
```ts
fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}/products/batch`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
{
id: productId2,
},
],
}),
})
.then((response) => response.json())
.then(({ product_category }) => {
console.log(product_category.id)
})
```
body: JSON.stringify({
product_ids: [
{
id: productId1,
},
{
id: productId2,
},
],
}),
})
.then((response) => response.json())
.then(({ product_category }) => {
console.log(product_category.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/product-categories/<CAT_ID>/products/batch' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"product_ids": [
{
"id": "productId1"
},
{
"id": "productId2"
}
]
}'
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/product-categories/<CAT_ID>/products/batch' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"product_ids": [
{
"id": "productId1"
},
{
"id": "productId2"
}
]
}'
```
</TabItem>
</TabItem>
</Tabs>
This request requires the ID of the category to be passed as a path parameter.
@@ -494,108 +494,108 @@ The request returns the full object of the product category updated with the new
You can remove products from a category by sending a request to the [Delete Products API Route](https://docs.medusajs.com/api/admin#product-categories_deleteproductcategoriescategoryproductsbatch):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.productCategories.removeProducts(
productCategoryId,
{
product_ids: [
```ts
medusa.admin.productCategories.removeProducts(
productCategoryId,
{
id: productId1,
},
{
id: productId2,
},
],
}
)
.then(({ product_category }) => {
console.log(product_category.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import {
useAdminDeleteProductsFromCategory,
} from "medusa-react"
const DeleteProductsFromCategory = () => {
const deleteProductsFromCategory =
useAdminDeleteProductsFromCategory(productCategoryId)
// ...
const handleDelete = () => {
deleteProductsFromCategory.mutate({
product_ids: [
{
id: productId1,
},
{
id: productId2,
},
],
product_ids: [
{
id: productId1,
},
{
id: productId2,
},
],
}
)
.then(({ product_category }) => {
console.log(product_category.id)
})
}
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default DeleteProductsFromCategory
```
```tsx
import {
useAdminDeleteProductsFromCategory,
} from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const DeleteProductsFromCategory = () => {
const deleteProductsFromCategory =
useAdminDeleteProductsFromCategory(productCategoryId)
// ...
const handleDelete = () => {
deleteProductsFromCategory.mutate({
product_ids: [
{
id: productId1,
},
{
id: productId2,
},
],
})
}
// ...
}
export default DeleteProductsFromCategory
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}/products/batch`, {
credentials: "include",
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
product_ids: [
{
id: productId1,
```ts
fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}/products/batch`, {
credentials: "include",
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
{
id: productId2,
},
],
}),
})
.then((response) => response.json())
.then(({ product_category }) => {
console.log(product_category.id)
})
```
body: JSON.stringify({
product_ids: [
{
id: productId1,
},
{
id: productId2,
},
],
}),
})
.then((response) => response.json())
.then(({ product_category }) => {
console.log(product_category.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/product-categories/<CAT_ID>/products/batch' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"product_ids": [
{
"id": "productId1"
},
{
"id": "productId2"
}
]
}'
```
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/product-categories/<CAT_ID>/products/batch' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"product_ids": [
{
"id": "productId1"
},
{
"id": "productId2"
}
]
}'
```
</TabItem>
</TabItem>
</Tabs>
This request requires the ID of the category to be passed as a path parameter.
@@ -611,62 +611,61 @@ The request returns the full object of the product category updated with the its
You can delete a product category by sending a request to the [Delete a Product Category API Route](https://docs.medusajs.com/api/admin#product-categories_deleteproductcategoriescategory):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.productCategories.delete(productCategoryId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
medusa.admin.productCategories.delete(productCategoryId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminDeleteProductCategory } from "medusa-react"
```tsx
import { useAdminDeleteProductCategory } from "medusa-react"
const Category = () => {
const deleteCategory = useAdminDeleteProductCategory(
productCategoryId
)
// ...
const Category = () => {
const deleteCategory = useAdminDeleteProductCategory(
productCategoryId
)
// ...
const handleDelete = () => {
deleteCategory.mutate()
}
const handleDelete = () => {
deleteCategory.mutate()
}
// ...
}
// ...
}
export default Category
```
export default Category
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/product-categories/<CAT_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/product-categories/<CAT_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This request requires the ID of the category to be passed as a path parameter.
File diff suppressed because it is too large. Load diff
@@ -111,8 +111,8 @@ For example, if a variant's price is 10 USD, it's stored is `1000`, as in 1,000
For zero-decimal currencies, the amount is still stored as an integer without multiplying by a 100. For example, if a variant's price is ¥500, it's stored as `500`.
<details>
<summary>Zero-decimal Currencies</summary>
<Details>
<Summary>Zero-decimal Currencies</Summary>
- BIF
- CLP
@@ -131,7 +131,7 @@ For zero-decimal currencies, the amount is still stored as an integer without mu
- XOF
- XPF
</details>
</Details>
This logic of formatting the price is not handled in the backend. So, when you add a product variant using the Admin APIs, you must format the price as explained earlier. The backend stores the price as received from API requests.
@@ -100,8 +100,8 @@ Migrations are used to create your database schema. Before you can run migration
The first command runs the migrations, and the second command allows you to optionally seed your database with demo products. However, you’d need the following seed file added in the root of your Next.js directory:
<details>
<summary>Seed file</summary>
<Details>
<Summary>Seed file</Summary>
```js title=seed-data.js
const productCategoriesData = [
@@ -194,7 +194,7 @@ The first command runs the migrations, and the second command allows you to opti
}
```
</details>
</Details>
Then run the first and optionally second commands to migrate the database schema:
File diff suppressed because it is too large. Load diff
@@ -48,7 +48,7 @@ If you follow the Medusa React code blocks, it's assumed you already have [Medus
This guide also includes code snippets to utilize the `@medusajs/product` module in your storefront, among other methods.
If you follow the `@medusajs/product` code blocks, it's assumed you already have the [@medusajs/product](../serverless-module.md) installed.
If you follow the `@medusajs/product` code blocks, it's assumed you already have the [@medusajs/product](../serverless-module.mdx) installed.
---
@@ -57,95 +57,95 @@ If you follow the `@medusajs/product` code blocks, it's assumed you already have
You can list product categories by sending a request to the [List Product Categories API Route](https://docs.medusajs.com/api/store#product-categories_getproductcategories):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.productCategories.list()
.then(({ product_categories, limit, offset, count }) => {
console.log(product_categories.length)
})
```
```ts
medusa.productCategories.list()
.then(({ product_categories, limit, offset, count }) => {
console.log(product_categories.length)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useProductCategories } from "medusa-react"
import { ProductCategory } from "@medusajs/medusa"
```tsx
import { useProductCategories } from "medusa-react"
import { ProductCategory } from "@medusajs/medusa"
function Categories() {
const {
product_categories,
isLoading,
} = useProductCategories()
function Categories() {
const {
product_categories,
isLoading,
} = useProductCategories()
return (
<div>
{isLoading && <span>Loading...</span>}
{product_categories && !product_categories.length && (
<span>No Categories</span>
)}
{product_categories && product_categories.length > 0 && (
<ul>
{product_categories.map(
(category: ProductCategory) => (
<li key={category.id}>{category.name}</li>
)
return (
<div>
{isLoading && <span>Loading...</span>}
{product_categories && !product_categories.length && (
<span>No Categories</span>
)}
</ul>
)}
</div>
)
}
{product_categories && product_categories.length > 0 && (
<ul>
{product_categories.map(
(category: ProductCategory) => (
<li key={category.id}>{category.name}</li>
)
)}
</ul>
)}
</div>
)
}
export default Categories
```
export default Categories
```
</TabItem>
<TabItem value="module" label={(
<>
@medusajs/product
<Badge variant="orange" className="ml-0.5">beta</Badge>
</>
)}>
</TabItem>
<TabItem value="module" label={(
<>
@medusajs/product
<Badge variant="orange" className="ml-0.5">beta</Badge>
</>
)}>
```ts
import {
initialize as initializeProductModule,
} from "@medusajs/product"
```ts
import {
initialize as initializeProductModule,
} from "@medusajs/product"
// in an async function, or you can use promises
async () => {
// ...
const productService = await initializeProductModule()
const categories = await productService.listCategories()
// in an async function, or you can use promises
async () => {
// ...
const productService = await initializeProductModule()
const categories = await productService.listCategories()
console.log(categories)
}
```
console.log(categories)
}
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/product-categories`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ product_categories, limit, offset, count }) => {
console.log(product_categories.length)
})
```
```ts
fetch(`<BACKEND_URL>/store/product-categories`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ product_categories, limit, offset, count }) => {
console.log(product_categories.length)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/store/product-categories' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/store/product-categories' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This request does not require any query parameters. You can, however, pass query parameters to filter the list of categories, such as the passing the `q` query parameter to search categories by title or handle. You can learn about available query parameters in the [API reference](https://docs.medusajs.com/api/store#product-categories_getproductcategories).
@@ -163,84 +163,84 @@ By default, the categories are not retrieved along with their nested children. T
You can retrieve a single product category by its ID using the [Get a Product Category API Route](https://docs.medusajs.com/api/store#product-categories_getproductcategoriescategory):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.productCategories.retrieve(productCategoryId)
.then(({ product_category }) => {
console.log(product_category.name)
})
```
```ts
medusa.productCategories.retrieve(productCategoryId)
.then(({ product_category }) => {
console.log(product_category.name)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useProductCategory } from "medusa-react"
```tsx
import { useProductCategory } from "medusa-react"
function Category() {
const { product_category, isLoading } = useProductCategory()
function Category() {
const { product_category, isLoading } = useProductCategory()
return (
<div>
{isLoading && <span>Loading...</span>}
{product_category && <span>{product_category.name}</span>}
</div>
)
}
return (
<div>
{isLoading && <span>Loading...</span>}
{product_category && <span>{product_category.name}</span>}
</div>
)
}
export default Category
```
export default Category
```
</TabItem>
<TabItem value="module" label={(
<>
@medusajs/product
<Badge variant="orange">beta</Badge>
</>
)}>
</TabItem>
<TabItem value="module" label={(
<>
@medusajs/product
<Badge variant="orange">beta</Badge>
</>
)}>
```ts
import {
initialize as initializeProductModule,
} from "@medusajs/product"
```ts
import {
initialize as initializeProductModule,
} from "@medusajs/product"
// in an async function, or you can use promises
async () => {
// ...
const productService = await initializeProductModule()
const categories = await productService.listCategories({
id: productCategoryId,
})
// in an async function, or you can use promises
async () => {
// ...
const productService = await initializeProductModule()
const categories = await productService.listCategories({
id: productCategoryId,
})
console.log(categories[0])
}
```
console.log(categories[0])
}
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/store/product-categories/${productCategoryId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ product_category }) => {
console.log(product_category.name)
})
```
```ts
fetch(`<BACKEND_URL>/store/product-categories/${productCategoryId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ product_category }) => {
console.log(product_category.name)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/store/product-categories/<CAT_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/store/product-categories/<CAT_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This request requires the product category ID as a path parameter. You can also pass query parameters such as `expand` and `fields` as explained in the [API reference](https://docs.medusajs.com/api/store#product-categories_getproductcategoriescategory).
@@ -256,107 +256,107 @@ On the storefront, you may use the handle of a category as its page’s path. Fo
You can retrieve the details of a category by its handle by sending a request to the List Categories API Route, passing the `handle` as a filter:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.productCategories.list({
handle: "women",
})
.then(({ product_categories, limit, offset, count }) => {
if (!product_categories.length) {
// category does not exist
}
const category = product_categories[0]
})
```
```ts
medusa.productCategories.list({
handle: "women",
})
.then(({ product_categories, limit, offset, count }) => {
if (!product_categories.length) {
// category does not exist
}
const category = product_categories[0]
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useProductCategories } from "medusa-react"
import { ProductCategory } from "@medusajs/medusa"
```tsx
import { useProductCategories } from "medusa-react"
import { ProductCategory } from "@medusajs/medusa"
function Categories() {
const {
product_categories,
isLoading,
} = useProductCategories({
handle: "women",
})
function Categories() {
const {
product_categories,
isLoading,
} = useProductCategories({
handle: "women",
})
return (
<div>
{isLoading && <span>Loading...</span>}
{product_categories && !product_categories.length && (
<span>No Categories</span>
)}
{product_categories && product_categories.length > 0 && (
<ul>
{product_categories.map(
(category: ProductCategory) => (
<li key={category.id}>{category.name}</li>
)
return (
<div>
{isLoading && <span>Loading...</span>}
{product_categories && !product_categories.length && (
<span>No Categories</span>
)}
</ul>
)}
</div>
)
}
{product_categories && product_categories.length > 0 && (
<ul>
{product_categories.map(
(category: ProductCategory) => (
<li key={category.id}>{category.name}</li>
)
)}
</ul>
)}
</div>
)
}
export default Categories
```
export default Categories
```
</TabItem>
<TabItem value="module" label={(
<>
@medusajs/product
<Badge variant="orange">beta</Badge>
</>
)}>
</TabItem>
<TabItem value="module" label={(
<>
@medusajs/product
<Badge variant="orange">beta</Badge>
</>
)}>
```ts
import {
initialize as initializeProductModule,
} from "@medusajs/product"
```ts
import {
initialize as initializeProductModule,
} from "@medusajs/product"
// in an async function, or you can use promises
async () => {
// ...
const productService = await initializeProductModule()
const categories = await productService.listCategories({
handle,
})
// in an async function, or you can use promises
async () => {
// ...
const productService = await initializeProductModule()
const categories = await productService.listCategories({
handle,
})
console.log(categories[0])
}
```
console.log(categories[0])
}
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/product-categories?handle=women`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ product_categories, limit, offset, count }) => {
if (!product_categories.length) {
// category does not exist
}
const category = product_categories[0]
})
```
```ts
fetch(`<BACKEND_URL>/store/product-categories?handle=women`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ product_categories, limit, offset, count }) => {
if (!product_categories.length) {
// category does not exist
}
const category = product_categories[0]
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/store/product-categories?handle=women' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/store/product-categories?handle=women' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
As the `handle` of each category is unique, when you pass the handle as a filter you’ll either:
@@ -63,67 +63,67 @@ You can learn more about [authenticating as an admin user in the API reference](
You can list all available currencies in your system by sending a request to the [List Currencies API Route](https://docs.medusajs.com/api/admin#currencies_getcurrencies):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.currencies.list()
.then(({ currencies, count, offset, limit }) => {
console.log(currencies.length)
})
```
```ts
medusa.admin.currencies.list()
.then(({ currencies, count, offset, limit }) => {
console.log(currencies.length)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { Currency } from "@medusajs/medusa"
import { useAdminCurrencies } from "medusa-react"
```tsx
import { Currency } from "@medusajs/medusa"
import { useAdminCurrencies } from "medusa-react"
const Currencies = () => {
const { currencies, isLoading } = useAdminCurrencies()
const Currencies = () => {
const { currencies, isLoading } = useAdminCurrencies()
return (
<div>
{isLoading && <span>Loading...</span>}
{currencies && !currencies.length && (
<span>No Currencies</span>
)}
{currencies && currencies.length > 0 && (
<ul>
{currencies.map((currency: Currency) => (
<li key={currency.code}>{currency.name}</li>
))}
</ul>
)}
</div>
)
}
return (
<div>
{isLoading && <span>Loading...</span>}
{currencies && !currencies.length && (
<span>No Currencies</span>
)}
{currencies && currencies.length > 0 && (
<ul>
{currencies.map((currency: Currency) => (
<li key={currency.code}>{currency.name}</li>
))}
</ul>
)}
</div>
)
}
export default Currencies
```
export default Currencies
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/currencies`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ currencies, count, offset, limit }) => {
console.log(currencies.length)
})
```
```ts
fetch(`<BACKEND_URL>/admin/currencies`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ currencies, count, offset, limit }) => {
console.log(currencies.length)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/currencies' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/currencies' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route accepts optional filter and search query parameters. For example, you can pass the `code` query parameter to search the list of currencies by a code. You can learn about available query parameters in the [API reference](https://docs.medusajs.com/api/admin#currencies_getcurrencies).
@@ -137,72 +137,72 @@ This request returns an array of currencies along with pagination parameters.
You can update a currency by sending a request to the [Update Currency API Route](https://docs.medusajs.com/api/admin#currencies_postcurrenciescurrency):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.currencies.update(code, {
includes_tax: true,
})
.then(({ currency }) => {
console.log(currency.code)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminUpdateCurrency } from "medusa-react"
const UpdateCode = () => {
const updateCode = useAdminUpdateCurrency(code)
// ...
const handleUpdate = () => {
updateCode.mutate({
includes_tax,
```ts
medusa.admin.currencies.update(code, {
includes_tax: true,
})
}
.then(({ currency }) => {
console.log(currency.code)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default UpdateCode
```
```tsx
import { useAdminUpdateCurrency } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const UpdateCode = () => {
const updateCode = useAdminUpdateCurrency(code)
// ...
```ts
fetch(`<BACKEND_URL>/admin/currencies/${code}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
includes_tax,
}),
})
.then((response) => response.json())
.then(({ currency }) => {
console.log(currency.code)
})
```
const handleUpdate = () => {
updateCode.mutate({
includes_tax,
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X GET '<BACKEND_URL>/admin/currencies/<CODE>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"includes_tax": true
}'
```
export default UpdateCode
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/currencies/${code}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
includes_tax,
}),
})
.then((response) => response.json())
.then(({ currency }) => {
console.log(currency.code)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/currencies/<CODE>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"includes_tax": true
}'
```
</TabItem>
</Tabs>
This API Route requires the currency code as a path parameter.
@@ -228,72 +228,72 @@ This section explains how you can manage the currencies of a store.
You can list currencies in a store by sending a request to the [Get Store Details API Route](https://docs.medusajs.com/api/admin#store_getstore):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.store.retrieve()
.then(({ store }) => {
console.log(store.currencies, store.default_currency)
})
```
```ts
medusa.admin.store.retrieve()
.then(({ store }) => {
console.log(store.currencies, store.default_currency)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { Currency } from "@medusajs/medusa"
import { useAdminStore } from "medusa-react"
```tsx
import { Currency } from "@medusajs/medusa"
import { useAdminStore } from "medusa-react"
const StoreCurrencies = () => {
const { store, isLoading } = useAdminStore()
const StoreCurrencies = () => {
const { store, isLoading } = useAdminStore()
return (
<div>
{isLoading && <span>Loading...</span>}
{store && store.default_currency && (
<span>
Default Currency: {store.default_currency.code}
</span>
)}
{store && !store.currencies.length && (
<span>No Currencies</span>
)}
{store?.currencies && store.currencies.length > 0 && (
<ul>
{store.currencies.map((currency: Currency) => (
<li key={currency.code}>{currency.name}</li>
))}
</ul>
)}
</div>
)
}
return (
<div>
{isLoading && <span>Loading...</span>}
{store && store.default_currency && (
<span>
Default Currency: {store.default_currency.code}
</span>
)}
{store && !store.currencies.length && (
<span>No Currencies</span>
)}
{store?.currencies && store.currencies.length > 0 && (
<ul>
{store.currencies.map((currency: Currency) => (
<li key={currency.code}>{currency.name}</li>
))}
</ul>
)}
</div>
)
}
export default StoreCurrencies
```
export default StoreCurrencies
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/store`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ store }) => {
console.log(store.currencies, store.default_currency)
})
```
```ts
fetch(`<BACKEND_URL>/admin/store`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ store }) => {
console.log(store.currencies, store.default_currency)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/store' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/store' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This request returns the store as an object. In that object, there are two properties related to currencies:
@@ -306,58 +306,58 @@ This request returns the store as an object. In that object, there are two prope
You can add a currency to a store using the [Add a Currency Code API Route](https://docs.medusajs.com/api/admin#store_poststorecurrenciescode):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.store.addCurrency(code)
.then(({ store }) => {
console.log(store.currencies)
})
```
```ts
medusa.admin.store.addCurrency(code)
.then(({ store }) => {
console.log(store.currencies)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminAddStoreCurrency } from "medusa-react"
```tsx
import { useAdminAddStoreCurrency } from "medusa-react"
const AddCurrency = () => {
const addCode = useAdminAddStoreCurrency()
// ...
const AddCurrency = () => {
const addCode = useAdminAddStoreCurrency()
// ...
const handleAdd = () => {
addCode.mutate(code)
}
const handleAdd = () => {
addCode.mutate(code)
}
// ...
}
// ...
}
export default AddCurrency
```
export default AddCurrency
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/store/currencies/${code}`, {
credentials: "include",
method: "POST",
})
.then((response) => response.json())
.then(({ store }) => {
console.log(store.currencies)
})
```
```ts
fetch(`<BACKEND_URL>/admin/store/currencies/${code}`, {
credentials: "include",
method: "POST",
})
.then((response) => response.json())
.then(({ store }) => {
console.log(store.currencies)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/store/currencies/<CODE>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/store/currencies/<CODE>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the currency code to be passed as a path parameter.
@@ -369,58 +369,58 @@ The request returns the updated store as an object. You can access the new list
You can remove a currency from a store by sending a request to the [Delete Currency Code API Route](https://docs.medusajs.com/api/admin#store_deletestorecurrenciescode):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.store.deleteCurrency(code)
.then(({ store }) => {
console.log(store.currencies)
})
```
```ts
medusa.admin.store.deleteCurrency(code)
.then(({ store }) => {
console.log(store.currencies)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminDeleteStoreCurrency } from "medusa-react"
```tsx
import { useAdminDeleteStoreCurrency } from "medusa-react"
const DeleteCurrency = () => {
const deleteCurrency = useAdminDeleteStoreCurrency()
// ...
const DeleteCurrency = () => {
const deleteCurrency = useAdminDeleteStoreCurrency()
// ...
const handleDelete = () => {
deleteCurrency.mutate(code)
}
const handleDelete = () => {
deleteCurrency.mutate(code)
}
// ...
}
// ...
}
export default DeleteCurrency
```
export default DeleteCurrency
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/store/currencies/${code}`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(({ store }) => {
console.log(store.currencies)
})
```
```ts
fetch(`<BACKEND_URL>/admin/store/currencies/${code}`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(({ store }) => {
console.log(store.currencies)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/store/currencies/<CODE>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/store/currencies/<CODE>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the currency code to be passed as a path parameter.
@@ -63,67 +63,67 @@ You can learn more about [authenticating as an admin user in the API reference](
You can retrieve regions available on your backend using the [List Regions API Route](https://docs.medusajs.com/api/admin#regions_getregions):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.regions.list()
.then(({ regions, limit, offset, count }) => {
console.log(regions.length)
// display regions
})
```
```ts
medusa.admin.regions.list()
.then(({ regions, limit, offset, count }) => {
console.log(regions.length)
// display regions
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { Region } from "@medusajs/medusa"
import { useAdminRegions } from "medusa-react"
```tsx
import { Region } from "@medusajs/medusa"
import { useAdminRegions } from "medusa-react"
const Regions = () => {
const { regions, isLoading } = useAdminRegions()
const Regions = () => {
const { regions, isLoading } = useAdminRegions()
return (
<div>
{isLoading && <span>Loading...</span>}
{regions && !regions.length && <span>No Regions</span>}
{regions && regions.length > 0 && (
<ul>
{regions.map((region: Region) => (
<li key={region.id}>{region.name}</li>
))}
</ul>
)}
</div>
)
}
return (
<div>
{isLoading && <span>Loading...</span>}
{regions && !regions.length && <span>No Regions</span>}
{regions && regions.length > 0 && (
<ul>
{regions.map((region: Region) => (
<li key={region.id}>{region.name}</li>
))}
</ul>
)}
</div>
)
}
export default Regions
```
export default Regions
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/regions`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ regions, limit, offset, count }) => {
console.log(regions.length)
// display regions
})
```
```ts
fetch(`<BACKEND_URL>/admin/regions`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ regions, limit, offset, count }) => {
console.log(regions.length)
// display regions
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/regions' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/regions' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This request returns an array of regions, as well as [pagination fields](https://docs.medusajs.com/api/admin#pagination).
@@ -137,40 +137,10 @@ You can also pass filters and other selection query parameters to the request. C
You can create a region by sending a request to the [Create a Region API Route](https://docs.medusajs.com/api/admin#regions_postregions):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.regions.create({
name: "Europe",
currency_code: "eur",
tax_rate: 0,
payment_providers: [
"manual",
],
fulfillment_providers: [
"manual",
],
countries: [
"DK",
],
})
.then(({ region }) => {
console.log(region.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCreateRegion } from "medusa-react"
const CreateRegion = () => {
const createRegion = useAdminCreateRegion()
// ...
const handleCreate = () => {
createRegion.mutate({
```ts
medusa.admin.regions.create({
name: "Europe",
currency_code: "eur",
tax_rate: 0,
@@ -184,69 +154,99 @@ const CreateRegion = () => {
"DK",
],
})
}
.then(({ region }) => {
console.log(region.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default CreateRegion
```
```tsx
import { useAdminCreateRegion } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const CreateRegion = () => {
const createRegion = useAdminCreateRegion()
// ...
```ts
fetch(`<BACKEND_URL>/admin/regions`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Europe",
currency_code: "eur",
tax_rate: 0,
payment_providers: [
"manual",
],
fulfillment_providers: [
"manual",
],
countries: [
"DK",
],
}),
})
.then((response) => response.json())
.then(({ region }) => {
console.log(region.id)
})
```
const handleCreate = () => {
createRegion.mutate({
name: "Europe",
currency_code: "eur",
tax_rate: 0,
payment_providers: [
"manual",
],
fulfillment_providers: [
"manual",
],
countries: [
"DK",
],
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/regions' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"name": "Europe",
"currency_code": "eur",
"tax_rate": 0,
"payment_providers": [
"manual"
],
"fulfillment_providers": [
"manual"
],
"countries": [
"DK"
]
}'
```
export default CreateRegion
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/regions`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Europe",
currency_code: "eur",
tax_rate: 0,
payment_providers: [
"manual",
],
fulfillment_providers: [
"manual",
],
countries: [
"DK",
],
}),
})
.then((response) => response.json())
.then(({ region }) => {
console.log(region.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/regions' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"name": "Europe",
"currency_code": "eur",
"tax_rate": 0,
"payment_providers": [
"manual"
],
"fulfillment_providers": [
"manual"
],
"countries": [
"DK"
]
}'
```
</TabItem>
</Tabs>
This request requires the following body parameters:
@@ -271,84 +271,84 @@ You can update any of the region’s fields and configurations. The REST APIs of
Alternatively, you can update the details of a region using the [Update a Region API Route](https://docs.medusajs.com/api/admin#regions_postregionsregion):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.regions.update(regionId, {
countries: [
"DK",
"DE",
],
})
.then(({ region }) => {
console.log(region.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminUpdateRegion } from "medusa-react"
const UpdateRegion = () => {
const updateRegion = useAdminUpdateRegion(regionId)
// ...
const handleUpdate = () => {
updateRegion.mutate({
```ts
medusa.admin.regions.update(regionId, {
countries: [
"DK",
"DE",
],
})
}
.then(({ region }) => {
console.log(region.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default UpdateRegion
```
```tsx
import { useAdminUpdateRegion } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const UpdateRegion = () => {
const updateRegion = useAdminUpdateRegion(regionId)
// ...
```ts
fetch(`<BACKEND_URL>/admin/regions/${regionId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
countries: [
"DK",
"DE",
],
}),
})
.then((response) => response.json())
.then(({ region }) => {
console.log(region.id)
})
```
const handleUpdate = () => {
updateRegion.mutate({
countries: [
"DK",
"DE",
],
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/regions/<REGION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"countries": [
"DK",
"DE"
]
}'
```
export default UpdateRegion
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/regions/${regionId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
countries: [
"DK",
"DE",
],
}),
})
.then((response) => response.json())
.then(({ region }) => {
console.log(region.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/regions/<REGION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"countries": [
"DK",
"DE"
]
}'
```
</TabItem>
</Tabs>
This request accepts in its body parameters any of the region’s fields that you want to update. In the example above, you update the list of countries that are included in that region.
@@ -370,35 +370,10 @@ In the example above, the list of countries replace any countries that were prev
You can add a shipping option to a region by sending a request to the [Create Shipping Option API Route](https://docs.medusajs.com/api/admin#shipping-options_postshippingoptions):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.shippingOptions.create({
name: "PostFake",
region_id: regionId,
provider_id: "manual",
data: {
},
price_type: "flat_rate",
amount: 1000,
})
.then(({ shipping_option }) => {
console.log(shipping_option.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCreateShippingOption } from "medusa-react"
const Region = () => {
const createShippingOption = useAdminCreateShippingOption()
// ...
const handleCreate = () => {
createShippingOption.mutate({
```ts
medusa.admin.shippingOptions.create({
name: "PostFake",
region_id: regionId,
provider_id: "manual",
@@ -407,58 +382,83 @@ const Region = () => {
price_type: "flat_rate",
amount: 1000,
})
}
.then(({ shipping_option }) => {
console.log(shipping_option.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default Region
```
```tsx
import { useAdminCreateShippingOption } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const Region = () => {
const createShippingOption = useAdminCreateShippingOption()
// ...
```ts
fetch(`<BACKEND_URL>/admin/shipping-options`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "PostFake",
region_id: regionId,
provider_id: "manual",
price_type: "flat_rate",
data: {
},
amount: 1000,
}),
})
.then((response) => response.json())
.then(({ shipping_option }) => {
console.log(shipping_option.id)
})
```
const handleCreate = () => {
createShippingOption.mutate({
name: "PostFake",
region_id: regionId,
provider_id: "manual",
data: {
},
price_type: "flat_rate",
amount: 1000,
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/shipping-options' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"name": "PostFake",
"region_id": "<REGION_ID>",
"provider_id": "manual",
"price_type": "flat_rate",
"data": {},
"amount": 1000
}'
```
export default Region
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/shipping-options`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "PostFake",
region_id: regionId,
provider_id: "manual",
price_type: "flat_rate",
data: {
},
amount: 1000,
}),
})
.then((response) => response.json())
.then(({ shipping_option }) => {
console.log(shipping_option.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/shipping-options' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"name": "PostFake",
"region_id": "<REGION_ID>",
"provider_id": "manual",
"price_type": "flat_rate",
"data": {},
"amount": 1000
}'
```
</TabItem>
</Tabs>
This request requires the following body parameters:
@@ -489,58 +489,58 @@ You can also manage shipping options such as list, update, and delete. You can l
You can delete a region by sending a request to the [Delete a Region API Route](https://docs.medusajs.com/api/admin#regions_deleteregionsregion):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.regions.delete(regionId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
medusa.admin.regions.delete(regionId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminDeleteRegion } from "medusa-react"
```tsx
import { useAdminDeleteRegion } from "medusa-react"
const Region = () => {
const deleteRegion = useAdminDeleteRegion(regionId)
// ...
const Region = () => {
const deleteRegion = useAdminDeleteRegion(regionId)
// ...
const handleDelete = () => {
deleteRegion.mutate()
}
const handleDelete = () => {
deleteRegion.mutate()
}
// ...
}
// ...
}
export default Region
```
export default Region
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/regions/${regionId}`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
fetch(`<BACKEND_URL>/admin/regions/${regionId}`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/regions/<REGION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/regions/<REGION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This request requires the region ID as a path parameter. It deletes the region and returns the following fields:
@@ -55,60 +55,60 @@ Customers should be able to see the list of available regions and select their r
You can retrieve available regions by sending a request to the [List Regions API Route](https://docs.medusajs.com/api/store#regions_getregions):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.regions.list()
.then(({ regions }) => {
console.log(regions.length)
// show customers available regions
})
```
```ts
medusa.regions.list()
.then(({ regions }) => {
console.log(regions.length)
// show customers available regions
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { Region } from "@medusajs/medusa"
import { useRegions } from "medusa-react"
```tsx
import { Region } from "@medusajs/medusa"
import { useRegions } from "medusa-react"
const Regions = () => {
const { regions, isLoading } = useRegions()
const Regions = () => {
const { regions, isLoading } = useRegions()
return (
<div>
{isLoading && <span>Loading...</span>}
{regions?.length && (
<ul>
{regions.map((region: Region) => (
<li key={region.id}>
{region.name}
</li>
))}
</ul>
)}
</div>
)
}
return (
<div>
{isLoading && <span>Loading...</span>}
{regions?.length && (
<ul>
{regions.map((region: Region) => (
<li key={region.id}>
{region.name}
</li>
))}
</ul>
)}
</div>
)
}
export default Regions
```
export default Regions
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/regions`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ regions }) => {
console.log(regions.length)
// show customers available regions
})
```
```ts
fetch(`<BACKEND_URL>/store/regions`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ regions }) => {
console.log(regions.length)
// show customers available regions
})
```
</TabItem>
</TabItem>
</Tabs>
This request returns the list of available regions. You can show them to your customers to select their region.
@@ -124,56 +124,56 @@ To retrieve products with the prices based on the selected regions, you can pass
For example:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.products.list({
region_id: regionId,
})
.then(({ products, limit, offset, count }) => {
console.log(products.length)
// show customer the products
})
```
```ts
medusa.products.list({
region_id: regionId,
})
.then(({ products, limit, offset, count }) => {
console.log(products.length)
// show customer the products
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { formatVariantPrice } from "medusa-react"
```tsx
import { formatVariantPrice } from "medusa-react"
const Product = () => {
// retrieve the region and variant(s)
// ...
const Product = () => {
// retrieve the region and variant(s)
// ...
return (
<span>
{formatVariantPrice({
variant, // ProductVariant
region, // Region
})}
</span>
)
}
return (
<span>
{formatVariantPrice({
variant, // ProductVariant
region, // Region
})}
</span>
)
}
export default Product
```
export default Product
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/products?region_id=${regionId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ products, limit, offset, count }) => {
console.log(products.length)
// show customer the products
})
```
```ts
fetch(`<BACKEND_URL>/store/products?region_id=${regionId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ products, limit, offset, count }) => {
console.log(products.length)
// show customer the products
})
```
</TabItem>
</TabItem>
</Tabs>
In this example, you send a request to the List Products API Route, passing it the `region_id` query parameter. It is assumed that you have the ID of the region stored in the variable `regionId`.
@@ -197,58 +197,58 @@ You can learn how to implement cart functionalities in your storefront in [this
For example:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.carts.update(cartId, {
region_id: regionId,
})
.then(({ cart }) => {
console.log(cart.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCart } from "medusa-react"
const Cart = () => {
// ...
const { updateCart } = useCart()
const changeRegionId = (region_id: string) => {
updateCart.mutate({
region_id,
```ts
medusa.carts.update(cartId, {
region_id: regionId,
})
}
.then(({ cart }) => {
console.log(cart.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default Cart
```
```tsx
import { useCart } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const Cart = () => {
// ...
```ts
fetch(`<BACKEND_URL>/store/carts/${cartId}`, {
method: "POST",
credentials: "include",
body: JSON.stringify({
region_id: regionId,
}),
})
.then((response) => response.json())
.then(({ cart }) => {
console.log(cart.id)
})
```
const { updateCart } = useCart()
</TabItem>
const changeRegionId = (region_id: string) => {
updateCart.mutate({
region_id,
})
}
// ...
}
export default Cart
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/carts/${cartId}`, {
method: "POST",
credentials: "include",
body: JSON.stringify({
region_id: regionId,
}),
})
.then((response) => response.json())
.then(({ cart }) => {
console.log(cart.id)
})
```
</TabItem>
</Tabs>
In this example, you send a request to the [Update Cart API Route](https://docs.medusajs.com/api/store#carts_postcartscart). In the request’s body, you pass the parameter `region_id` and set its value to the selected region’s ID. It is assumed that you have the ID of the region stored in the variable `regionId`.
File diff suppressed because it is too large. Load diff
@@ -56,65 +56,65 @@ For requests that use the cart, it's also assumed you already have [used CartPro
To filter products by a specific sales channel, pass the `sales_channel_id` query parameter to the List Products API Route:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.products.list({
sales_channel_id: [
salesChannelId,
],
})
.then(({ products, limit, offset, count }) => {
console.log(products.length)
})
```
```ts
medusa.products.list({
sales_channel_id: [
salesChannelId,
],
})
.then(({ products, limit, offset, count }) => {
console.log(products.length)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { Product } from "@medusajs/medusa"
import { useProducts } from "medusa-react"
```tsx
import { Product } from "@medusajs/medusa"
import { useProducts } from "medusa-react"
const Products = () => {
const { products, isLoading } = useProducts({
sales_channel_id: [
salesChannelId,
],
})
const Products = () => {
const { products, isLoading } = useProducts({
sales_channel_id: [
salesChannelId,
],
})
return (
<div>
{isLoading && <span>Loading...</span>}
{products && products.length > 0 && (
<ul>
{products.map((product: Product) => (
<li key={product.id}>{product.title}</li>
))}
</ul>
)}
{products && !products.length && <span>No Products</span>}
</div>
)
}
return (
<div>
{isLoading && <span>Loading...</span>}
{products && products.length > 0 && (
<ul>
{products.map((product: Product) => (
<li key={product.id}>{product.title}</li>
))}
</ul>
)}
{products && !products.length && <span>No Products</span>}
</div>
)
}
export default Products
```
export default Products
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/store/products?sales_channel_id[0]=${salesChannelId}`)
.then((response) => response.json())
.then(({ products, limit, offset, count }) => {
console.log(products.length)
})
```
```ts
fetch(`<BACKEND_URL>/store/products?sales_channel_id[0]=${salesChannelId}`)
.then((response) => response.json())
.then(({ products, limit, offset, count }) => {
console.log(products.length)
})
```
</TabItem>
</TabItem>
</Tabs>
The `sales_channel_id` query parameter is an array of sales channel IDs. You can pass more than one sales channel.
@@ -130,66 +130,65 @@ The request returns an array of products. These are the products that are availa
To associate a sales channel with a cart while creating it, you can pass the `sales_channel_id` request body parameter with the ID of the sales channel:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.carts.create({
sales_channel_id: salesChannelId,
})
.then(({ cart }) => {
console.log(cart.id)
})
```
```ts
medusa.carts.create({
sales_channel_id: salesChannelId,
})
.then(({ cart }) => {
console.log(cart.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCart } from "medusa-react"
```tsx
import { useCart } from "medusa-react"
const Cart = () => {
const { cart, createCart } = useCart()
const Cart = () => {
const { cart, createCart } = useCart()
const handleCreateCart = () => {
createCart.mutate(
{
sales_channel_id: salesChannelId,
},
{
onSuccess: ({ cart }) => {
localStorage.setItem("cart_id", cart.id)
},
const handleCreateCart = () => {
createCart.mutate(
{
sales_channel_id: salesChannelId,
},
{
onSuccess: ({ cart }) => {
localStorage.setItem("cart_id", cart.id)
},
}
)
}
)
}
// ...
}
// ...
}
export default Cart
```
export default Cart
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/carts`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
sales_channel_id: salesChannelId,
}),
})
.then((response) => response.json())
.then(({ cart }) => {
console.log(cart.id)
})
```
```ts
fetch(`<BACKEND_URL>/store/carts`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
sales_channel_id: salesChannelId,
}),
})
.then((response) => response.json())
.then(({ cart }) => {
console.log(cart.id)
})
```
</TabItem>
</TabItem>
</Tabs>
The request returns the created cart.
@@ -199,58 +198,58 @@ The request returns the created cart.
You can update the sales channel of an existing cart by passing the `sales_channel_id` request body parameter with the ID of the sales channel:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.carts.update(cartId, {
sales_channel_id: salesChannelId,
})
.then(({ cart }) => {
console.log(cart.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useCart } from "medusa-react"
const Cart = () => {
// ...
const { updateCart } = useCart()
const changeSalesChannel = (salesChannelId: string) => {
updateCart.mutate({
```ts
medusa.carts.update(cartId, {
sales_channel_id: salesChannelId,
})
}
.then(({ cart }) => {
console.log(cart.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default Cart
```
```tsx
import { useCart } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const Cart = () => {
// ...
```ts
fetch(`<BACKEND_URL>/store/carts/${cartId}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
sales_channel_id: salesChannelId,
}),
})
.then((response) => response.json())
.then(({ cart }) => console.log(cart.id))
```
const { updateCart } = useCart()
</TabItem>
const changeSalesChannel = (salesChannelId: string) => {
updateCart.mutate({
sales_channel_id: salesChannelId,
})
}
// ...
}
export default Cart
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/store/carts/${cartId}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
sales_channel_id: salesChannelId,
}),
})
.then((response) => response.json())
.then(({ cart }) => console.log(cart.id))
```
</TabItem>
</Tabs>
The request returns the updated cart.
File diff suppressed because it is too large. Load diff
@@ -55,69 +55,69 @@ You can learn more about [authenticating as an admin user in the API reference](
You can list all tax providers of a store using the [List Tax Providers API Route](https://docs.medusajs.com/api/admin#store_getstoretaxproviders):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.store.listTaxProviders()
.then(({ tax_providers }) => {
console.log(tax_providers.length)
})
```
```ts
medusa.admin.store.listTaxProviders()
.then(({ tax_providers }) => {
console.log(tax_providers.length)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminStoreTaxProviders } from "medusa-react"
```tsx
import { useAdminStoreTaxProviders } from "medusa-react"
const TaxProviders = () => {
const {
tax_providers,
isLoading,
} = useAdminStoreTaxProviders()
const TaxProviders = () => {
const {
tax_providers,
isLoading,
} = useAdminStoreTaxProviders()
return (
<div>
{isLoading && <span>Loading...</span>}
{tax_providers && !tax_providers.length && (
<span>No Tax Providers</span>
)}
{tax_providers && tax_providers.length > 0 && (
<ul>
{tax_providers.map((tax_provider) => (
<li key={tax_provider.id}>{tax_provider.id}</li>
))}
</ul>
)}
</div>
)
}
return (
<div>
{isLoading && <span>Loading...</span>}
{tax_providers && !tax_providers.length && (
<span>No Tax Providers</span>
)}
{tax_providers && tax_providers.length > 0 && (
<ul>
{tax_providers.map((tax_provider) => (
<li key={tax_provider.id}>{tax_provider.id}</li>
))}
</ul>
)}
</div>
)
}
export default TaxProviders
```
export default TaxProviders
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/store/tax-providers`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ tax_providers }) => {
console.log(tax_providers.length)
})
```
```ts
fetch(`<BACKEND_URL>/admin/store/tax-providers`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ tax_providers }) => {
console.log(tax_providers.length)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/store/tax-providers' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/store/tax-providers' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route doesn't accept any parameters.
@@ -131,72 +131,72 @@ The request returns an array of tax provider objects.
You can change the tax provider of a region using the [Update Region API Route](https://docs.medusajs.com/api/admin#regions_postregionsregion):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.regions.update(regionId, {
tax_provider_id,
})
.then(({ region }) => {
console.log(region.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminUpdateRegion } from "medusa-react"
const UpdateRegion = () => {
const updateRegion = useAdminUpdateRegion(regionId)
// ...
const handleUpdate = () => {
updateRegion.mutate({
```ts
medusa.admin.regions.update(regionId, {
tax_provider_id,
})
}
.then(({ region }) => {
console.log(region.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default UpdateRegion
```
```tsx
import { useAdminUpdateRegion } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const UpdateRegion = () => {
const updateRegion = useAdminUpdateRegion(regionId)
// ...
```ts
fetch(`<BACKEND_URL>/admin/regions/${regionId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
tax_provider_id,
}),
})
.then((response) => response.json())
.then(({ region }) => {
console.log(region.id)
})
```
const handleUpdate = () => {
updateRegion.mutate({
tax_provider_id,
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/regions/<REGION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"tax_provider_id": "<TAX_PROVIDER_ID>"
}'
```
export default UpdateRegion
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/regions/${regionId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
tax_provider_id,
}),
})
.then((response) => response.json())
.then(({ region }) => {
console.log(region.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/regions/<REGION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"tax_provider_id": "<TAX_PROVIDER_ID>"
}'
```
</TabItem>
</Tabs>
This API Route requires the ID of the region to be passed as a path parameter.
@@ -212,88 +212,88 @@ The request returns the updated region as an object.
In addition to changing the tax provider, you can use the same [Update Region API Route](https://docs.medusajs.com/api/admin#regions_postregionsregion) to update the region’s other tax settings:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.regions.update(regionId, {
tax_provider_id,
automatic_taxes,
gift_cards_taxable,
tax_code,
tax_rate,
})
.then(({ region }) => {
console.log(region.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminUpdateRegion } from "medusa-react"
const UpdateRegion = () => {
const updateRegion = useAdminUpdateRegion(regionId)
// ...
const handleUpdate = () => {
updateRegion.mutate({
```ts
medusa.admin.regions.update(regionId, {
tax_provider_id,
automatic_taxes,
gift_cards_taxable,
tax_code,
tax_rate,
})
}
.then(({ region }) => {
console.log(region.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default UpdateRegion
```
```tsx
import { useAdminUpdateRegion } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const UpdateRegion = () => {
const updateRegion = useAdminUpdateRegion(regionId)
// ...
```ts
fetch(`<BACKEND_URL>/admin/regions/${regionId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
tax_provider_id,
automatic_taxes,
gift_cards_taxable,
tax_code,
tax_rate,
}),
})
.then((response) => response.json())
.then(({ region }) => {
console.log(region.id)
})
```
const handleUpdate = () => {
updateRegion.mutate({
tax_provider_id,
automatic_taxes,
gift_cards_taxable,
tax_code,
tax_rate,
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/regions/<REGION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"tax_provider_id": "<TAX_PROVIDER_ID>",
"automatic_taxes": true,
"gift_cards_taxable": true,
"tax_code": "<TAX_CODE>",
"tax_rate": 10
}'
```
export default UpdateRegion
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/regions/${regionId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
tax_provider_id,
automatic_taxes,
gift_cards_taxable,
tax_code,
tax_rate,
}),
})
.then((response) => response.json())
.then(({ region }) => {
console.log(region.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/regions/<REGION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"tax_provider_id": "<TAX_PROVIDER_ID>",
"automatic_taxes": true,
"gift_cards_taxable": true,
"tax_code": "<TAX_CODE>",
"tax_rate": 10
}'
```
</TabItem>
</Tabs>
You can pass the following parameters in the body of the request that are related to tax settings:
@@ -57,64 +57,64 @@ You can learn more about [authenticating as an admin user in the API reference](
You can list invites by sending a request to the [List Invite API Route](https://docs.medusajs.com/api/admin#invites_getinvites):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.invites.list()
.then(({ invites }) => {
console.log(invites.length)
})
```
```ts
medusa.admin.invites.list()
.then(({ invites }) => {
console.log(invites.length)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminInvites } from "medusa-react"
```tsx
import { useAdminInvites } from "medusa-react"
const Invites = () => {
const { invites, isLoading } = useAdminInvites()
const Invites = () => {
const { invites, isLoading } = useAdminInvites()
return (
<div>
{isLoading && <span>Loading...</span>}
{invites && !invites.length && <span>No Invites</span>}
{invites && invites.length > 0 && (
<ul>
{invites.map((invite) => (
<li key={invite.id}>{invite.user_email}</li>
))}
</ul>
)}
</div>
)
}
return (
<div>
{isLoading && <span>Loading...</span>}
{invites && !invites.length && <span>No Invites</span>}
{invites && invites.length > 0 && (
<ul>
{invites.map((invite) => (
<li key={invite.id}>{invite.user_email}</li>
))}
</ul>
)}
</div>
)
}
export default Invites
```
export default Invites
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/invites`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ invites }) => {
console.log(invites.length)
})
```
```ts
fetch(`<BACKEND_URL>/admin/invites`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ invites }) => {
console.log(invites.length)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/invites' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/invites' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route doesn't accept any parameters.
@@ -128,76 +128,76 @@ The request returns an array of invite objects.
You can create an invite by sending a request to the [Create Invite API Route](https://docs.medusajs.com/api/admin#invites_postinvites):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.invites.create({
user: "user@example.com",
role: "admin",
})
.then(() => {
// successful
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCreateInvite } from "medusa-react"
const CreateInvite = () => {
const createInvite = useAdminCreateInvite()
// ...
const handleCreate = () => {
createInvite.mutate({
```ts
medusa.admin.invites.create({
user: "user@example.com",
role: "admin",
})
}
.then(() => {
// successful
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default CreateInvite
```
```tsx
import { useAdminCreateInvite } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const CreateInvite = () => {
const createInvite = useAdminCreateInvite()
// ...
```ts
fetch(`<BACKEND_URL>/admin/invites`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
user: "user@example.com",
role: "admin",
}),
})
.then((response) => response.json())
.then(() => {
// successful
})
```
const handleCreate = () => {
createInvite.mutate({
user: "user@example.com",
role: "admin",
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/invites' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"user": "user@example.com",
"role": "admin"
}'
```
export default CreateInvite
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/invites`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
user: "user@example.com",
role: "admin",
}),
})
.then((response) => response.json())
.then(() => {
// successful
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/invites' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"user": "user@example.com",
"role": "admin"
}'
```
</TabItem>
</Tabs>
This API Route requires the following body parameters:
@@ -216,34 +216,10 @@ A logged-out user can accept an invite, which would create a user for that user.
You can accept an invite by sending a request to the [Accept Invite API Route](https://docs.medusajs.com/api/admin#invites_postinvitesinviteaccept):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.invites.accept({
token,
user: {
first_name: "Brigitte",
last_name: "Collier",
password: "supersecret",
},
})
.then(() => {
// successful
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminAcceptInvite } from "medusa-react"
const AcceptInvite = () => {
const acceptInvite = useAdminAcceptInvite()
// ...
const handleAccept = () => {
acceptInvite.mutate({
```ts
medusa.admin.invites.accept({
token,
user: {
first_name: "Brigitte",
@@ -251,56 +227,80 @@ const AcceptInvite = () => {
password: "supersecret",
},
})
}
.then(() => {
// successful
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default AcceptInvite
```
```tsx
import { useAdminAcceptInvite } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const AcceptInvite = () => {
const acceptInvite = useAdminAcceptInvite()
// ...
```ts
fetch(`<BACKEND_URL>/admin/invites/accept`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
token,
user: {
first_name: "Brigitte",
last_name: "Collier",
password: "supersecret",
},
}),
})
.then((response) => response.json())
.then(() => {
// successful
})
```
const handleAccept = () => {
acceptInvite.mutate({
token,
user: {
first_name: "Brigitte",
last_name: "Collier",
password: "supersecret",
},
})
}
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/invites/accept' \
-H 'Content-Type: application/json' \
--data-raw '{
"token": "<TOKEN>",
"user": {
"first_name": "Brigitte",
"last_name": "Collier",
"password": "supersecret"
// ...
}
}'
```
</TabItem>
export default AcceptInvite
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/invites/accept`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
token,
user: {
first_name: "Brigitte",
last_name: "Collier",
password: "supersecret",
},
}),
})
.then((response) => response.json())
.then(() => {
// successful
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/invites/accept' \
-H 'Content-Type: application/json' \
--data-raw '{
"token": "<TOKEN>",
"user": {
"first_name": "Brigitte",
"last_name": "Collier",
"password": "supersecret"
}
}'
```
</TabItem>
</Tabs>
This API Route requires the following request body parameters:
@@ -320,58 +320,58 @@ The request does not return any data. If the invite was accepted successfully, t
You can resend an invite if it’s not accepted yet. To resend an invite, send a request to the [Resend Invite API Route](https://docs.medusajs.com/api/admin#invites_postinvitesinviteresend):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.invites.resend(inviteId)
.then(() => {
// successful
})
```
```ts
medusa.admin.invites.resend(inviteId)
.then(() => {
// successful
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminResendInvite } from "medusa-react"
```tsx
import { useAdminResendInvite } from "medusa-react"
const ResendInvite = () => {
const resendInvite = useAdminResendInvite(inviteId)
// ...
const ResendInvite = () => {
const resendInvite = useAdminResendInvite(inviteId)
// ...
const handleResend = () => {
resendInvite.mutate()
}
const handleResend = () => {
resendInvite.mutate()
}
// ...
}
// ...
}
export default ResendInvite
```
export default ResendInvite
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/invites/${inviteId}/resend`, {
credentials: "include",
method: "POST",
})
.then((response) => response.json())
.then(() => {
// successful
})
```
```ts
fetch(`<BACKEND_URL>/admin/invites/${inviteId}/resend`, {
credentials: "include",
method: "POST",
})
.then((response) => response.json())
.then(() => {
// successful
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/invites/<INVITE_ID>/resend' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/invites/<INVITE_ID>/resend' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the invite ID as a path parameter.
@@ -385,58 +385,58 @@ The request doesn't return any data. If the invite was resent successfully, the
You can delete an invite by sending a request to the [Delete Invite API Route](https://docs.medusajs.com/api/admin#invites_deleteinvitesinvite):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.invites.delete(inviteId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
medusa.admin.invites.delete(inviteId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminDeleteInvite } from "medusa-react"
```tsx
import { useAdminDeleteInvite } from "medusa-react"
const DeleteInvite = () => {
const deleteInvite = useAdminDeleteInvite(inviteId)
// ...
const DeleteInvite = () => {
const deleteInvite = useAdminDeleteInvite(inviteId)
// ...
const handleDelete = () => {
deleteInvite.mutate()
}
const handleDelete = () => {
deleteInvite.mutate()
}
// ...
}
// ...
}
export default DeleteInvite
```
export default DeleteInvite
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/invites/${inviteId}`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
fetch(`<BACKEND_URL>/admin/invites/${inviteId}`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/invites/<INVITE_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/invites/<INVITE_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the invite ID as a path parameter.
@@ -55,75 +55,75 @@ You can learn more about [authenticating as an admin user in the API reference](
You can log in a user by sending a request to the [User Login API Route](https://docs.medusajs.com/api/admin#auth_postauth):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.auth.createSession({
email: "user@example.com",
password: "supersecret",
})
.then(({ user }) => {
console.log(user.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminLogin } from "medusa-react"
const Login = () => {
const adminLogin = useAdminLogin()
// ...
const handleLogin = () => {
adminLogin.mutate({
```ts
medusa.admin.auth.createSession({
email: "user@example.com",
password: "supersecret",
})
}
.then(({ user }) => {
console.log(user.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default Login
```
```tsx
import { useAdminLogin } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const Login = () => {
const adminLogin = useAdminLogin()
// ...
```ts
fetch(`<BACKEND_URL>/admin/auth`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: "user@example.com",
password: "supersecret",
}),
})
.then((response) => response.json())
.then(({ user }) => {
console.log(user.id)
})
```
const handleLogin = () => {
adminLogin.mutate({
email: "user@example.com",
password: "supersecret",
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/auth' \
-H 'Content-Type: application/json' \
--data-raw '{
"email": "user@example.com",
"password": "supersecret"
}'
```
export default Login
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/auth`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: "user@example.com",
password: "supersecret",
}),
})
.then((response) => response.json())
.then(({ user }) => {
console.log(user.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/auth' \
-H 'Content-Type: application/json' \
--data-raw '{
"email": "user@example.com",
"password": "supersecret"
}'
```
</TabItem>
</Tabs>
This API Route requires the following request body parameters:
@@ -138,58 +138,58 @@ The request returns the logged-in user as an object.
You can log out a user by sending a request to the [User Logout API Route](https://docs.medusajs.com/api/admin#auth_deleteauth):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.auth.deleteSession()
.then(() => {
// logged out successfully
})
```
```ts
medusa.admin.auth.deleteSession()
.then(() => {
// logged out successfully
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminDeleteSession } from "medusa-react"
```tsx
import { useAdminDeleteSession } from "medusa-react"
const Logout = () => {
const adminLogout = useAdminDeleteSession()
// ...
const Logout = () => {
const adminLogout = useAdminDeleteSession()
// ...
const handleLogout = () => {
adminLogout.mutate()
}
const handleLogout = () => {
adminLogout.mutate()
}
// ...
}
// ...
}
export default Logout
```
export default Logout
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/auth`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(() => {
// logged out successfully
})
```
```ts
fetch(`<BACKEND_URL>/admin/auth`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(() => {
// logged out successfully
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/auth' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/auth' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
The API Route doesn't require any path or query parameters.
@@ -203,57 +203,57 @@ The request doesn't return any data. The response code will be `200` for success
You can retrieve the current user’s details for their profile by sending a request to the [Get Current User API Route](https://docs.medusajs.com/api/admin#auth_getauth):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.auth.getSession()
.then(({ user }) => {
console.log(user.id)
})
```
```ts
medusa.admin.auth.getSession()
.then(({ user }) => {
console.log(user.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminGetSession } from "medusa-react"
```tsx
import { useAdminGetSession } from "medusa-react"
const Profile = () => {
const { user, isLoading } = useAdminGetSession()
const Profile = () => {
const { user, isLoading } = useAdminGetSession()
return (
<div>
{isLoading && <span>Loading...</span>}
{user && <span>{user.email}</span>}
</div>
)
}
return (
<div>
{isLoading && <span>Loading...</span>}
{user && <span>{user.email}</span>}
</div>
)
}
export default Profile
```
export default Profile
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/auth`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ user }) => {
console.log(user.id)
})
```
```ts
fetch(`<BACKEND_URL>/admin/auth`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ user }) => {
console.log(user.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/auth' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/auth' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route doesn't require any parameters.
@@ -267,75 +267,75 @@ The request returns the current user as an object.
You can update a user’s details in their profile by sending a request to the [Update User API Route](https://docs.medusajs.com/api/admin#users_postusersuser):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.users.update(userId, {
first_name: "Marcellus",
})
.then(({ user }) => {
console.log(user.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import {
useAdminDeleteSession,
useAdminUpdateUser,
} from "medusa-react"
const Profile = () => {
const updateUser = useAdminUpdateUser(userId)
// ...
const handleUpdate = () => {
updateUser.mutate({
```ts
medusa.admin.users.update(userId, {
first_name: "Marcellus",
})
}
.then(({ user }) => {
console.log(user.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default Profile
```
```tsx
import {
useAdminDeleteSession,
useAdminUpdateUser,
} from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const Profile = () => {
const updateUser = useAdminUpdateUser(userId)
// ...
```ts
fetch(`<BACKEND_URL>/admin/users/${userId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
first_name: "Marcellus",
}),
})
.then((response) => response.json())
.then(({ user }) => {
console.log(user.id)
})
```
const handleUpdate = () => {
updateUser.mutate({
first_name: "Marcellus",
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/users/<USER_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"first_name": "Marcellus"
}'
```
export default Profile
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/users/${userId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
first_name: "Marcellus",
}),
})
.then((response) => response.json())
.then(({ user }) => {
console.log(user.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/users/<USER_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"first_name": "Marcellus"
}'
```
</TabItem>
</Tabs>
This API Route requires the ID of the user as a path parameter.
@@ -363,71 +363,71 @@ Sending the password reset email is not handled by default in the Medusa backend
You can request a password reset by sending a request to the [Request Password Reset API Route](https://docs.medusajs.com/api/admin#users_postusersuserpasswordtoken):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.users.sendResetPasswordToken({
email: "user@example.com",
})
.then(() => {
// successful
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminSendResetPasswordToken } from "medusa-react"
const Login = () => {
const requestPasswordReset = useAdminSendResetPasswordToken()
// ...
const handleResetPassword = () => {
requestPasswordReset.mutate({
```ts
medusa.admin.users.sendResetPasswordToken({
email: "user@example.com",
})
}
.then(() => {
// successful
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default Login
```
```tsx
import { useAdminSendResetPasswordToken } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const Login = () => {
const requestPasswordReset = useAdminSendResetPasswordToken()
// ...
```ts
fetch(`<BACKEND_URL>/admin/users/password-token`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: "user@example.com",
}),
})
.then((response) => response.json())
.then(() => {
// successful
})
```
const handleResetPassword = () => {
requestPasswordReset.mutate({
email: "user@example.com",
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/users/password-token' \
-H 'Content-Type: application/json' \
--data-raw '{
"email": "user@example.com"
}'
```
export default Login
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/users/password-token`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: "user@example.com",
}),
})
.then((response) => response.json())
.then(() => {
// successful
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/users/password-token' \
-H 'Content-Type: application/json' \
--data-raw '{
"email": "user@example.com"
}'
```
</TabItem>
</Tabs>
This API Route requires the `email` parameter in the request body, which is the email of the user requesting to reset their password.
@@ -441,75 +441,75 @@ After the user resets their password and, typically, receives an email with a li
You can reset the password by sending a request to the [Reset Password API Route](https://docs.medusajs.com/api/admin#users_postusersuserpassword):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.users.resetPassword({
token: "supersecrettoken",
password: "supersecret",
})
.then(({ user }) => {
console.log(user.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminResetPassword } from "medusa-react"
const ResetPassword = () => {
const resetPassword = useAdminResetPassword()
// ...
const handleResetPassword = () => {
resetPassword.mutate({
```ts
medusa.admin.users.resetPassword({
token: "supersecrettoken",
password: "supersecret",
})
}
.then(({ user }) => {
console.log(user.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default ResetPassword
```
```tsx
import { useAdminResetPassword } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const ResetPassword = () => {
const resetPassword = useAdminResetPassword()
// ...
```ts
fetch(`<BACKEND_URL>/admin/users/reset-password`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
token: "supersecrettoken",
password: "supersecret",
}),
})
.then((response) => response.json())
.then(({ user }) => {
console.log(user.id)
})
```
const handleResetPassword = () => {
resetPassword.mutate({
token: "supersecrettoken",
password: "supersecret",
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/users/reset-password' \
-H 'Content-Type: application/json' \
--data-raw '{
"token": "supersecrettoken",
"password": "supersecret"
}'
```
export default ResetPassword
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/users/reset-password`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
token: "supersecrettoken",
password: "supersecret",
}),
})
.then((response) => response.json())
.then(({ user }) => {
console.log(user.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/users/reset-password' \
-H 'Content-Type: application/json' \
--data-raw '{
"token": "supersecrettoken",
"password": "supersecret"
}'
```
</TabItem>
</Tabs>
This API Route requires the following request body parameters:
@@ -56,64 +56,64 @@ You can learn more about [authenticating as an admin user in the API reference](
You can retrieve users in a store by sending a request to the [List Users API Route](https://docs.medusajs.com/api/admin#users_getusers):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.users.list()
.then(({ users }) => {
console.log(users.length)
})
```
```ts
medusa.admin.users.list()
.then(({ users }) => {
console.log(users.length)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminUsers } from "medusa-react"
```tsx
import { useAdminUsers } from "medusa-react"
const Users = () => {
const { users, isLoading } = useAdminUsers()
const Users = () => {
const { users, isLoading } = useAdminUsers()
return (
<div>
{isLoading && <span>Loading...</span>}
{users && !users.length && <span>No Users</span>}
{users && users.length > 0 && (
<ul>
{users.map((user) => (
<li key={user.id}>{user.email}</li>
))}
</ul>
)}
</div>
)
}
return (
<div>
{isLoading && <span>Loading...</span>}
{users && !users.length && <span>No Users</span>}
{users && users.length > 0 && (
<ul>
{users.map((user) => (
<li key={user.id}>{user.email}</li>
))}
</ul>
)}
</div>
)
}
export default Users
```
export default Users
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/users`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ users }) => {
console.log(users.length)
})
```
```ts
fetch(`<BACKEND_URL>/admin/users`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ users }) => {
console.log(users.length)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/users' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/users' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route doesn't require any parameters.
@@ -127,76 +127,76 @@ The request returns an array of user objects.
You can create a user by sending a request to the [Create User API Route](https://docs.medusajs.com/api/admin#users_postusers):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.users.create({
email: "user@example.com",
password: "supersecret",
})
.then(({ user }) => {
console.log(user.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCreateUser } from "medusa-react"
const CreateUser = () => {
const createUser = useAdminCreateUser()
// ...
const handleCreateUser = () => {
createUser.mutate({
```ts
medusa.admin.users.create({
email: "user@example.com",
password: "supersecret",
})
}
.then(({ user }) => {
console.log(user.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default CreateUser
```
```tsx
import { useAdminCreateUser } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const CreateUser = () => {
const createUser = useAdminCreateUser()
// ...
```ts
fetch(`<BACKEND_URL>/admin/users`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: "user@example.com",
password: "supersecret",
}),
})
.then((response) => response.json())
.then(({ user }) => {
console.log(user.id)
})
```
const handleCreateUser = () => {
createUser.mutate({
email: "user@example.com",
password: "supersecret",
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/users' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"email": "user@example.com",
"password": "supersecret"
}'
```
export default CreateUser
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/users`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: "user@example.com",
password: "supersecret",
}),
})
.then((response) => response.json())
.then(({ user }) => {
console.log(user.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/users' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"email": "user@example.com",
"password": "supersecret"
}'
```
</TabItem>
</Tabs>
This API Route requires the following request body parameters:
@@ -215,72 +215,72 @@ The request returns the created user as an object.
You can update a user’s details by sending a request to the [Update User API Route](https://docs.medusajs.com/api/admin#users_postusersuser):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.users.update(userId, {
first_name: "Marcellus",
})
.then(({ user }) => {
console.log(user.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminUpdateUser } from "medusa-react"
const UpdateUser = () => {
const updateUser = useAdminUpdateUser(userId)
// ...
const handleUpdateUser = () => {
updateUser.mutate({
```ts
medusa.admin.users.update(userId, {
first_name: "Marcellus",
})
}
.then(({ user }) => {
console.log(user.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default UpdateUser
```
```tsx
import { useAdminUpdateUser } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const UpdateUser = () => {
const updateUser = useAdminUpdateUser(userId)
// ...
```ts
fetch(`<BACKEND_URL>/admin/users/${userId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
first_name: "Marcellus",
}),
})
.then((response) => response.json())
.then(({ user }) => {
console.log(user.id)
})
```
const handleUpdateUser = () => {
updateUser.mutate({
first_name: "Marcellus",
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/users/<USER_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"first_name": "Marcellus"
}'
```
export default UpdateUser
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/users/${userId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
first_name: "Marcellus",
}),
})
.then((response) => response.json())
.then(({ user }) => {
console.log(user.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/users/<USER_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"first_name": "Marcellus"
}'
```
</TabItem>
</Tabs>
This API Route requires the ID of the user as a path parameter.
@@ -296,58 +296,58 @@ The request returns the updated user as an object.
You can delete a user by sending a request to the [Delete User API Route](https://docs.medusajs.com/api/admin#users_deleteusersuser):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.users.delete(userId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
medusa.admin.users.delete(userId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminDeleteUser } from "medusa-react"
```tsx
import { useAdminDeleteUser } from "medusa-react"
const DeleteUser = () => {
const deleteUser = useAdminDeleteUser(userId)
// ...
const DeleteUser = () => {
const deleteUser = useAdminDeleteUser(userId)
// ...
const handleDeleteUser = () => {
deleteUser.mutate()
}
const handleDeleteUser = () => {
deleteUser.mutate()
}
// ...
}
// ...
}
export default DeleteUser
```
export default DeleteUser
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/users/${userId}`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
fetch(`<BACKEND_URL>/admin/users/${userId}`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/users/<USER_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/users/<USER_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the user ID as a path parameter.
File diff suppressed because it is too large. Load diff
@@ -95,69 +95,59 @@ const plugins = [
The rest of this section includes the field names you can customize using this option for each content model type.
<details>
<summary>
product
</summary>
<Details>
<Summary>product</Summary>
- `title`
- `subtitle`
- `description`
- `variants`
- `options`
- `medusaId`
- `type`
- `collection`
- `tags`
- `handle`
- `title`
- `subtitle`
- `description`
- `variants`
- `options`
- `medusaId`
- `type`
- `collection`
- `tags`
- `handle`
</details>
</Details>
<details>
<summary>
variant
</summary>
<Details>
<Summary>variant</Summary>
- `title`
- `sku`
- `prices`
- `options`
- `medusaId`
- `title`
- `sku`
- `prices`
- `options`
- `medusaId`
</details>
</Details>
<details>
<summary>
region
</summary>
<Details>
<Summary>region</Summary>
- `name`
- `countries`
- `paymentProviders`
- `fulfillmentProviders`
- `medusaId`
- `name`
- `countries`
- `paymentProviders`
- `fulfillmentProviders`
- `medusaId`
</details>
</Details>
<details>
<summary>
collection
</summary>
<Details>
<Summary>collection</Summary>
- `title`
- `medusaId`
- `title`
- `medusaId`
</details>
</Details>
<details>
<summary>
type
</summary>
<Details>
<Summary>type</Summary>
- `name`
- `medusaId`
- `name`
- `medusaId`
</details>
</Details>
### Migrate Content Models
@@ -173,252 +163,244 @@ Before creating the migration scripts, run the following command in the root of
npm install --save-dev contentful-migration
```
<details>
<summary>
product Content Model
</summary>
<Details>
<Summary>product Content Model</Summary>
Create the file `src/loaders/contentful-migrations/product.ts` with the following content:
Create the file `src/loaders/contentful-migrations/product.ts` with the following content:
```ts title=src/loaders/contentful-migrations/product.ts
import Migration, {
MigrationContext,
} from "contentful-migration"
```ts title=src/loaders/contentful-migrations/product.ts
import Migration, {
MigrationContext,
} from "contentful-migration"
export function productMigration(
migration: Migration,
context?: MigrationContext
) {
const product = migration
.createContentType("product")
.name("Product")
.displayField("title")
export function productMigration(
migration: Migration,
context?: MigrationContext
) {
const product = migration
.createContentType("product")
.name("Product")
.displayField("title")
product
.createField("title")
.name("Title")
.type("Symbol")
.required(true)
product
.createField("subtitle")
.name("Subtitle")
.type("Symbol")
product
.createField("handle")
.name("Handle")
.type("Symbol")
product
.createField("thumbnail")
.name("Thumbnail")
.type("Link")
.linkType("Asset")
product
.createField("description")
.name("Description")
.type("Text")
product
.createField("options")
.name("Options")
.type("Object")
product
.createField("tags")
.name("Tags")
.type("Object")
product
.createField("collection")
.name("Collection")
.type("Symbol")
product
.createField("type")
.name("Type")
.type("Symbol")
product
.createField("variants")
.name("Variants")
.type("Array")
.items({
type: "Link",
linkType: "Entry",
validations: [
{
linkContentType: ["productVariant"],
},
],
})
product
.createField("medusaId")
.name("Medusa ID")
.type("Symbol")
}
```
</details>
<details>
<summary>
productVariant Content Model
</summary>
Create the file `src/loaders/contentful-migrations/product-variant.ts` with the following content:
```ts title=src/loaders/contentful-migrations/product-variant.ts
import Migration, {
MigrationContext,
} from "contentful-migration"
export function productVariantMigration(
migration: Migration,
context?: MigrationContext
) {
const productVariant = migration
.createContentType("productVariant")
.name("Product Variant")
.displayField("title")
productVariant
.createField("title")
.name("Title")
.type("Symbol")
.required(true)
productVariant
.createField("sku")
.name("SKU")
.type("Symbol")
productVariant
.createField("options")
.name("Options")
.type("Object")
productVariant
.createField("prices")
.name("Prices")
.type("Object")
productVariant
.createField("medusaId")
.name("Medusa ID")
.type("Symbol")
}
```
</details>
<details>
<summary>
collection Content Model
</summary>
Create the file `src/loaders/contentful-migrations/product-collection.ts` with the following content:
```ts title=src/loaders/contentful-migrations/product-collection.ts
import Migration, {
MigrationContext,
} from "contentful-migration"
export function productCollectionMigration(
migration: Migration,
context?: MigrationContext
) {
const collection = migration
.createContentType("collection")
.name("Product Collection")
.displayField("title")
collection
product
.createField("title")
.name("Title")
.type("Symbol")
.required(true)
collection
product
.createField("subtitle")
.name("Subtitle")
.type("Symbol")
product
.createField("handle")
.name("Handle")
.type("Symbol")
product
.createField("thumbnail")
.name("Thumbnail")
.type("Link")
.linkType("Asset")
product
.createField("description")
.name("Description")
.type("Text")
product
.createField("options")
.name("Options")
.type("Object")
product
.createField("tags")
.name("Tags")
.type("Object")
product
.createField("collection")
.name("Collection")
.type("Symbol")
product
.createField("type")
.name("Type")
.type("Symbol")
product
.createField("variants")
.name("Variants")
.type("Array")
.items({
type: "Link",
linkType: "Entry",
validations: [
{
linkContentType: ["productVariant"],
},
],
})
product
.createField("medusaId")
.name("Medusa ID")
.type("Symbol")
}
```
</details>
}
```
<details>
<summary>
productType Content Model
</summary>
</Details>
Create the file `src/loaders/contentful-migrations/product-type.ts` with the following content:
<Details>
<Summary>productVariant Content Model</Summary>
```ts title=src/loaders/contentful-migrations/product-type.ts
import Migration, {
MigrationContext,
} from "contentful-migration"
Create the file `src/loaders/contentful-migrations/product-variant.ts` with the following content:
export function productTypeMigration(
migration: Migration,
context?: MigrationContext
) {
const collection = migration
.createContentType("productType")
.name("Product Type")
.displayField("title")
```ts title=src/loaders/contentful-migrations/product-variant.ts
import Migration, {
MigrationContext,
} from "contentful-migration"
collection
export function productVariantMigration(
migration: Migration,
context?: MigrationContext
) {
const productVariant = migration
.createContentType("productVariant")
.name("Product Variant")
.displayField("title")
productVariant
.createField("title")
.name("Title")
.type("Symbol")
.required(true)
collection
productVariant
.createField("sku")
.name("SKU")
.type("Symbol")
productVariant
.createField("options")
.name("Options")
.type("Object")
productVariant
.createField("prices")
.name("Prices")
.type("Object")
productVariant
.createField("medusaId")
.name("Medusa ID")
.type("Symbol")
}
```
</details>
}
```
</Details>
<Details>
<Summary>collection Content Model</Summary>
Create the file `src/loaders/contentful-migrations/product-collection.ts` with the following content:
```ts title=src/loaders/contentful-migrations/product-collection.ts
import Migration, {
MigrationContext,
} from "contentful-migration"
export function productCollectionMigration(
migration: Migration,
context?: MigrationContext
) {
const collection = migration
.createContentType("collection")
.name("Product Collection")
.displayField("title")
collection
.createField("title")
.name("Title")
.type("Symbol")
.required(true)
collection
.createField("medusaId")
.name("Medusa ID")
.type("Symbol")
}
```
</Details>
<Details>
<Summary>productType Content Model</Summary>
Create the file `src/loaders/contentful-migrations/product-type.ts` with the following content:
```ts title=src/loaders/contentful-migrations/product-type.ts
import Migration, {
MigrationContext,
} from "contentful-migration"
export function productTypeMigration(
migration: Migration,
context?: MigrationContext
) {
const collection = migration
.createContentType("productType")
.name("Product Type")
.displayField("title")
collection
.createField("title")
.name("Title")
.type("Symbol")
.required(true)
collection
.createField("medusaId")
.name("Medusa ID")
.type("Symbol")
}
```
</Details>
<details>
<summary>
region Content Model
</summary>
<Details>
<Summary>region Content Model</Summary>
Create the file `src/loaders/contentful-migrations/region.ts` with the following content:
Create the file `src/loaders/contentful-migrations/region.ts` with the following content:
```ts title=src/loaders/contentful-migrations/region.ts
import Migration, {
MigrationContext,
} from "contentful-migration"
```ts title=src/loaders/contentful-migrations/region.ts
import Migration, {
MigrationContext,
} from "contentful-migration"
export function regionMigration(
migration: Migration,
context?: MigrationContext
) {
const region = migration
.createContentType("region")
.name("Region")
.displayField("name")
export function regionMigration(
migration: Migration,
context?: MigrationContext
) {
const region = migration
.createContentType("region")
.name("Region")
.displayField("name")
region
.createField("name")
.name("Name")
.type("Symbol")
.required(true)
region
.createField("countries")
.name("Options")
.type("Object")
region
.createField("paymentProviders")
.name("Payment Providers")
.type("Object")
region
.createField("fulfillmentProviders")
.name("Fulfillment Providers")
.type("Object")
region
.createField("currencyCode")
.name("Currency Code")
.type("Symbol")
region
.createField("medusaId")
.name("Medusa ID")
.type("Symbol")
}
```
region
.createField("name")
.name("Name")
.type("Symbol")
.required(true)
region
.createField("countries")
.name("Options")
.type("Object")
region
.createField("paymentProviders")
.name("Payment Providers")
.type("Object")
region
.createField("fulfillmentProviders")
.name("Fulfillment Providers")
.type("Object")
region
.createField("currencyCode")
.name("Currency Code")
.type("Symbol")
region
.createField("medusaId")
.name("Medusa ID")
.type("Symbol")
}
```
</details>
</Details>
Finally, create a [loader](../../development/loaders/overview.mdx) at `src/loaders/index.ts` with the following content:
@@ -71,7 +71,7 @@ Medusa supports localization so you can also create multiple templates for multi
## Template Reference
This section covers the template types supported by the plugin and what variables you can expect in your dynamic template. You can use the variables to add details like order total or customer name.
This section covers the template types supported by the plugin and what variables you can expect in your dynamic template. You can use the variables to add Details like order total or customer name.
:::note
@@ -85,9 +85,9 @@ You don’t have to create a template for every type in the reference. You can s
**Description:** Template to be sent to the customer when they place a new order.
<details>
<summary>Example Data</summary>
<Details>
<Summary>Example Data</Summary>
```json noReport
{
"beforeInsert": [Function],
@@ -304,7 +304,8 @@ You don’t have to create a template for every type in the reference. You can s
"updated_at": Any<Date>,
}
```
</details>
</Details>
### Order Canceled
@@ -312,8 +313,8 @@ You don’t have to create a template for every type in the reference. You can s
**Description:** Template to be sent to a customer when their order is canceled.
<details>
<summary>Example Data</summary>
<Details>
<Summary>Example Data</Summary>
```json noReport
{
@@ -535,7 +536,8 @@ You don’t have to create a template for every type in the reference. You can s
"updated_at": Any<Date>,
}
```
</details>
</Details>
### Order Shipment Created
@@ -543,8 +545,8 @@ You don’t have to create a template for every type in the reference. You can s
**Description:** Template to be sent to the customer when a shipment of their order has been created.
<details>
<summary>Example Data</summary>
<Details>
<Summary>Example Data</Summary>
```json noReport
{
@@ -817,7 +819,8 @@ You don’t have to create a template for every type in the reference. You can s
"tracking_number": "",
}
```
</details>
</Details>
### Order Return Requested
@@ -825,8 +828,8 @@ You don’t have to create a template for every type in the reference. You can s
**Description:** Template to be sent to the customer when a return request is made for an order.
<details>
<summary>Example Data</summary>
<Details>
<Summary>Example Data</Summary>
```json noReport
{
@@ -1259,7 +1262,8 @@ You don’t have to create a template for every type in the reference. You can s
"subtotal": "12.00 USD",
}
```
</details>
</Details>
### Order Items Returned
@@ -1267,8 +1271,8 @@ You don’t have to create a template for every type in the reference. You can s
**Description:** Template to be sent to the customer when an order’s items have been returned.
<details>
<summary>Example Data</summary>
<Details>
<Summary>Example Data</Summary>
```json noReport
{
@@ -1701,7 +1705,8 @@ You don’t have to create a template for every type in the reference. You can s
"subtotal": "12.00 USD",
}
```
</details>
</Details>
### Claim Shipment Created
@@ -1709,8 +1714,8 @@ You don’t have to create a template for every type in the reference. You can s
**Description:** Template to be sent to the customer when a Claim shipment has been created.
<details>
<summary>Example Data</summary>
<Details>
<Summary>Example Data</Summary>
```json noReport
{
@@ -1998,7 +2003,8 @@ You don’t have to create a template for every type in the reference. You can s
"tracking_number": "",
}
```
</details>
</Details>
### Swap Created
@@ -2006,8 +2012,8 @@ You don’t have to create a template for every type in the reference. You can s
**Description:** Template to be sent to the customer when a swap for an order has been created.
<details>
<summary>Example Data</summary>
<Details>
<Summary>Example Data</Summary>
```json noReport
{
@@ -2507,7 +2513,8 @@ You don’t have to create a template for every type in the reference. You can s
"additional_total": "11.25 USD"
}
```
</details>
</Details>
### Swap Shipment Created
@@ -2515,8 +2522,8 @@ You don’t have to create a template for every type in the reference. You can s
**Description:** Template to be sent to the customer when a shipment of a swap of an order has been created.
<details>
<summary>Example Data</summary>
<Details>
<Summary>Example Data</Summary>
```json noReport
Object {
@@ -3087,7 +3094,8 @@ You don’t have to create a template for every type in the reference. You can s
"tracking_number": "",
}
```
</details>
</Details>
### Swap Received
@@ -3095,8 +3103,8 @@ You don’t have to create a template for every type in the reference. You can s
**Description:** Template to be sent to the customer when a swap of an order has been received.
<details>
<summary>Example Data</summary>
<Details>
<Summary>Example Data</Summary>
```json noReport
{
@@ -3597,7 +3605,8 @@ You don’t have to create a template for every type in the reference. You can s
"additional_total": "11.25 USD"
}
```
</details>
</Details>
### Gift Card Created
@@ -3605,8 +3614,8 @@ You don’t have to create a template for every type in the reference. You can s
**Description:** Template to be to the customer sent when a gift card in their order has been created.
<details>
<summary>Example Data</summary>
<Details>
<Summary>Example Data</Summary>
```json noReport
Object {
@@ -3765,7 +3774,8 @@ You don’t have to create a template for every type in the reference. You can s
"display_value": 4
}
```
</details>
</Details>
### Customer Password Reset
@@ -3773,8 +3783,8 @@ You don’t have to create a template for every type in the reference. You can s
**Description:** Template to be sent to the customer when they request a password reset.
<details>
<summary>Example Data</summary>
<Details>
<Summary>Example Data</Summary>
```json noReport
Object {
@@ -3785,7 +3795,8 @@ You don’t have to create a template for every type in the reference. You can s
"token": Any<String>,
}
```
</details>
</Details>
### User Password Reset
@@ -3793,8 +3804,8 @@ You don’t have to create a template for every type in the reference. You can s
**Description:** Template to be sent to the admin user when they request a password reset.
<details>
<summary>Example Data</summary>
<Details>
<Summary>Example Data</Summary>
```json noReport
Object {
@@ -3802,7 +3813,8 @@ You don’t have to create a template for every type in the reference. You can s
"token": Any<String>,
}
```
</details>
</Details>
### Restock Notification
@@ -3810,8 +3822,8 @@ You don’t have to create a template for every type in the reference. You can s
**Description:** Template to be sent to admin users when a product has hit the restock quantity threshold.
<details>
<summary>Example Data</summary>
<Details>
<Summary>Example Data</Summary>
```json noReport
Object {
@@ -3899,7 +3911,8 @@ You don’t have to create a template for every type in the reference. You can s
]
}
```
</details>
</Details>
---
@@ -4004,8 +4017,7 @@ export const POST = async (
to: "customer@mail.com",
dynamic_template_data: { dynamic: "data" },
}
sendgridService.sendEmail(sendOptions)
sendgridService.sendEmail(sendOptions)
}
```
+47 -49
View File
@@ -266,62 +266,60 @@ Medusa allows you to create custom API Routes exposed as REST APIs.
}
}} />
<details>
<summary>
Example Implementation
</summary>
<Details>
<Summary>Example Implementation</Summary>
For example, create the following API Route that allows you to check the customer’s group and whether it has the `is_b2b` flag enabled:
For example, create the following API Route that allows you to check the customer’s group and whether it has the `is_b2b` flag enabled:
```ts title=src/api/store/customers/is-b2b/route.ts
import type {
CustomerService,
MedusaRequest,
MedusaResponse,
} from "@medusajs/medusa"
export const GET = async (
req: MedusaRequest,
res: MedusaResponse
) => {
const customerService: CustomerService = req.scope.resolve(
"customerService"
)
const customer = await customerService
.retrieve(req.user.customer_id, {
relations: ["groups"],
})
const is_b2b = customer.groups.some(
(group) => group.metadata.is_b2b === "true"
)
```ts title=src/api/store/customers/is-b2b/route.ts
import type {
CustomerService,
MedusaRequest,
MedusaResponse,
} from "@medusajs/medusa"
export const GET = async (
req: MedusaRequest,
res: MedusaResponse
) => {
const customerService: CustomerService = req.scope.resolve(
"customerService"
)
const customer = await customerService
.retrieve(req.user.customer_id, {
relations: ["groups"],
return res.json({
is_b2b,
})
}
```
const is_b2b = customer.groups.some(
(group) => group.metadata.is_b2b === "true"
)
return res.json({
is_b2b,
})
}
```
Then add the `requireCustomerAuthentication` middleware in `src/api/middlewares.ts` that ensures only authenticated customer can access this API Route:
Then add the `requireCustomerAuthentication` middleware in `src/api/middlewares.ts` that ensures only authenticated customer can access this API Route:
```ts title=src/api/middlewares.ts
import {
requireCustomerAuthentication,
type MiddlewaresConfig,
} from "@medusajs/medusa"
```ts title=src/api/middlewares.ts
import {
requireCustomerAuthentication,
type MiddlewaresConfig,
} from "@medusajs/medusa"
export const config: MiddlewaresConfig = {
routes: [
{
matcher: "/store/customers/is-b2b",
middlewares: [requireCustomerAuthentication()],
},
],
}
```
export const config: MiddlewaresConfig = {
routes: [
{
matcher: "/store/customers/is-b2b",
middlewares: [requireCustomerAuthentication()],
},
],
}
```
</details>
</Details>
---
@@ -100,85 +100,83 @@ Medusa also provides official notification plugins that integrate with third-par
},
]} />
<details>
<summary>
Example: Sending an email for new notes
</summary>
Here’s an example of a subscriber that uses the SendGrid plugin to send an email to the customer when the order has a new note:
<Details>
<Summary>Example: Sending an email for new notes</Summary>
```ts title=src/subscribers/new-note.ts
import {
EventBusService,
NoteService,
OrderService,
} from "@medusajs/medusa"
Here’s an example of a subscriber that uses the SendGrid plugin to send an email to the customer when the order has a new note:
type InjectedDependencies = {
eventBusService: EventBusService
sendgridService: any
noteService: NoteService
orderService: OrderService
}
```ts title=src/subscribers/new-note.ts
import {
EventBusService,
NoteService,
OrderService,
} from "@medusajs/medusa"
class NewNoteSubscriber {
protected sendGridService_: any
protected noteService_: NoteService
protected orderService_: OrderService
constructor({
eventBusService,
sendgridService,
noteService,
orderService,
}: InjectedDependencies) {
this.noteService_ = noteService
this.orderService_ = orderService
this.sendGridService_ = sendgridService
eventBusService.subscribe(
"note.created",
this.handleNoteCreated
)
type InjectedDependencies = {
eventBusService: EventBusService
sendgridService: any
noteService: NoteService
orderService: OrderService
}
handleNoteCreated = async (data) => {
// retrieve note by id
const note = await this.noteService_.retrieve(data.id, {
relations: ["author"],
})
class NewNoteSubscriber {
protected sendGridService_: any
protected noteService_: NoteService
protected orderService_: OrderService
if (!note || note.resource_type !== "order") {
return
constructor({
eventBusService,
sendgridService,
noteService,
orderService,
}: InjectedDependencies) {
this.noteService_ = noteService
this.orderService_ = orderService
this.sendGridService_ = sendgridService
eventBusService.subscribe(
"note.created",
this.handleNoteCreated
)
}
// retrieve note's order
const order = await this.orderService_.retrieve(
note.resource_id
)
handleNoteCreated = async (data) => {
// retrieve note by id
const note = await this.noteService_.retrieve(data.id, {
relations: ["author"],
})
if (!order) {
return
if (!note || note.resource_type !== "order") {
return
}
// retrieve note's order
const order = await this.orderService_.retrieve(
note.resource_id
)
if (!order) {
return
}
this.sendGridService_.sendEmail({
templateId: "order-update",
from: "hello@medusajs.com",
to: order.email,
dynamic_template_data: {
// any data necessary for your template...
note_text: note.value,
note_author: note.author.first_name,
note_date: note.created_at,
order_id: order.display_id,
},
})
}
this.sendGridService_.sendEmail({
templateId: "order-update",
from: "hello@medusajs.com",
to: order.email,
dynamic_template_data: {
// any data necessary for your template...
note_text: note.value,
note_author: note.author.first_name,
note_date: note.created_at,
order_id: order.display_id,
},
})
}
}
export default NewNoteSubscriber
```
export default NewNoteSubscriber
```
</details>
</Details>
---
@@ -198,75 +196,73 @@ You can implement automatic synchronization in Medusa using scheduled jobs. A sc
}
}} />
<details>
<summary>
Example: Synchronizing products with a third-party service
</summary>
<Details>
<Summary>Example: Synchronizing products with a third-party service</Summary>
Here’s an example of synchronizing products with a third party service using a [loader](../development/loaders/create.md):
Here’s an example of synchronizing products with a third party service using a [loader](../development/loaders/create.md):
```ts title=src/loaders/sync-products.ts
import {
Logger,
ProductService,
StoreService,
} from "@medusajs/medusa"
import {
ProductSelector,
} from "@medusajs/medusa/dist/types/product"
import { AwilixContainer } from "awilix"
```ts title=src/loaders/sync-products.ts
import {
Logger,
ProductService,
StoreService,
} from "@medusajs/medusa"
import {
ProductSelector,
} from "@medusajs/medusa/dist/types/product"
import { AwilixContainer } from "awilix"
export default async (
container: AwilixContainer,
config: Record<string, unknown>
): Promise<void> => {
const logger = container.resolve<Logger>("logger")
logger.info("Synchronizing products...")
const productService = container.resolve<ProductService>(
"productService"
)
const storeService = container.resolve<StoreService>(
"storeService"
)
// retrieve store to get last sync date
const store = await storeService.retrieve()
export default async (
container: AwilixContainer,
config: Record<string, unknown>
): Promise<void> => {
const logger = container.resolve<Logger>("logger")
logger.info("Synchronizing products...")
const productService = container.resolve<ProductService>(
"productService"
)
const storeService = container.resolve<StoreService>(
"storeService"
)
// retrieve store to get last sync date
const store = await storeService.retrieve()
const productFilters: ProductSelector = {}
const productFilters: ProductSelector = {}
if (store.metadata.last_sync_date) {
productFilters.updated_at = {
gt: new Date(
store.metadata.last_sync_date as string
),
if (store.metadata.last_sync_date) {
productFilters.updated_at = {
gt: new Date(
store.metadata.last_sync_date as string
),
}
}
const updatedProducts = await productService.list(
productFilters
)
updatedProducts.forEach((product) => {
// assuming client is an initialized connection
// with a third-party service
client.sync(product)
})
await storeService.update({
metadata: {
last_sync_date: new Date(),
},
})
logger.info("Finish synchronizing products")
}
```
const updatedProducts = await productService.list(
productFilters
)
updatedProducts.forEach((product) => {
// assuming client is an initialized connection
// with a third-party service
client.sync(product)
})
Notice that here it’s assumed that:
await storeService.update({
metadata: {
last_sync_date: new Date(),
},
})
logger.info("Finish synchronizing products")
}
```
1. The last update date is stored in the `Store`'s metadata object. You can instead use a custom entity to handle this.
2. The connection to the third-party service is assumed to be available and handled within the `client` variable.
Notice that here it’s assumed that:
1. The last update date is stored in the `Store`'s metadata object. You can instead use a custom entity to handle this.
2. The connection to the third-party service is assumed to be available and handled within the `client` variable.
</details>
</Details>
---
@@ -419,88 +415,86 @@ For example, if you're grouping customers with over twenty orders, you can use a
},
]} />
<details>
<summary>
Example: Add customer to VIP group
</summary>
<Details>
<Summary>Example: Add customer to VIP group</Summary>
Here’s an example of a subscriber that listens to the `order.placed` event and checks if the customer should be added to the VIP customer group based on their number of orders:
Here’s an example of a subscriber that listens to the `order.placed` event and checks if the customer should be added to the VIP customer group based on their number of orders:
```ts title=src/subscribers/add-custom-to-vip.ts
import {
CustomerGroupService,
CustomerService,
EventBusService,
OrderService,
} from "@medusajs/medusa"
```ts title=src/subscribers/add-custom-to-vip.ts
import {
CustomerGroupService,
CustomerService,
EventBusService,
OrderService,
} from "@medusajs/medusa"
type InjectedDependencies = {
orderService: OrderService
customerService: CustomerService
customerGroupService: CustomerGroupService
eventBusService: EventBusService
}
class AddCustomerToVipSubscriber {
protected orderService_: OrderService
protected customerService_: CustomerService
protected customerGroupService_: CustomerGroupService
constructor({
orderService,
customerService,
customerGroupService,
eventBusService,
}: InjectedDependencies) {
this.orderService_ = orderService
this.customerService_ = customerService
this.customerGroupService_ = customerGroupService
eventBusService.subscribe(
"order.placed",
this.handleOrderPlaced
)
type InjectedDependencies = {
orderService: OrderService
customerService: CustomerService
customerGroupService: CustomerGroupService
eventBusService: EventBusService
}
handleOrderPlaced = async ({ id }) => {
// check if VIP group exists
const vipGroup = await this.customerGroupService_.list({
name: "VIP",
}, {
relations: ["customers"],
})
if (!vipGroup.length) {
return
}
class AddCustomerToVipSubscriber {
protected orderService_: OrderService
protected customerService_: CustomerService
protected customerGroupService_: CustomerGroupService
// retrieve order and its customer
const order = await this.orderService_.retrieve(id)
if (!order || !order.customer_id ||
vipGroup[0].customers.find(
(customer) => customer.id === order.customer_id
) !== undefined) {
return
}
// retrieve orders of this customer
const [, count] = await this.orderService_.listAndCount({
customer_id: order.customer_id,
})
if (count >= 20) {
// add customer to VIP group
this.customerGroupService_.addCustomers(
vipGroup[0].id,
order.customer_id
constructor({
orderService,
customerService,
customerGroupService,
eventBusService,
}: InjectedDependencies) {
this.orderService_ = orderService
this.customerService_ = customerService
this.customerGroupService_ = customerGroupService
eventBusService.subscribe(
"order.placed",
this.handleOrderPlaced
)
}
handleOrderPlaced = async ({ id }) => {
// check if VIP group exists
const vipGroup = await this.customerGroupService_.list({
name: "VIP",
}, {
relations: ["customers"],
})
if (!vipGroup.length) {
return
}
// retrieve order and its customer
const order = await this.orderService_.retrieve(id)
if (!order || !order.customer_id ||
vipGroup[0].customers.find(
(customer) => customer.id === order.customer_id
) !== undefined) {
return
}
// retrieve orders of this customer
const [, count] = await this.orderService_.listAndCount({
customer_id: order.customer_id,
})
if (count >= 20) {
// add customer to VIP group
this.customerGroupService_.addCustomers(
vipGroup[0].id,
order.customer_id
)
}
}
}
}
export default AddCustomerToVipSubscriber
```
export default AddCustomerToVipSubscriber
```
</details>
</Details>
---
@@ -543,105 +537,103 @@ You can alternatively have a Scheduled Job that checks if the number of new prod
},
]} />
<details>
<summary>
Example: Sending a newsletter email after adding ten products
</summary>
<Details>
<Summary>Example: Sending a newsletter email after adding ten products</Summary>
Here’s an example of listening to the `product.created` event in a subscriber and send a newsletter if the condition is met:
Here’s an example of listening to the `product.created` event in a subscriber and send a newsletter if the condition is met:
```ts title=src/subscribers/send-products-newsletter.ts
import {
CustomerService,
EventBusService,
NoteService,
OrderService,
ProductService,
StoreService,
} from "@medusajs/medusa"
import {
ProductSelector,
} from "@medusajs/medusa/dist/types/product"
```ts title=src/subscribers/send-products-newsletter.ts
import {
CustomerService,
EventBusService,
NoteService,
OrderService,
ProductService,
StoreService,
} from "@medusajs/medusa"
import {
ProductSelector,
} from "@medusajs/medusa/dist/types/product"
type InjectedDependencies = {
eventBusService: EventBusService
sendgridService: any
productService: ProductService
storeService: StoreService
customerService: CustomerService
}
class SendProductsNewsletterSubscriber {
protected sendGridService_: any
protected productService_: ProductService
protected storeService_: StoreService
protected customerService_: CustomerService
constructor({
eventBusService,
sendgridService,
productService,
storeService,
customerService,
}: InjectedDependencies) {
this.productService_ = productService
this.sendGridService_ = sendgridService
this.storeService_ = storeService
this.customerService_ = customerService
eventBusService.subscribe(
"product.created",
this.handleProductCreated
)
type InjectedDependencies = {
eventBusService: EventBusService
sendgridService: any
productService: ProductService
storeService: StoreService
customerService: CustomerService
}
handleProductCreated = async ({ id }) => {
// retrieve store to have access to last send date
const store = await this.storeService_.retrieve()
const productFilters: ProductSelector = {}
if (store.metadata.last_send_date) {
productFilters.created_at = {
gt: new Date(store.metadata.last_send_date as string),
class SendProductsNewsletterSubscriber {
protected sendGridService_: any
protected productService_: ProductService
protected storeService_: StoreService
protected customerService_: CustomerService
constructor({
eventBusService,
sendgridService,
productService,
storeService,
customerService,
}: InjectedDependencies) {
this.productService_ = productService
this.sendGridService_ = sendgridService
this.storeService_ = storeService
this.customerService_ = customerService
eventBusService.subscribe(
"product.created",
this.handleProductCreated
)
}
handleProductCreated = async ({ id }) => {
// retrieve store to have access to last send date
const store = await this.storeService_.retrieve()
const productFilters: ProductSelector = {}
if (store.metadata.last_send_date) {
productFilters.created_at = {
gt: new Date(store.metadata.last_send_date as string),
}
}
const products = await this.productService_.list(
productFilters
)
if (products.length > 10) {
// get subscribed customers
const customers = await this.customerService_.list({
metadata: {
is_subscribed: true,
},
})
this.sendGridService_.sendEmail({
templateId: "product-newsletter",
from: "hello@medusajs.com",
to: customers.map((customer) => ({
name: customer.first_name,
email: customer.email,
})),
dynamic_template_data: {
// any data necessary for your template...
products,
},
})
await this.storeService_.update({
metadata: {
last_send_date: new Date(),
},
})
}
}
const products = await this.productService_.list(
productFilters
)
if (products.length > 10) {
// get subscribed customers
const customers = await this.customerService_.list({
metadata: {
is_subscribed: true,
},
})
this.sendGridService_.sendEmail({
templateId: "product-newsletter",
from: "hello@medusajs.com",
to: customers.map((customer) => ({
name: customer.first_name,
email: customer.email,
})),
dynamic_template_data: {
// any data necessary for your template...
products,
},
})
await this.storeService_.update({
metadata: {
last_send_date: new Date(),
},
})
}
}
}
export default SendProductsNewsletterSubscriber
```
export default SendProductsNewsletterSubscriber
```
</details>
</Details>
---
File diff suppressed because it is too large. Load diff
+154 -152
View File
@@ -41,105 +41,105 @@ To associate these entities with the `Store` entity, you need to extend and cust
}
}} />
<details>
<summary>Example: Associate User with Store</summary>
<Details>
<Summary>Example: Associate User with Store</Summary>
For example, to associate the `User` entity with the `Store` entity, create the file `src/models/user.ts` with the following content:
For example, to associate the `User` entity with the `Store` entity, create the file `src/models/user.ts` with the following content:
```ts title=src/models/user.ts
import {
Column,
Entity,
Index,
JoinColumn,
ManyToOne,
} from "typeorm"
import {
User as MedusaUser,
} from "@medusajs/medusa"
import { Store } from "./store"
```ts title=src/models/user.ts
import {
Column,
Entity,
Index,
JoinColumn,
ManyToOne,
} from "typeorm"
import {
User as MedusaUser,
} from "@medusajs/medusa"
import { Store } from "./store"
@Entity()
export class User extends MedusaUser {
@Index("UserStoreId")
@Column({ nullable: true })
store_id?: string
@Entity()
export class User extends MedusaUser {
@Index("UserStoreId")
@Column({ nullable: true })
store_id?: string
@ManyToOne(() => Store, (store) => store.members)
@JoinColumn({ name: "store_id", referencedColumnName: "id" })
store?: Store
}
```
@ManyToOne(() => Store, (store) => store.members)
@JoinColumn({ name: "store_id", referencedColumnName: "id" })
store?: Store
}
```
Then, you need to extend the `UserRepository` to point to your extended entity. To do that, create the file `src/repositories/user.ts` with the following content:
Then, you need to extend the `UserRepository` to point to your extended entity. To do that, create the file `src/repositories/user.ts` with the following content:
```ts title=src/repositories/user.ts
import { User } from "../models/user"
import {
dataSource,
} from "@medusajs/medusa/dist/loaders/database"
import {
UserRepository as MedusaUserRepository,
} from "@medusajs/medusa/dist/repositories/user"
```ts title=src/repositories/user.ts
import { User } from "../models/user"
import {
dataSource,
} from "@medusajs/medusa/dist/loaders/database"
import {
UserRepository as MedusaUserRepository,
} from "@medusajs/medusa/dist/repositories/user"
export const UserRepository = dataSource
.getRepository(User)
.extend({
...Object.assign(
MedusaUserRepository,
{ target: User }
),
})
export const UserRepository = dataSource
.getRepository(User)
.extend({
...Object.assign(
MedusaUserRepository,
{ target: User }
),
})
export default UserRepository
```
export default UserRepository
```
Next, you need to create a migration that reflects the changes on the `User` entity in your database. To do that, run the following command to create a migration file:
Next, you need to create a migration that reflects the changes on the `User` entity in your database. To do that, run the following command to create a migration file:
```bash
npx typeorm migration:create src/migrations/add-user-store-id
```
```bash
npx typeorm migration:create src/migrations/add-user-store-id
```
This creates a file in the `src/migrations` directory of the format `<TIMESTAMP>_add-user-store-id.ts`. Replace the `up` and `down` methods in that file with the methods here:
This creates a file in the `src/migrations` directory of the format `<TIMESTAMP>_add-user-store-id.ts`. Replace the `up` and `down` methods in that file with the methods here:
```ts title=src/migrations/<TIMESTAMP>_add-user-store-id.ts
// ...
```ts title=src/migrations/<TIMESTAMP>_add-user-store-id.ts
// ...
export class AddUserStoreId1681287255173
implements MigrationInterface {
// ...
export class AddUserStoreId1681287255173
implements MigrationInterface {
// ...
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "user" ADD "store_id" character varying`
)
await queryRunner.query(
`CREATE INDEX "UserStoreId" ON "user" ("store_id")`
)
}
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "user" ADD "store_id" character varying`
)
await queryRunner.query(
`CREATE INDEX "UserStoreId" ON "user" ("store_id")`
)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`DROP INDEX "public"."UserStoreId"`
)
await queryRunner.query(
`ALTER TABLE "user" DROP COLUMN "store_id"`
)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`DROP INDEX "public"."UserStoreId"`
)
await queryRunner.query(
`ALTER TABLE "user" DROP COLUMN "store_id"`
)
}
}
```
}
```
Finally, to reflect these changes and start using them, `build` your changes and run migrations with the following commands:
Finally, to reflect these changes and start using them, `build` your changes and run migrations with the following commands:
```bash npm2yarn
npm run build
npx medusa migrations run
```
```bash npm2yarn
npm run build
npx medusa migrations run
```
You can extend other entities in a similar manner to associate them with a store.
You can extend other entities in a similar manner to associate them with a store.
</details>
</Details>
---
@@ -179,75 +179,76 @@ You can also extend services if you need to customize a functionality implemente
}
}} />
<details>
<summary>Example: Extend User Service</summary>
<Details>
<Summary>Example: Extend User Service</Summary>
You can extend the user service to change how the `create` method is implemented.
You can extend the user service to change how the `create` method is implemented.
To extend the user service, create the file `src/services/user.ts` with the following content:
To extend the user service, create the file `src/services/user.ts` with the following content:
<!-- eslint-disable prefer-rest-params -->
```ts title=src/services/user.ts
import { Lifetime } from "awilix"
import {
UserService as MedusaUserService,
} from "@medusajs/medusa"
import { User } from "../models/user"
import {
CreateUserInput as MedusaCreateUserInput,
} from "@medusajs/medusa/dist/types/user"
import StoreRepository from "../repositories/store"
```ts title=src/services/user.ts
import { Lifetime } from "awilix"
import {
UserService as MedusaUserService,
} from "@medusajs/medusa"
import { User } from "../models/user"
import {
CreateUserInput as MedusaCreateUserInput,
} from "@medusajs/medusa/dist/types/user"
import StoreRepository from "../repositories/store"
type CreateUserInput = {
store_id?: string
} & MedusaCreateUserInput
type CreateUserInput = {
store_id?: string
} & MedusaCreateUserInput
class UserService extends MedusaUserService {
static LIFE_TIME = Lifetime.SCOPED
protected readonly loggedInUser_: User | null
protected readonly storeRepository_: typeof StoreRepository
class UserService extends MedusaUserService {
static LIFE_TIME = Lifetime.SCOPED
protected readonly loggedInUser_: User | null
protected readonly storeRepository_: typeof StoreRepository
constructor(container, options) {
super(...arguments)
this.storeRepository_ = container.storeRepository
constructor(container, options) {
super(...arguments)
this.storeRepository_ = container.storeRepository
try {
this.loggedInUser_ = container.loggedInUser
} catch (e) {
// avoid errors when backend first runs
try {
this.loggedInUser_ = container.loggedInUser
} catch (e) {
// avoid errors when backend first runs
}
}
async create(
user: CreateUserInput,
password: string
): Promise<User> {
if (!user.store_id) {
const storeRepo = this.manager_.withRepository(
this.storeRepository_
)
let newStore = storeRepo.create()
newStore = await storeRepo.save(newStore)
user.store_id = newStore.id
}
return await super.create(user, password)
}
}
async create(
user: CreateUserInput,
password: string
): Promise<User> {
if (!user.store_id) {
const storeRepo = this.manager_.withRepository(
this.storeRepository_
)
let newStore = storeRepo.create()
newStore = await storeRepo.save(newStore)
user.store_id = newStore.id
}
export default UserService
```
return await super.create(user, password)
}
}
In the `create` method of this extended service, you create a new store if the user being created doesn't have a store associated with it.
export default UserService
```
You can then test out your customization by running the `build` command and starting the backend:
In the `create` method of this extended service, you create a new store if the user being created doesn't have a store associated with it.
```bash
npm run build
npx medusa develop
```
You can then test out your customization by running the `build` command and starting the backend:
```bash
npm run build
npx medusa develop
```
</details>
</Details>
---
@@ -267,34 +268,35 @@ To listen to events, you need to create Subscribers that subscribe a handler met
}
}} />
<details>
<summary>Example: Listen to Order Created Event</summary>
<Details>
<Summary>Example: Listen to Order Created Event</Summary>
To listen to the `order.placed` event, create the file `src/subscribers/orderNotifier.ts` with the following content:
To listen to the `order.placed` event, create the file `src/subscribers/orderNotifier.ts` with the following content:
```ts title=src/subscribers/orderNotifier.ts
class OrderNotifierSubscriber {
constructor({ eventBusService }) {
eventBusService.subscribe("order.placed", this.handleOrder)
```ts title=src/subscribers/orderNotifier.ts
class OrderNotifierSubscriber {
constructor({ eventBusService }) {
eventBusService.subscribe("order.placed", this.handleOrder)
}
handleOrder = async (data) => {
// TODO perform functionality
}
}
handleOrder = async (data) => {
// TODO perform functionality
}
}
export default OrderNotifierSubscriber
```
export default OrderNotifierSubscriber
```
This subscribes the `handleOrder` method to be executed whenever the `order.placed` event is emitted.
This subscribes the `handleOrder` method to be executed whenever the `order.placed` event is emitted.
You can then test out your subscriber by running the `build` command and starting the backend:
You can then test out your subscriber by running the `build` command and starting the backend:
```bash
npm run build
npx medusa develop
```
```bash
npm run build
npx medusa develop
```
</details>
</Details>
---
+36 -38
View File
@@ -94,50 +94,48 @@ To search through product variants by their barcode, you can create a custom API
},
]} />
<details>
<summary>
Example: Search Products By Barcode API Route
</summary>
<Details>
<Summary>Example: Search Products By Barcode API Route</Summary>
Here’s an example of creating a custom API Route at `/store/pos/search-barcode` that searches product variants by a barcode:
Here’s an example of creating a custom API Route at `/store/pos/search-barcode` that searches product variants by a barcode:
```ts title=src/api/store/pos/search-barcode/route.ts
import type {
MedusaRequest,
MedusaResponse,
ProductVariantService,
} from "@medusajs/medusa"
import { MedusaError } from "@medusajs/utils"
```ts title=src/api/store/pos/search-barcode/route.ts
import type {
MedusaRequest,
MedusaResponse,
ProductVariantService,
} from "@medusajs/medusa"
import { MedusaError } from "@medusajs/utils"
export const GET = async (
req: MedusaRequest,
res: MedusaResponse
) => {
const barcode = (req.query.barcode as string) || ""
if (!barcode) {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
"Barcode is required"
)
}
// get product service
const productVariantService = req.scope.resolve<
ProductVariantService
>("productVariantService")
export const GET = async (
req: MedusaRequest,
res: MedusaResponse
) => {
const barcode = (req.query.barcode as string) || ""
if (!barcode) {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
"Barcode is required"
)
}
// get product service
const productVariantService = req.scope.resolve<
ProductVariantService
>("productVariantService")
// retrieve product variants by barcode
const productVariants = await productVariantService
.list({
barcode,
// retrieve product variants by barcode
const productVariants = await productVariantService
.list({
barcode,
})
res.json({
product_variants: productVariants,
})
}
```
res.json({
product_variants: productVariants,
})
}
```
</details>
</Details>
---
@@ -49,7 +49,7 @@ An address is used across the Medusa backend within other schemas and object typ
},
{
"name": "country",
"type": "``null`` \\| [`Country`](Country.mdx)",
"type": "``null`` \\| [Country](Country.mdx)",
"description": "A country object.",
"optional": false,
"defaultValue": "",
@@ -76,7 +76,7 @@ An address is used across the Medusa backend within other schemas and object typ
},
{
"name": "customer",
"type": "``null`` \\| [`Customer`](Customer.mdx)",
"type": "``null`` \\| [Customer](Customer.mdx)",
"description": "Available if the relation `customer` is expanded.",
"optional": false,
"defaultValue": "",
@@ -130,7 +130,7 @@ An address is used across the Medusa backend within other schemas and object typ
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -40,7 +40,7 @@ A Batch Job indicates an asynchronus task stored in the Medusa backend. Its stat
},
{
"name": "context",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "The context of the batch job, the type of the batch job determines what the context should contain.",
"optional": false,
"defaultValue": "",
@@ -67,7 +67,7 @@ A Batch Job indicates an asynchronus task stored in the Medusa backend. Its stat
},
{
"name": "created_by_user",
"type": "[`User`](User.mdx)",
"type": "[User](User.mdx)",
"description": "The details of the user that created the batch job.",
"optional": false,
"defaultValue": "",
@@ -138,7 +138,7 @@ A Batch Job indicates an asynchronus task stored in the Medusa backend. Its stat
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -156,7 +156,7 @@ A Batch Job indicates an asynchronus task stored in the Medusa backend. Its stat
},
{
"name": "role",
"type": "[`UserRoles`](../enums/UserRoles.mdx)",
"type": "[UserRoles](../enums/UserRoles.mdx)",
"description": "The user's role. These roles don't provide any different privileges.",
"optional": false,
"defaultValue": "member",
@@ -230,7 +230,7 @@ A Batch Job indicates an asynchronus task stored in the Medusa backend. Its stat
},
{
"name": "result",
"type": "{ `advancement_count?`: `number` ; `count?`: `number` ; `errors?`: (`string` \\| [`BatchJobResultError`](../types/BatchJobResultError.mdx))[] ; `file_key?`: `string` ; `file_size?`: `number` ; `progress?`: `number` ; `stat_descriptors?`: [`BatchJobResultStatDescriptor`](../types/BatchJobResultStatDescriptor.mdx)[] } & Record<`string`, `unknown`\\>",
"type": "`&#123; advancement_count?: number ; count?: number ; errors?: (string \\| [BatchJobResultError](../types/BatchJobResultError.mdx))[] ; file_key?: string ; file_size?: number ; progress?: number ; stat_descriptors?: [BatchJobResultStatDescriptor](../types/BatchJobResultStatDescriptor.mdx)[] &#125;` & `Record<string, unknown>`",
"description": "The result of the batch job.",
"optional": false,
"defaultValue": "",
@@ -256,7 +256,7 @@ A Batch Job indicates an asynchronus task stored in the Medusa backend. Its stat
},
{
"name": "errors",
"type": "(`string` \\| [`BatchJobResultError`](../types/BatchJobResultError.mdx))[]",
"type": "(`string` \\| [BatchJobResultError](../types/BatchJobResultError.mdx))[]",
"description": "",
"optional": true,
"defaultValue": "",
@@ -292,7 +292,7 @@ A Batch Job indicates an asynchronus task stored in the Medusa backend. Its stat
},
{
"name": "stat_descriptors",
"type": "[`BatchJobResultStatDescriptor`](../types/BatchJobResultStatDescriptor.mdx)[]",
"type": "[BatchJobResultStatDescriptor](../types/BatchJobResultStatDescriptor.mdx)[]",
"description": "",
"optional": true,
"defaultValue": "",
@@ -303,7 +303,7 @@ A Batch Job indicates an asynchronus task stored in the Medusa backend. Its stat
},
{
"name": "status",
"type": "[`BatchJobStatus`](../enums/BatchJobStatus.mdx)",
"type": "[BatchJobStatus](../enums/BatchJobStatus.mdx)",
"description": "The status of the batch job.",
"optional": false,
"defaultValue": "created",
@@ -13,7 +13,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
<ParameterTypes parameters={[
{
"name": "billing_address",
"type": "[`Address`](Address.mdx)",
"type": "[Address](Address.mdx)",
"description": "The details of the billing address associated with the cart.",
"optional": false,
"defaultValue": "",
@@ -40,7 +40,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
},
{
"name": "context",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "The context of the cart which can include info like IP or user agent.",
"optional": false,
"defaultValue": "",
@@ -58,7 +58,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
},
{
"name": "customer",
"type": "[`Customer`](Customer.mdx)",
"type": "[Customer](Customer.mdx)",
"description": "The details of the customer the cart belongs to.",
"optional": false,
"defaultValue": "",
@@ -94,7 +94,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
},
{
"name": "discounts",
"type": "[`Discount`](Discount.mdx)[]",
"type": "[Discount](Discount.mdx)[]",
"description": "An array of details of all discounts applied to the cart.",
"optional": false,
"defaultValue": "",
@@ -130,7 +130,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
},
{
"name": "gift_cards",
"type": "[`GiftCard`](GiftCard.mdx)[]",
"type": "[GiftCard](GiftCard.mdx)[]",
"description": "An array of details of all gift cards applied to the cart.",
"optional": false,
"defaultValue": "",
@@ -166,7 +166,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
},
{
"name": "items",
"type": "[`LineItem`](LineItem.mdx)[]",
"type": "[LineItem](LineItem.mdx)[]",
"description": "The line items added to the cart.",
"optional": false,
"defaultValue": "",
@@ -175,7 +175,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -193,7 +193,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
},
{
"name": "payment",
"type": "[`Payment`](Payment.mdx)",
"type": "[Payment](Payment.mdx)",
"description": "The details of the payment associated with the cart.",
"optional": false,
"defaultValue": "",
@@ -220,7 +220,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
},
{
"name": "payment_session",
"type": "``null`` \\| [`PaymentSession`](PaymentSession.mdx)",
"type": "``null`` \\| [PaymentSession](PaymentSession.mdx)",
"description": "The details of the selected payment session in the cart.",
"optional": false,
"defaultValue": "",
@@ -229,7 +229,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
},
{
"name": "payment_sessions",
"type": "[`PaymentSession`](PaymentSession.mdx)[]",
"type": "[PaymentSession](PaymentSession.mdx)[]",
"description": "The details of all payment sessions created on the cart.",
"optional": false,
"defaultValue": "",
@@ -265,7 +265,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
},
{
"name": "region",
"type": "[`Region`](Region.mdx)",
"type": "[Region](Region.mdx)",
"description": "The details of the region associated with the cart.",
"optional": false,
"defaultValue": "",
@@ -283,7 +283,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
},
{
"name": "sales_channel",
"type": "[`SalesChannel`](SalesChannel.mdx)",
"type": "[SalesChannel](SalesChannel.mdx)",
"description": "The details of the sales channel associated with the cart.",
"optional": false,
"defaultValue": "",
@@ -301,7 +301,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
},
{
"name": "shipping_address",
"type": "``null`` \\| [`Address`](Address.mdx)",
"type": "``null`` \\| [Address](Address.mdx)",
"description": "The details of the shipping address associated with the cart.",
"optional": false,
"defaultValue": "",
@@ -319,7 +319,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
},
{
"name": "shipping_methods",
"type": "[`ShippingMethod`](ShippingMethod.mdx)[]",
"type": "[ShippingMethod](ShippingMethod.mdx)[]",
"description": "The details of the shipping methods added to the cart.",
"optional": false,
"defaultValue": "",
@@ -373,7 +373,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
},
{
"name": "type",
"type": "[`CartType`](../enums/CartType.mdx)",
"type": "[CartType](../enums/CartType.mdx)",
"description": "The cart's type.",
"optional": false,
"defaultValue": "default",
@@ -13,7 +13,7 @@ The details of an image attached to a claim.
<ParameterTypes parameters={[
{
"name": "claim_item",
"type": "[`ClaimItem`](ClaimItem.mdx)",
"type": "[ClaimItem](ClaimItem.mdx)",
"description": "The details of the claim item this image is associated with.",
"optional": false,
"defaultValue": "",
@@ -21,7 +21,7 @@ The details of an image attached to a claim.
"children": [
{
"name": "claim_order",
"type": "[`ClaimOrder`](ClaimOrder.mdx)",
"type": "[ClaimOrder](ClaimOrder.mdx)",
"description": "The details of the claim this item belongs to.",
"optional": false,
"defaultValue": "",
@@ -66,7 +66,7 @@ The details of an image attached to a claim.
},
{
"name": "images",
"type": "[`ClaimImage`](ClaimImage.mdx)[]",
"type": "[ClaimImage](ClaimImage.mdx)[]",
"description": "The claim images that are attached to the claim item.",
"optional": false,
"defaultValue": "",
@@ -75,7 +75,7 @@ The details of an image attached to a claim.
},
{
"name": "item",
"type": "[`LineItem`](LineItem.mdx)",
"type": "[LineItem](LineItem.mdx)",
"description": "The details of the line item in the original order that this claim item refers to.",
"optional": false,
"defaultValue": "",
@@ -93,7 +93,7 @@ The details of an image attached to a claim.
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -120,7 +120,7 @@ The details of an image attached to a claim.
},
{
"name": "reason",
"type": "[`ClaimReason`](../enums/ClaimReason.mdx)",
"type": "[ClaimReason](../enums/ClaimReason.mdx)",
"description": "The reason for the claim",
"optional": false,
"defaultValue": "",
@@ -129,7 +129,7 @@ The details of an image attached to a claim.
},
{
"name": "tags",
"type": "[`ClaimTag`](ClaimTag.mdx)[]",
"type": "[ClaimTag](ClaimTag.mdx)[]",
"description": "User defined tags for easy filtering and grouping.",
"optional": false,
"defaultValue": "",
@@ -147,7 +147,7 @@ The details of an image attached to a claim.
},
{
"name": "variant",
"type": "[`ProductVariant`](ProductVariant.mdx)",
"type": "[ProductVariant](ProductVariant.mdx)",
"description": "The details of the product variant to potentially replace the item in the original order.",
"optional": false,
"defaultValue": "",
@@ -203,7 +203,7 @@ The details of an image attached to a claim.
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -13,7 +13,7 @@ A claim item is an item created as part of a claim. It references an item in the
<ParameterTypes parameters={[
{
"name": "claim_order",
"type": "[`ClaimOrder`](ClaimOrder.mdx)",
"type": "[ClaimOrder](ClaimOrder.mdx)",
"description": "The details of the claim this item belongs to.",
"optional": false,
"defaultValue": "",
@@ -21,7 +21,7 @@ A claim item is an item created as part of a claim. It references an item in the
"children": [
{
"name": "additional_items",
"type": "[`LineItem`](LineItem.mdx)[]",
"type": "[LineItem](LineItem.mdx)[]",
"description": "The details of the new items to be shipped when the claim's type is `replace`",
"optional": false,
"defaultValue": "",
@@ -39,7 +39,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "claim_items",
"type": "[`ClaimItem`](ClaimItem.mdx)[]",
"type": "[ClaimItem](ClaimItem.mdx)[]",
"description": "The details of the items that should be replaced or refunded.",
"optional": false,
"defaultValue": "",
@@ -66,7 +66,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "fulfillment_status",
"type": "[`ClaimFulfillmentStatus`](../enums/ClaimFulfillmentStatus.mdx)",
"type": "[ClaimFulfillmentStatus](../enums/ClaimFulfillmentStatus.mdx)",
"description": "The claim's fulfillment status",
"optional": false,
"defaultValue": "not_fulfilled",
@@ -75,7 +75,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "fulfillments",
"type": "[`Fulfillment`](Fulfillment.mdx)[]",
"type": "[Fulfillment](Fulfillment.mdx)[]",
"description": "The fulfillments of the new items to be shipped",
"optional": false,
"defaultValue": "",
@@ -102,7 +102,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -120,7 +120,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "order",
"type": "[`Order`](Order.mdx)",
"type": "[Order](Order.mdx)",
"description": "The details of the order that this claim was created for.",
"optional": false,
"defaultValue": "",
@@ -138,7 +138,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "payment_status",
"type": "[`ClaimPaymentStatus`](../enums/ClaimPaymentStatus.mdx)",
"type": "[ClaimPaymentStatus](../enums/ClaimPaymentStatus.mdx)",
"description": "The status of the claim's payment",
"optional": false,
"defaultValue": "na",
@@ -156,7 +156,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "return_order",
"type": "[`Return`](Return.mdx)",
"type": "[Return](Return.mdx)",
"description": "The details of the return associated with the claim if the claim's type is `replace`.",
"optional": false,
"defaultValue": "",
@@ -165,7 +165,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "shipping_address",
"type": "[`Address`](Address.mdx)",
"type": "[Address](Address.mdx)",
"description": "The details of the address that new items should be shipped to.",
"optional": false,
"defaultValue": "",
@@ -183,7 +183,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "shipping_methods",
"type": "[`ShippingMethod`](ShippingMethod.mdx)[]",
"type": "[ShippingMethod](ShippingMethod.mdx)[]",
"description": "The details of the shipping methods that the claim order will be shipped with.",
"optional": false,
"defaultValue": "",
@@ -192,7 +192,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "type",
"type": "[`ClaimType`](../enums/ClaimType.mdx)",
"type": "[ClaimType](../enums/ClaimType.mdx)",
"description": "The claim's type",
"optional": false,
"defaultValue": "",
@@ -248,7 +248,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "images",
"type": "[`ClaimImage`](ClaimImage.mdx)[]",
"type": "[ClaimImage](ClaimImage.mdx)[]",
"description": "The claim images that are attached to the claim item.",
"optional": false,
"defaultValue": "",
@@ -256,7 +256,7 @@ A claim item is an item created as part of a claim. It references an item in the
"children": [
{
"name": "claim_item",
"type": "[`ClaimItem`](ClaimItem.mdx)",
"type": "[ClaimItem](ClaimItem.mdx)",
"description": "The details of the claim item this image is associated with.",
"optional": false,
"defaultValue": "",
@@ -301,7 +301,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -330,7 +330,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "item",
"type": "[`LineItem`](LineItem.mdx)",
"type": "[LineItem](LineItem.mdx)",
"description": "The details of the line item in the original order that this claim item refers to.",
"optional": false,
"defaultValue": "",
@@ -338,7 +338,7 @@ A claim item is an item created as part of a claim. It references an item in the
"children": [
{
"name": "adjustments",
"type": "[`LineItemAdjustment`](LineItemAdjustment.mdx)[]",
"type": "[LineItemAdjustment](LineItemAdjustment.mdx)[]",
"description": "The details of the item's adjustments, which are available when a discount is applied on the item.",
"optional": false,
"defaultValue": "",
@@ -356,7 +356,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "cart",
"type": "[`Cart`](Cart.mdx)",
"type": "[Cart](Cart.mdx)",
"description": "The details of the cart that the line item may belongs to.",
"optional": false,
"defaultValue": "",
@@ -374,7 +374,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "claim_order",
"type": "[`ClaimOrder`](ClaimOrder.mdx)",
"type": "[ClaimOrder](ClaimOrder.mdx)",
"description": "The details of the claim that the line item may belong to.",
"optional": false,
"defaultValue": "",
@@ -456,7 +456,7 @@ A claim item is an item created as part of a claim. It references an item in the
{
"name": "includes_tax",
"type": "`boolean`",
"description": "Indicates if the line item unit_price include tax",
"description": "Indicates if the line item unit\\_price include tax",
"optional": false,
"defaultValue": "false",
"expandable": false,
@@ -483,7 +483,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -492,7 +492,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "order",
"type": "[`Order`](Order.mdx)",
"type": "[Order](Order.mdx)",
"description": "The details of the order that the line item may belongs to.",
"optional": false,
"defaultValue": "",
@@ -501,7 +501,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "order_edit",
"type": "``null`` \\| [`OrderEdit`](OrderEdit.mdx)",
"type": "``null`` \\| [OrderEdit](OrderEdit.mdx)",
"description": "The details of the order edit.",
"optional": true,
"defaultValue": "",
@@ -627,7 +627,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "swap",
"type": "[`Swap`](Swap.mdx)",
"type": "[Swap](Swap.mdx)",
"description": "The details of the swap that the line item may belong to.",
"optional": false,
"defaultValue": "",
@@ -645,7 +645,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "tax_lines",
"type": "[`LineItemTaxLine`](LineItemTaxLine.mdx)[]",
"type": "[LineItemTaxLine](LineItemTaxLine.mdx)[]",
"description": "The details of the item's tax lines.",
"optional": false,
"defaultValue": "",
@@ -708,7 +708,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "variant",
"type": "[`ProductVariant`](ProductVariant.mdx)",
"type": "[ProductVariant](ProductVariant.mdx)",
"description": "The details of the product variant that this item was created from.",
"optional": false,
"defaultValue": "",
@@ -737,7 +737,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -764,7 +764,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "reason",
"type": "[`ClaimReason`](../enums/ClaimReason.mdx)",
"type": "[ClaimReason](../enums/ClaimReason.mdx)",
"description": "The reason for the claim",
"optional": false,
"defaultValue": "",
@@ -810,7 +810,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "tags",
"type": "[`ClaimTag`](ClaimTag.mdx)[]",
"type": "[ClaimTag](ClaimTag.mdx)[]",
"description": "User defined tags for easy filtering and grouping.",
"optional": false,
"defaultValue": "",
@@ -845,7 +845,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -883,7 +883,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "variant",
"type": "[`ProductVariant`](ProductVariant.mdx)",
"type": "[ProductVariant](ProductVariant.mdx)",
"description": "The details of the product variant to potentially replace the item in the original order.",
"optional": false,
"defaultValue": "",
@@ -892,7 +892,7 @@ A claim item is an item created as part of a claim. It references an item in the
{
"name": "allow_backorder",
"type": "`boolean`",
"description": "Whether the Product Variant should be purchasable when `inventory_quantity` is 0.",
"description": "Whether the Product Variant should be purchasable when `inventory\\_quantity` is 0.",
"optional": false,
"defaultValue": "false",
"expandable": false,
@@ -963,7 +963,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "inventory_items",
"type": "[`ProductVariantInventoryItem`](ProductVariantInventoryItem.mdx)[]",
"type": "[ProductVariantInventoryItem](ProductVariantInventoryItem.mdx)[]",
"description": "The details inventory items of the product variant.",
"optional": false,
"defaultValue": "",
@@ -1008,7 +1008,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "metadata",
"type": "``null`` \\| Record<`string`, `unknown`\\>",
"type": "``null`` \\| `Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -1026,7 +1026,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "options",
"type": "[`ProductOptionValue`](ProductOptionValue.mdx)[]",
"type": "[ProductOptionValue](ProductOptionValue.mdx)[]",
"description": "The details of the product options that this product variant defines values for.",
"optional": false,
"defaultValue": "",
@@ -1044,7 +1044,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "prices",
"type": "[`MoneyAmount`](MoneyAmount.mdx)[]",
"type": "[MoneyAmount](MoneyAmount.mdx)[]",
"description": "The details of the prices of the Product Variant, each represented as a Money Amount. Each Money Amount represents a price in a given currency or a specific Region.",
"optional": false,
"defaultValue": "",
@@ -1053,7 +1053,7 @@ A claim item is an item created as part of a claim. It references an item in the
},
{
"name": "product",
"type": "[`Product`](Product.mdx)",
"type": "[Product](Product.mdx)",
"description": "The details of the product that the product variant belongs to.",
"optional": false,
"defaultValue": "",
@@ -13,7 +13,7 @@ A Claim represents a group of faulty or missing items. It consists of claim item
<ParameterTypes parameters={[
{
"name": "additional_items",
"type": "[`LineItem`](LineItem.mdx)[]",
"type": "[LineItem](LineItem.mdx)[]",
"description": "The details of the new items to be shipped when the claim's type is `replace`",
"optional": false,
"defaultValue": "",
@@ -31,7 +31,7 @@ A Claim represents a group of faulty or missing items. It consists of claim item
},
{
"name": "claim_items",
"type": "[`ClaimItem`](ClaimItem.mdx)[]",
"type": "[ClaimItem](ClaimItem.mdx)[]",
"description": "The details of the items that should be replaced or refunded.",
"optional": false,
"defaultValue": "",
@@ -58,7 +58,7 @@ A Claim represents a group of faulty or missing items. It consists of claim item
},
{
"name": "fulfillment_status",
"type": "[`ClaimFulfillmentStatus`](../enums/ClaimFulfillmentStatus.mdx)",
"type": "[ClaimFulfillmentStatus](../enums/ClaimFulfillmentStatus.mdx)",
"description": "The claim's fulfillment status",
"optional": false,
"defaultValue": "not_fulfilled",
@@ -67,7 +67,7 @@ A Claim represents a group of faulty or missing items. It consists of claim item
},
{
"name": "fulfillments",
"type": "[`Fulfillment`](Fulfillment.mdx)[]",
"type": "[Fulfillment](Fulfillment.mdx)[]",
"description": "The fulfillments of the new items to be shipped",
"optional": false,
"defaultValue": "",
@@ -94,7 +94,7 @@ A Claim represents a group of faulty or missing items. It consists of claim item
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -112,7 +112,7 @@ A Claim represents a group of faulty or missing items. It consists of claim item
},
{
"name": "order",
"type": "[`Order`](Order.mdx)",
"type": "[Order](Order.mdx)",
"description": "The details of the order that this claim was created for.",
"optional": false,
"defaultValue": "",
@@ -130,7 +130,7 @@ A Claim represents a group of faulty or missing items. It consists of claim item
},
{
"name": "payment_status",
"type": "[`ClaimPaymentStatus`](../enums/ClaimPaymentStatus.mdx)",
"type": "[ClaimPaymentStatus](../enums/ClaimPaymentStatus.mdx)",
"description": "The status of the claim's payment",
"optional": false,
"defaultValue": "na",
@@ -148,7 +148,7 @@ A Claim represents a group of faulty or missing items. It consists of claim item
},
{
"name": "return_order",
"type": "[`Return`](Return.mdx)",
"type": "[Return](Return.mdx)",
"description": "The details of the return associated with the claim if the claim's type is `replace`.",
"optional": false,
"defaultValue": "",
@@ -157,7 +157,7 @@ A Claim represents a group of faulty or missing items. It consists of claim item
},
{
"name": "shipping_address",
"type": "[`Address`](Address.mdx)",
"type": "[Address](Address.mdx)",
"description": "The details of the address that new items should be shipped to.",
"optional": false,
"defaultValue": "",
@@ -175,7 +175,7 @@ A Claim represents a group of faulty or missing items. It consists of claim item
},
{
"name": "shipping_methods",
"type": "[`ShippingMethod`](ShippingMethod.mdx)[]",
"type": "[ShippingMethod](ShippingMethod.mdx)[]",
"description": "The details of the shipping methods that the claim order will be shipped with.",
"optional": false,
"defaultValue": "",
@@ -184,7 +184,7 @@ A Claim represents a group of faulty or missing items. It consists of claim item
},
{
"name": "type",
"type": "[`ClaimType`](../enums/ClaimType.mdx)",
"type": "[ClaimType](../enums/ClaimType.mdx)",
"description": "The claim's type",
"optional": false,
"defaultValue": "",
@@ -40,7 +40,7 @@ Claim Tags are user defined tags that can be assigned to claim items for easy fi
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -67,7 +67,7 @@ Country details
},
{
"name": "region",
"type": "[`Region`](Region.mdx)",
"type": "[Region](Region.mdx)",
"description": "The details of the region the country is associated with.",
"optional": false,
"defaultValue": "",
@@ -84,7 +84,7 @@ Country details
},
{
"name": "countries",
"type": "[`Country`](Country.mdx)[]",
"type": "[Country](Country.mdx)[]",
"description": "The details of the countries included in this region.",
"optional": false,
"defaultValue": "",
@@ -102,7 +102,7 @@ Country details
},
{
"name": "currency",
"type": "[`Currency`](Currency.mdx)",
"type": "[Currency](Currency.mdx)",
"description": "The details of the currency used in the region.",
"optional": false,
"defaultValue": "",
@@ -129,7 +129,7 @@ Country details
},
{
"name": "fulfillment_providers",
"type": "[`FulfillmentProvider`](FulfillmentProvider.mdx)[]",
"type": "[FulfillmentProvider](FulfillmentProvider.mdx)[]",
"description": "The details of the fulfillment providers that can be used to fulfill items of orders and similar resources in the region.",
"optional": false,
"defaultValue": "",
@@ -166,7 +166,7 @@ Country details
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -184,7 +184,7 @@ Country details
},
{
"name": "payment_providers",
"type": "[`PaymentProvider`](PaymentProvider.mdx)[]",
"type": "[PaymentProvider](PaymentProvider.mdx)[]",
"description": "The details of the payment providers that can be used to process payments in the region.",
"optional": false,
"defaultValue": "",
@@ -202,7 +202,7 @@ Country details
},
{
"name": "tax_provider",
"type": "[`TaxProvider`](TaxProvider.mdx)",
"type": "[TaxProvider](TaxProvider.mdx)",
"description": "The details of the tax provider used in the region.",
"optional": false,
"defaultValue": "",
@@ -229,7 +229,7 @@ Country details
},
{
"name": "tax_rates",
"type": "``null`` \\| [`TaxRate`](TaxRate.mdx)[]",
"type": "``null`` \\| [TaxRate](TaxRate.mdx)[]",
"description": "The details of the tax rates used in the region, aside from the default rate.",
"optional": false,
"defaultValue": "",
@@ -13,7 +13,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
<ParameterTypes parameters={[
{
"name": "cart",
"type": "[`Cart`](Cart.mdx)",
"type": "[Cart](Cart.mdx)",
"description": "The details of the cart this shipping option belongs to.",
"optional": false,
"defaultValue": "",
@@ -21,7 +21,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
"children": [
{
"name": "billing_address",
"type": "[`Address`](Address.mdx)",
"type": "[Address](Address.mdx)",
"description": "The details of the billing address associated with the cart.",
"optional": false,
"defaultValue": "",
@@ -48,7 +48,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "context",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "The context of the cart which can include info like IP or user agent.",
"optional": false,
"defaultValue": "",
@@ -66,7 +66,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "customer",
"type": "[`Customer`](Customer.mdx)",
"type": "[Customer](Customer.mdx)",
"description": "The details of the customer the cart belongs to.",
"optional": false,
"defaultValue": "",
@@ -102,7 +102,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "discounts",
"type": "[`Discount`](Discount.mdx)[]",
"type": "[Discount](Discount.mdx)[]",
"description": "An array of details of all discounts applied to the cart.",
"optional": false,
"defaultValue": "",
@@ -138,7 +138,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "gift_cards",
"type": "[`GiftCard`](GiftCard.mdx)[]",
"type": "[GiftCard](GiftCard.mdx)[]",
"description": "An array of details of all gift cards applied to the cart.",
"optional": false,
"defaultValue": "",
@@ -174,7 +174,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "items",
"type": "[`LineItem`](LineItem.mdx)[]",
"type": "[LineItem](LineItem.mdx)[]",
"description": "The line items added to the cart.",
"optional": false,
"defaultValue": "",
@@ -183,7 +183,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -201,7 +201,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "payment",
"type": "[`Payment`](Payment.mdx)",
"type": "[Payment](Payment.mdx)",
"description": "The details of the payment associated with the cart.",
"optional": false,
"defaultValue": "",
@@ -228,7 +228,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "payment_session",
"type": "``null`` \\| [`PaymentSession`](PaymentSession.mdx)",
"type": "``null`` \\| [PaymentSession](PaymentSession.mdx)",
"description": "The details of the selected payment session in the cart.",
"optional": false,
"defaultValue": "",
@@ -237,7 +237,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "payment_sessions",
"type": "[`PaymentSession`](PaymentSession.mdx)[]",
"type": "[PaymentSession](PaymentSession.mdx)[]",
"description": "The details of all payment sessions created on the cart.",
"optional": false,
"defaultValue": "",
@@ -273,7 +273,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "region",
"type": "[`Region`](Region.mdx)",
"type": "[Region](Region.mdx)",
"description": "The details of the region associated with the cart.",
"optional": false,
"defaultValue": "",
@@ -291,7 +291,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "sales_channel",
"type": "[`SalesChannel`](SalesChannel.mdx)",
"type": "[SalesChannel](SalesChannel.mdx)",
"description": "The details of the sales channel associated with the cart.",
"optional": false,
"defaultValue": "",
@@ -309,7 +309,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "shipping_address",
"type": "``null`` \\| [`Address`](Address.mdx)",
"type": "``null`` \\| [Address](Address.mdx)",
"description": "The details of the shipping address associated with the cart.",
"optional": false,
"defaultValue": "",
@@ -327,7 +327,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "shipping_methods",
"type": "[`ShippingMethod`](ShippingMethod.mdx)[]",
"type": "[ShippingMethod](ShippingMethod.mdx)[]",
"description": "The details of the shipping methods added to the cart.",
"optional": false,
"defaultValue": "",
@@ -381,7 +381,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "type",
"type": "[`CartType`](../enums/CartType.mdx)",
"type": "[CartType](../enums/CartType.mdx)",
"description": "The cart's type.",
"optional": false,
"defaultValue": "default",
@@ -437,7 +437,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -455,7 +455,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "shipping_option",
"type": "[`ShippingOption`](ShippingOption.mdx)",
"type": "[ShippingOption](ShippingOption.mdx)",
"description": "The details of the overridden shipping options.",
"optional": false,
"defaultValue": "",
@@ -473,7 +473,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
{
"name": "amount",
"type": "``null`` \\| `number`",
"description": "The amount to charge for shipping when the Shipping Option price type is `flat_rate`.",
"description": "The amount to charge for shipping when the Shipping Option price type is `flat\\_rate`.",
"optional": false,
"defaultValue": "",
"expandable": false,
@@ -490,7 +490,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "data",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "The data needed for the Fulfillment Provider to identify the Shipping Option.",
"optional": false,
"defaultValue": "",
@@ -536,7 +536,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -554,8 +554,8 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "price_type",
"type": "[`ShippingOptionPriceType`](../enums/ShippingOptionPriceType.mdx)",
"description": "The type of pricing calculation that is used when creatin Shipping Methods from the Shipping Option. Can be `flat_rate` for fixed prices or `calculated` if the Fulfillment Provider can provide price calulations.",
"type": "[ShippingOptionPriceType](../enums/ShippingOptionPriceType.mdx)",
"description": "The type of pricing calculation that is used when creatin Shipping Methods from the Shipping Option. Can be `flat\\_rate` for fixed prices or `calculated` if the Fulfillment Provider can provide price calulations.",
"optional": false,
"defaultValue": "",
"expandable": false,
@@ -563,7 +563,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "profile",
"type": "[`ShippingProfile`](ShippingProfile.mdx)",
"type": "[ShippingProfile](ShippingProfile.mdx)",
"description": "The details of the shipping profile that the shipping option belongs to.",
"optional": false,
"defaultValue": "",
@@ -581,7 +581,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "provider",
"type": "[`FulfillmentProvider`](FulfillmentProvider.mdx)",
"type": "[FulfillmentProvider](FulfillmentProvider.mdx)",
"description": "The details of the fulfillment provider that will be used to later to process the shipping method created from this shipping option and its fulfillments.",
"optional": false,
"defaultValue": "",
@@ -599,7 +599,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "region",
"type": "[`Region`](Region.mdx)",
"type": "[Region](Region.mdx)",
"description": "The details of the region this shipping option can be used in.",
"optional": false,
"defaultValue": "",
@@ -617,7 +617,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
},
{
"name": "requirements",
"type": "[`ShippingOptionRequirement`](ShippingOptionRequirement.mdx)[]",
"type": "[ShippingOptionRequirement](ShippingOptionRequirement.mdx)[]",
"description": "The details of the requirements that must be satisfied for the Shipping Option to be available for usage in a Cart.",
"optional": false,
"defaultValue": "",
@@ -13,7 +13,7 @@ A customer can make purchases in your store and manage their profile.
<ParameterTypes parameters={[
{
"name": "billing_address",
"type": "[`Address`](Address.mdx)",
"type": "[Address](Address.mdx)",
"description": "The details of the billing address associated with the customer.",
"optional": false,
"defaultValue": "",
@@ -57,7 +57,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "country",
"type": "``null`` \\| [`Country`](Country.mdx)",
"type": "``null`` \\| [Country](Country.mdx)",
"description": "A country object.",
"optional": false,
"defaultValue": "",
@@ -84,7 +84,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "customer",
"type": "``null`` \\| [`Customer`](Customer.mdx)",
"type": "``null`` \\| [Customer](Customer.mdx)",
"description": "Available if the relation `customer` is expanded.",
"optional": false,
"defaultValue": "",
@@ -138,7 +138,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -230,7 +230,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "groups",
"type": "[`CustomerGroup`](CustomerGroup.mdx)[]",
"type": "[CustomerGroup](CustomerGroup.mdx)[]",
"description": "The customer groups the customer belongs to.",
"optional": false,
"defaultValue": "",
@@ -247,7 +247,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "customers",
"type": "[`Customer`](Customer.mdx)[]",
"type": "[Customer](Customer.mdx)[]",
"description": "The details of the customers that belong to the customer group.",
"optional": false,
"defaultValue": "",
@@ -274,7 +274,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -292,7 +292,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "price_lists",
"type": "[`PriceList`](PriceList.mdx)[]",
"type": "[PriceList](PriceList.mdx)[]",
"description": "The price lists that are associated with the customer group.",
"optional": false,
"defaultValue": "",
@@ -339,7 +339,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -348,7 +348,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "orders",
"type": "[`Order`](Order.mdx)[]",
"type": "[Order](Order.mdx)[]",
"description": "The details of the orders this customer placed.",
"optional": false,
"defaultValue": "",
@@ -356,7 +356,7 @@ A customer can make purchases in your store and manage their profile.
"children": [
{
"name": "billing_address",
"type": "[`Address`](Address.mdx)",
"type": "[Address](Address.mdx)",
"description": "The details of the billing address associated with the order.",
"optional": false,
"defaultValue": "",
@@ -383,7 +383,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "cart",
"type": "[`Cart`](Cart.mdx)",
"type": "[Cart](Cart.mdx)",
"description": "The details of the cart associated with the order.",
"optional": false,
"defaultValue": "",
@@ -401,7 +401,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "claims",
"type": "[`ClaimOrder`](ClaimOrder.mdx)[]",
"type": "[ClaimOrder](ClaimOrder.mdx)[]",
"description": "The details of the claims created for the order.",
"optional": false,
"defaultValue": "",
@@ -419,7 +419,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "currency",
"type": "[`Currency`](Currency.mdx)",
"type": "[Currency](Currency.mdx)",
"description": "The details of the currency used in the order.",
"optional": false,
"defaultValue": "",
@@ -437,7 +437,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "customer",
"type": "[`Customer`](Customer.mdx)",
"type": "[Customer](Customer.mdx)",
"description": "The details of the customer associated with the order.",
"optional": false,
"defaultValue": "",
@@ -464,7 +464,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "discounts",
"type": "[`Discount`](Discount.mdx)[]",
"type": "[Discount](Discount.mdx)[]",
"description": "The details of the discounts applied on the order.",
"optional": false,
"defaultValue": "",
@@ -482,7 +482,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "draft_order",
"type": "[`DraftOrder`](DraftOrder.mdx)",
"type": "[DraftOrder](DraftOrder.mdx)",
"description": "The details of the draft order this order was created from.",
"optional": false,
"defaultValue": "",
@@ -500,7 +500,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "edits",
"type": "[`OrderEdit`](OrderEdit.mdx)[]",
"type": "[OrderEdit](OrderEdit.mdx)[]",
"description": "The details of the order edits done on the order.",
"optional": false,
"defaultValue": "",
@@ -527,7 +527,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "fulfillment_status",
"type": "[`FulfillmentStatus`](../enums/FulfillmentStatus.mdx)",
"type": "[FulfillmentStatus](../enums/FulfillmentStatus.mdx)",
"description": "The order's fulfillment status",
"optional": false,
"defaultValue": "not_fulfilled",
@@ -536,7 +536,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "fulfillments",
"type": "[`Fulfillment`](Fulfillment.mdx)[]",
"type": "[Fulfillment](Fulfillment.mdx)[]",
"description": "The details of the fulfillments created for the order.",
"optional": false,
"defaultValue": "",
@@ -563,7 +563,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "gift_card_transactions",
"type": "[`GiftCardTransaction`](GiftCardTransaction.mdx)[]",
"type": "[GiftCardTransaction](GiftCardTransaction.mdx)[]",
"description": "The gift card transactions made in the order.",
"optional": false,
"defaultValue": "",
@@ -572,7 +572,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "gift_cards",
"type": "[`GiftCard`](GiftCard.mdx)[]",
"type": "[GiftCard](GiftCard.mdx)[]",
"description": "The details of the gift card used in the order.",
"optional": false,
"defaultValue": "",
@@ -608,7 +608,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "items",
"type": "[`LineItem`](LineItem.mdx)[]",
"type": "[LineItem](LineItem.mdx)[]",
"description": "The details of the line items that belong to the order.",
"optional": false,
"defaultValue": "",
@@ -617,7 +617,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -653,7 +653,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "payment_status",
"type": "[`PaymentStatus`](../enums/PaymentStatus.mdx)",
"type": "[PaymentStatus](../enums/PaymentStatus.mdx)",
"description": "The order's payment status",
"optional": false,
"defaultValue": "not_paid",
@@ -662,7 +662,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "payments",
"type": "[`Payment`](Payment.mdx)[]",
"type": "[Payment](Payment.mdx)[]",
"description": "The details of the payments used in the order.",
"optional": false,
"defaultValue": "",
@@ -698,7 +698,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "refunds",
"type": "[`Refund`](Refund.mdx)[]",
"type": "[Refund](Refund.mdx)[]",
"description": "The details of the refunds created for the order.",
"optional": false,
"defaultValue": "",
@@ -707,7 +707,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "region",
"type": "[`Region`](Region.mdx)",
"type": "[Region](Region.mdx)",
"description": "The details of the region this order was created in.",
"optional": false,
"defaultValue": "",
@@ -725,7 +725,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "returnable_items",
"type": "[`LineItem`](LineItem.mdx)[]",
"type": "[LineItem](LineItem.mdx)[]",
"description": "The details of the line items that are returnable as part of the order, swaps, or claims",
"optional": true,
"defaultValue": "",
@@ -734,7 +734,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "returns",
"type": "[`Return`](Return.mdx)[]",
"type": "[Return](Return.mdx)[]",
"description": "The details of the returns created for the order.",
"optional": false,
"defaultValue": "",
@@ -743,7 +743,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "sales_channel",
"type": "[`SalesChannel`](SalesChannel.mdx)",
"type": "[SalesChannel](SalesChannel.mdx)",
"description": "The details of the sales channel this order belongs to.",
"optional": false,
"defaultValue": "",
@@ -761,7 +761,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "shipping_address",
"type": "[`Address`](Address.mdx)",
"type": "[Address](Address.mdx)",
"description": "The details of the shipping address associated with the order.",
"optional": false,
"defaultValue": "",
@@ -779,7 +779,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "shipping_methods",
"type": "[`ShippingMethod`](ShippingMethod.mdx)[]",
"type": "[ShippingMethod](ShippingMethod.mdx)[]",
"description": "The details of the shipping methods used in the order.",
"optional": false,
"defaultValue": "",
@@ -806,7 +806,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "status",
"type": "[`OrderStatus`](../enums/OrderStatus.mdx)",
"type": "[OrderStatus](../enums/OrderStatus.mdx)",
"description": "The order's status",
"optional": false,
"defaultValue": "pending",
@@ -824,7 +824,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "swaps",
"type": "[`Swap`](Swap.mdx)[]",
"type": "[Swap](Swap.mdx)[]",
"description": "The details of the swaps created for the order.",
"optional": false,
"defaultValue": "",
@@ -889,7 +889,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "shipping_addresses",
"type": "[`Address`](Address.mdx)[]",
"type": "[Address](Address.mdx)[]",
"description": "The details of the shipping addresses associated with the customer.",
"optional": false,
"defaultValue": "",
@@ -933,7 +933,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "country",
"type": "``null`` \\| [`Country`](Country.mdx)",
"type": "``null`` \\| [Country](Country.mdx)",
"description": "A country object.",
"optional": false,
"defaultValue": "",
@@ -960,7 +960,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "customer",
"type": "``null`` \\| [`Customer`](Customer.mdx)",
"type": "``null`` \\| [Customer](Customer.mdx)",
"description": "Available if the relation `customer` is expanded.",
"optional": false,
"defaultValue": "",
@@ -1014,7 +1014,7 @@ A customer can make purchases in your store and manage their profile.
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -22,7 +22,7 @@ A customer group that can be used to organize customers into groups of similar t
},
{
"name": "customers",
"type": "[`Customer`](Customer.mdx)[]",
"type": "[Customer](Customer.mdx)[]",
"description": "The details of the customers that belong to the customer group.",
"optional": false,
"defaultValue": "",
@@ -30,7 +30,7 @@ A customer group that can be used to organize customers into groups of similar t
"children": [
{
"name": "billing_address",
"type": "[`Address`](Address.mdx)",
"type": "[Address](Address.mdx)",
"description": "The details of the billing address associated with the customer.",
"optional": false,
"defaultValue": "",
@@ -84,7 +84,7 @@ A customer group that can be used to organize customers into groups of similar t
},
{
"name": "groups",
"type": "[`CustomerGroup`](CustomerGroup.mdx)[]",
"type": "[CustomerGroup](CustomerGroup.mdx)[]",
"description": "The customer groups the customer belongs to.",
"optional": false,
"defaultValue": "",
@@ -120,7 +120,7 @@ A customer group that can be used to organize customers into groups of similar t
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -129,7 +129,7 @@ A customer group that can be used to organize customers into groups of similar t
},
{
"name": "orders",
"type": "[`Order`](Order.mdx)[]",
"type": "[Order](Order.mdx)[]",
"description": "The details of the orders this customer placed.",
"optional": false,
"defaultValue": "",
@@ -156,7 +156,7 @@ A customer group that can be used to organize customers into groups of similar t
},
{
"name": "shipping_addresses",
"type": "[`Address`](Address.mdx)[]",
"type": "[Address](Address.mdx)[]",
"description": "The details of the shipping addresses associated with the customer.",
"optional": false,
"defaultValue": "",
@@ -194,7 +194,7 @@ A customer group that can be used to organize customers into groups of similar t
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -212,7 +212,7 @@ A customer group that can be used to organize customers into groups of similar t
},
{
"name": "price_lists",
"type": "[`PriceList`](PriceList.mdx)[]",
"type": "[PriceList](PriceList.mdx)[]",
"description": "The price lists that are associated with the customer group.",
"optional": false,
"defaultValue": "",
@@ -229,7 +229,7 @@ A customer group that can be used to organize customers into groups of similar t
},
{
"name": "customer_groups",
"type": "[`CustomerGroup`](CustomerGroup.mdx)[]",
"type": "[CustomerGroup](CustomerGroup.mdx)[]",
"description": "The details of the customer groups that the Price List can apply to.",
"optional": false,
"defaultValue": "",
@@ -293,7 +293,7 @@ A customer group that can be used to organize customers into groups of similar t
},
{
"name": "prices",
"type": "[`MoneyAmount`](MoneyAmount.mdx)[]",
"type": "[MoneyAmount](MoneyAmount.mdx)[]",
"description": "The prices that belong to the price list, represented as a Money Amount.",
"optional": false,
"defaultValue": "",
@@ -311,7 +311,7 @@ A customer group that can be used to organize customers into groups of similar t
},
{
"name": "status",
"type": "[`PriceListStatus`](../enums/PriceListStatus.mdx)",
"type": "[PriceListStatus](../enums/PriceListStatus.mdx)",
"description": "The status of the Price List",
"optional": false,
"defaultValue": "draft",
@@ -320,7 +320,7 @@ A customer group that can be used to organize customers into groups of similar t
},
{
"name": "type",
"type": "[`PriceListType`](../enums/PriceListType.mdx)",
"type": "[PriceListType](../enums/PriceListType.mdx)",
"description": "The type of Price List. This can be one of either `sale` or `override`.",
"optional": false,
"defaultValue": "sale",
@@ -76,7 +76,7 @@ A discount can be applied to a cart for promotional purposes.
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -85,7 +85,7 @@ A discount can be applied to a cart for promotional purposes.
},
{
"name": "parent_discount",
"type": "[`Discount`](Discount.mdx)",
"type": "[Discount](Discount.mdx)",
"description": "The details of the parent discount that this discount was created from.",
"optional": false,
"defaultValue": "",
@@ -156,7 +156,7 @@ A discount can be applied to a cart for promotional purposes.
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -165,7 +165,7 @@ A discount can be applied to a cart for promotional purposes.
},
{
"name": "parent_discount",
"type": "[`Discount`](Discount.mdx)",
"type": "[Discount](Discount.mdx)",
"description": "The details of the parent discount that this discount was created from.",
"optional": false,
"defaultValue": "",
@@ -183,7 +183,7 @@ A discount can be applied to a cart for promotional purposes.
},
{
"name": "regions",
"type": "[`Region`](Region.mdx)[]",
"type": "[Region](Region.mdx)[]",
"description": "The details of the regions in which the Discount can be used.",
"optional": false,
"defaultValue": "",
@@ -192,7 +192,7 @@ A discount can be applied to a cart for promotional purposes.
},
{
"name": "rule",
"type": "[`DiscountRule`](DiscountRule.mdx)",
"type": "[DiscountRule](DiscountRule.mdx)",
"description": "The details of the discount rule that defines how the discount will be applied to a cart..",
"optional": false,
"defaultValue": "",
@@ -266,7 +266,7 @@ A discount can be applied to a cart for promotional purposes.
},
{
"name": "regions",
"type": "[`Region`](Region.mdx)[]",
"type": "[Region](Region.mdx)[]",
"description": "The details of the regions in which the Discount can be used.",
"optional": false,
"defaultValue": "",
@@ -283,7 +283,7 @@ A discount can be applied to a cart for promotional purposes.
},
{
"name": "countries",
"type": "[`Country`](Country.mdx)[]",
"type": "[Country](Country.mdx)[]",
"description": "The details of the countries included in this region.",
"optional": false,
"defaultValue": "",
@@ -301,7 +301,7 @@ A discount can be applied to a cart for promotional purposes.
},
{
"name": "currency",
"type": "[`Currency`](Currency.mdx)",
"type": "[Currency](Currency.mdx)",
"description": "The details of the currency used in the region.",
"optional": false,
"defaultValue": "",
@@ -328,7 +328,7 @@ A discount can be applied to a cart for promotional purposes.
},
{
"name": "fulfillment_providers",
"type": "[`FulfillmentProvider`](FulfillmentProvider.mdx)[]",
"type": "[FulfillmentProvider](FulfillmentProvider.mdx)[]",
"description": "The details of the fulfillment providers that can be used to fulfill items of orders and similar resources in the region.",
"optional": false,
"defaultValue": "",
@@ -365,7 +365,7 @@ A discount can be applied to a cart for promotional purposes.
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -383,7 +383,7 @@ A discount can be applied to a cart for promotional purposes.
},
{
"name": "payment_providers",
"type": "[`PaymentProvider`](PaymentProvider.mdx)[]",
"type": "[PaymentProvider](PaymentProvider.mdx)[]",
"description": "The details of the payment providers that can be used to process payments in the region.",
"optional": false,
"defaultValue": "",
@@ -401,7 +401,7 @@ A discount can be applied to a cart for promotional purposes.
},
{
"name": "tax_provider",
"type": "[`TaxProvider`](TaxProvider.mdx)",
"type": "[TaxProvider](TaxProvider.mdx)",
"description": "The details of the tax provider used in the region.",
"optional": false,
"defaultValue": "",
@@ -428,7 +428,7 @@ A discount can be applied to a cart for promotional purposes.
},
{
"name": "tax_rates",
"type": "``null`` \\| [`TaxRate`](TaxRate.mdx)[]",
"type": "``null`` \\| [TaxRate](TaxRate.mdx)[]",
"description": "The details of the tax rates used in the region, aside from the default rate.",
"optional": false,
"defaultValue": "",
@@ -448,7 +448,7 @@ A discount can be applied to a cart for promotional purposes.
},
{
"name": "rule",
"type": "[`DiscountRule`](DiscountRule.mdx)",
"type": "[DiscountRule](DiscountRule.mdx)",
"description": "The details of the discount rule that defines how the discount will be applied to a cart..",
"optional": false,
"defaultValue": "",
@@ -456,7 +456,7 @@ A discount can be applied to a cart for promotional purposes.
"children": [
{
"name": "allocation",
"type": "[`AllocationType`](../enums/AllocationType.mdx)",
"type": "[AllocationType](../enums/AllocationType.mdx)",
"description": "The scope that the discount should apply to.",
"optional": false,
"defaultValue": "",
@@ -465,7 +465,7 @@ A discount can be applied to a cart for promotional purposes.
},
{
"name": "conditions",
"type": "[`DiscountCondition`](DiscountCondition.mdx)[]",
"type": "[DiscountCondition](DiscountCondition.mdx)[]",
"description": "The details of the discount conditions associated with the rule. They can be used to limit when the discount can be used.",
"optional": false,
"defaultValue": "",
@@ -510,7 +510,7 @@ A discount can be applied to a cart for promotional purposes.
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -519,8 +519,8 @@ A discount can be applied to a cart for promotional purposes.
},
{
"name": "type",
"type": "[`DiscountRuleType`](../enums/DiscountRuleType.mdx)",
"description": "The type of the Discount, can be `fixed` for discounts that reduce the price by a fixed amount, `percentage` for percentage reductions or `free_shipping` for shipping vouchers.",
"type": "[DiscountRuleType](../enums/DiscountRuleType.mdx)",
"description": "The type of the Discount, can be `fixed` for discounts that reduce the price by a fixed amount, `percentage` for percentage reductions or `free\\_shipping` for shipping vouchers.",
"optional": false,
"defaultValue": "",
"expandable": false,
@@ -22,8 +22,8 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "customer_groups",
"type": "[`CustomerGroup`](CustomerGroup.mdx)[]",
"description": "Customer groups associated with this condition if `type` is `customer_groups`.",
"type": "[CustomerGroup](CustomerGroup.mdx)[]",
"description": "Customer groups associated with this condition if `type` is `customer\\_groups`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -39,7 +39,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "customers",
"type": "[`Customer`](Customer.mdx)[]",
"type": "[Customer](Customer.mdx)[]",
"description": "The details of the customers that belong to the customer group.",
"optional": false,
"defaultValue": "",
@@ -66,7 +66,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -84,7 +84,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "price_lists",
"type": "[`PriceList`](PriceList.mdx)[]",
"type": "[PriceList](PriceList.mdx)[]",
"description": "The price lists that are associated with the customer group.",
"optional": false,
"defaultValue": "",
@@ -113,7 +113,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "discount_rule",
"type": "[`DiscountRule`](DiscountRule.mdx)",
"type": "[DiscountRule](DiscountRule.mdx)",
"description": "The details of the discount rule associated with the condition.",
"optional": false,
"defaultValue": "",
@@ -121,7 +121,7 @@ Holds rule conditions for when a discount is applicable
"children": [
{
"name": "allocation",
"type": "[`AllocationType`](../enums/AllocationType.mdx)",
"type": "[AllocationType](../enums/AllocationType.mdx)",
"description": "The scope that the discount should apply to.",
"optional": false,
"defaultValue": "",
@@ -130,7 +130,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "conditions",
"type": "[`DiscountCondition`](DiscountCondition.mdx)[]",
"type": "[DiscountCondition](DiscountCondition.mdx)[]",
"description": "The details of the discount conditions associated with the rule. They can be used to limit when the discount can be used.",
"optional": false,
"defaultValue": "",
@@ -175,7 +175,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -184,8 +184,8 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "type",
"type": "[`DiscountRuleType`](../enums/DiscountRuleType.mdx)",
"description": "The type of the Discount, can be `fixed` for discounts that reduce the price by a fixed amount, `percentage` for percentage reductions or `free_shipping` for shipping vouchers.",
"type": "[DiscountRuleType](../enums/DiscountRuleType.mdx)",
"description": "The type of the Discount, can be `fixed` for discounts that reduce the price by a fixed amount, `percentage` for percentage reductions or `free\\_shipping` for shipping vouchers.",
"optional": false,
"defaultValue": "",
"expandable": false,
@@ -231,7 +231,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -240,8 +240,8 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "operator",
"type": "[`DiscountConditionOperator`](../enums/DiscountConditionOperator.mdx)",
"description": "The operator of the condition. `in` indicates that discountable resources are within the specified resources. `not_in` indicates that discountable resources are everything but the specified resources.",
"type": "[DiscountConditionOperator](../enums/DiscountConditionOperator.mdx)",
"description": "The operator of the condition. `in` indicates that discountable resources are within the specified resources. `not\\_in` indicates that discountable resources are everything but the specified resources.",
"optional": false,
"defaultValue": "",
"expandable": false,
@@ -268,8 +268,8 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "product_collections",
"type": "[`ProductCollection`](ProductCollection.mdx)[]",
"description": "Product collections associated with this condition if `type` is `product_collections`.",
"type": "[ProductCollection](ProductCollection.mdx)[]",
"description": "Product collections associated with this condition if `type` is `product\\_collections`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -312,7 +312,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -321,7 +321,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "products",
"type": "[`Product`](Product.mdx)[]",
"type": "[Product](Product.mdx)[]",
"description": "The details of the products that belong to this product collection.",
"optional": false,
"defaultValue": "",
@@ -350,8 +350,8 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "product_tags",
"type": "[`ProductTag`](ProductTag.mdx)[]",
"description": "Product tags associated with this condition if `type` is `product_tags`.",
"type": "[ProductTag](ProductTag.mdx)[]",
"description": "Product tags associated with this condition if `type` is `product\\_tags`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -385,7 +385,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -414,8 +414,8 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "product_types",
"type": "[`ProductType`](ProductType.mdx)[]",
"description": "Product types associated with this condition if `type` is `product_types`.",
"type": "[ProductType](ProductType.mdx)[]",
"description": "Product types associated with this condition if `type` is `product\\_types`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -449,7 +449,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -478,7 +478,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "products",
"type": "[`Product`](Product.mdx)[]",
"type": "[Product](Product.mdx)[]",
"description": "products associated with this condition if `type` is `products`.",
"optional": false,
"defaultValue": "",
@@ -486,7 +486,7 @@ Holds rule conditions for when a discount is applicable
"children": [
{
"name": "categories",
"type": "[`ProductCategory`](ProductCategory.mdx)[]",
"type": "[ProductCategory](ProductCategory.mdx)[]",
"description": "The details of the product categories that this product belongs to.",
"optional": false,
"defaultValue": "",
@@ -496,7 +496,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "collection",
"type": "[`ProductCollection`](ProductCollection.mdx)",
"type": "[ProductCollection](ProductCollection.mdx)",
"description": "The details of the product collection that the product belongs to.",
"optional": false,
"defaultValue": "",
@@ -595,7 +595,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "images",
"type": "[`Image`](Image.mdx)[]",
"type": "[Image](Image.mdx)[]",
"description": "The details of the product's images.",
"optional": false,
"defaultValue": "",
@@ -631,7 +631,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "metadata",
"type": "``null`` \\| Record<`string`, `unknown`\\>",
"type": "``null`` \\| `Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -649,7 +649,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "options",
"type": "[`ProductOption`](ProductOption.mdx)[]",
"type": "[ProductOption](ProductOption.mdx)[]",
"description": "The details of the Product Options that are defined for the Product. The product's variants will have a unique combination of values of the product's options.",
"optional": false,
"defaultValue": "",
@@ -667,7 +667,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "profile",
"type": "[`ShippingProfile`](ShippingProfile.mdx)",
"type": "[ShippingProfile](ShippingProfile.mdx)",
"description": "The details of the shipping profile that the product belongs to. The shipping profile has a set of defined shipping options that can be used to fulfill the product.",
"optional": false,
"defaultValue": "",
@@ -685,7 +685,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "profiles",
"type": "[`ShippingProfile`](ShippingProfile.mdx)[]",
"type": "[ShippingProfile](ShippingProfile.mdx)[]",
"description": "Available if the relation `profiles` is expanded.",
"optional": false,
"defaultValue": "",
@@ -694,7 +694,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "sales_channels",
"type": "[`SalesChannel`](SalesChannel.mdx)[]",
"type": "[SalesChannel](SalesChannel.mdx)[]",
"description": "The details of the sales channels this product is available in.",
"optional": false,
"defaultValue": "",
@@ -703,7 +703,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "status",
"type": "[`ProductStatus`](../enums/ProductStatus.mdx)",
"type": "[ProductStatus](../enums/ProductStatus.mdx)",
"description": "The status of the product",
"optional": false,
"defaultValue": "draft",
@@ -721,7 +721,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "tags",
"type": "[`ProductTag`](ProductTag.mdx)[]",
"type": "[ProductTag](ProductTag.mdx)[]",
"description": "The details of the product tags used in this product.",
"optional": false,
"defaultValue": "",
@@ -748,7 +748,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "type",
"type": "[`ProductType`](ProductType.mdx)",
"type": "[ProductType](ProductType.mdx)",
"description": "The details of the product type that the product belongs to.",
"optional": false,
"defaultValue": "",
@@ -775,7 +775,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "variants",
"type": "[`ProductVariant`](ProductVariant.mdx)[]",
"type": "[ProductVariant](ProductVariant.mdx)[]",
"description": "The details of the Product Variants that belong to the Product. Each will have a unique combination of values of the product's options.",
"optional": false,
"defaultValue": "",
@@ -804,7 +804,7 @@ Holds rule conditions for when a discount is applicable
},
{
"name": "type",
"type": "[`DiscountConditionType`](../enums/DiscountConditionType.mdx)",
"type": "[DiscountConditionType](../enums/DiscountConditionType.mdx)",
"description": "The type of the condition. The type affects the available resources associated with the condition. For example, if the type is `products`, that means the `products` relation will hold the products associated with this condition and other relations will be empty.",
"optional": false,
"defaultValue": "",
@@ -31,8 +31,8 @@ Associates a discount condition with a customer group
},
{
"name": "customer_group",
"type": "[`CustomerGroup`](CustomerGroup.mdx)",
"description": "Available if the relation `customer_group` is expanded.",
"type": "[CustomerGroup](CustomerGroup.mdx)",
"description": "Available if the relation `customer\\_group` is expanded.",
"optional": true,
"defaultValue": "",
"expandable": false,
@@ -48,7 +48,7 @@ Associates a discount condition with a customer group
},
{
"name": "customers",
"type": "[`Customer`](Customer.mdx)[]",
"type": "[Customer](Customer.mdx)[]",
"description": "The details of the customers that belong to the customer group.",
"optional": false,
"defaultValue": "",
@@ -75,7 +75,7 @@ Associates a discount condition with a customer group
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -93,7 +93,7 @@ Associates a discount condition with a customer group
},
{
"name": "price_lists",
"type": "[`PriceList`](PriceList.mdx)[]",
"type": "[PriceList](PriceList.mdx)[]",
"description": "The price lists that are associated with the customer group.",
"optional": false,
"defaultValue": "",
@@ -122,8 +122,8 @@ Associates a discount condition with a customer group
},
{
"name": "discount_condition",
"type": "[`DiscountCondition`](DiscountCondition.mdx)",
"description": "Available if the relation `discount_condition` is expanded.",
"type": "[DiscountCondition](DiscountCondition.mdx)",
"description": "Available if the relation `discount\\_condition` is expanded.",
"optional": true,
"defaultValue": "",
"expandable": false,
@@ -139,8 +139,8 @@ Associates a discount condition with a customer group
},
{
"name": "customer_groups",
"type": "[`CustomerGroup`](CustomerGroup.mdx)[]",
"description": "Customer groups associated with this condition if `type` is `customer_groups`.",
"type": "[CustomerGroup](CustomerGroup.mdx)[]",
"description": "Customer groups associated with this condition if `type` is `customer\\_groups`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -157,7 +157,7 @@ Associates a discount condition with a customer group
},
{
"name": "discount_rule",
"type": "[`DiscountRule`](DiscountRule.mdx)",
"type": "[DiscountRule](DiscountRule.mdx)",
"description": "The details of the discount rule associated with the condition.",
"optional": false,
"defaultValue": "",
@@ -184,7 +184,7 @@ Associates a discount condition with a customer group
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -193,8 +193,8 @@ Associates a discount condition with a customer group
},
{
"name": "operator",
"type": "[`DiscountConditionOperator`](../enums/DiscountConditionOperator.mdx)",
"description": "The operator of the condition. `in` indicates that discountable resources are within the specified resources. `not_in` indicates that discountable resources are everything but the specified resources.",
"type": "[DiscountConditionOperator](../enums/DiscountConditionOperator.mdx)",
"description": "The operator of the condition. `in` indicates that discountable resources are within the specified resources. `not\\_in` indicates that discountable resources are everything but the specified resources.",
"optional": false,
"defaultValue": "",
"expandable": false,
@@ -202,8 +202,8 @@ Associates a discount condition with a customer group
},
{
"name": "product_collections",
"type": "[`ProductCollection`](ProductCollection.mdx)[]",
"description": "Product collections associated with this condition if `type` is `product_collections`.",
"type": "[ProductCollection](ProductCollection.mdx)[]",
"description": "Product collections associated with this condition if `type` is `product\\_collections`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -211,8 +211,8 @@ Associates a discount condition with a customer group
},
{
"name": "product_tags",
"type": "[`ProductTag`](ProductTag.mdx)[]",
"description": "Product tags associated with this condition if `type` is `product_tags`.",
"type": "[ProductTag](ProductTag.mdx)[]",
"description": "Product tags associated with this condition if `type` is `product\\_tags`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -220,8 +220,8 @@ Associates a discount condition with a customer group
},
{
"name": "product_types",
"type": "[`ProductType`](ProductType.mdx)[]",
"description": "Product types associated with this condition if `type` is `product_types`.",
"type": "[ProductType](ProductType.mdx)[]",
"description": "Product types associated with this condition if `type` is `product\\_types`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -229,7 +229,7 @@ Associates a discount condition with a customer group
},
{
"name": "products",
"type": "[`Product`](Product.mdx)[]",
"type": "[Product](Product.mdx)[]",
"description": "products associated with this condition if `type` is `products`.",
"optional": false,
"defaultValue": "",
@@ -238,7 +238,7 @@ Associates a discount condition with a customer group
},
{
"name": "type",
"type": "[`DiscountConditionType`](../enums/DiscountConditionType.mdx)",
"type": "[DiscountConditionType](../enums/DiscountConditionType.mdx)",
"description": "The type of the condition. The type affects the available resources associated with the condition. For example, if the type is `products`, that means the `products` relation will hold the products associated with this condition and other relations will be empty.",
"optional": false,
"defaultValue": "",
@@ -258,7 +258,7 @@ Associates a discount condition with a customer group
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -31,7 +31,7 @@ This represents the association between a discount condition and a product
},
{
"name": "discount_condition",
"type": "[`DiscountCondition`](DiscountCondition.mdx)",
"type": "[DiscountCondition](DiscountCondition.mdx)",
"description": "The details of the discount condition.",
"optional": true,
"defaultValue": "",
@@ -48,8 +48,8 @@ This represents the association between a discount condition and a product
},
{
"name": "customer_groups",
"type": "[`CustomerGroup`](CustomerGroup.mdx)[]",
"description": "Customer groups associated with this condition if `type` is `customer_groups`.",
"type": "[CustomerGroup](CustomerGroup.mdx)[]",
"description": "Customer groups associated with this condition if `type` is `customer\\_groups`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -66,7 +66,7 @@ This represents the association between a discount condition and a product
},
{
"name": "discount_rule",
"type": "[`DiscountRule`](DiscountRule.mdx)",
"type": "[DiscountRule](DiscountRule.mdx)",
"description": "The details of the discount rule associated with the condition.",
"optional": false,
"defaultValue": "",
@@ -93,7 +93,7 @@ This represents the association between a discount condition and a product
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -102,8 +102,8 @@ This represents the association between a discount condition and a product
},
{
"name": "operator",
"type": "[`DiscountConditionOperator`](../enums/DiscountConditionOperator.mdx)",
"description": "The operator of the condition. `in` indicates that discountable resources are within the specified resources. `not_in` indicates that discountable resources are everything but the specified resources.",
"type": "[DiscountConditionOperator](../enums/DiscountConditionOperator.mdx)",
"description": "The operator of the condition. `in` indicates that discountable resources are within the specified resources. `not\\_in` indicates that discountable resources are everything but the specified resources.",
"optional": false,
"defaultValue": "",
"expandable": false,
@@ -111,8 +111,8 @@ This represents the association between a discount condition and a product
},
{
"name": "product_collections",
"type": "[`ProductCollection`](ProductCollection.mdx)[]",
"description": "Product collections associated with this condition if `type` is `product_collections`.",
"type": "[ProductCollection](ProductCollection.mdx)[]",
"description": "Product collections associated with this condition if `type` is `product\\_collections`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -120,8 +120,8 @@ This represents the association between a discount condition and a product
},
{
"name": "product_tags",
"type": "[`ProductTag`](ProductTag.mdx)[]",
"description": "Product tags associated with this condition if `type` is `product_tags`.",
"type": "[ProductTag](ProductTag.mdx)[]",
"description": "Product tags associated with this condition if `type` is `product\\_tags`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -129,8 +129,8 @@ This represents the association between a discount condition and a product
},
{
"name": "product_types",
"type": "[`ProductType`](ProductType.mdx)[]",
"description": "Product types associated with this condition if `type` is `product_types`.",
"type": "[ProductType](ProductType.mdx)[]",
"description": "Product types associated with this condition if `type` is `product\\_types`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -138,7 +138,7 @@ This represents the association between a discount condition and a product
},
{
"name": "products",
"type": "[`Product`](Product.mdx)[]",
"type": "[Product](Product.mdx)[]",
"description": "products associated with this condition if `type` is `products`.",
"optional": false,
"defaultValue": "",
@@ -147,7 +147,7 @@ This represents the association between a discount condition and a product
},
{
"name": "type",
"type": "[`DiscountConditionType`](../enums/DiscountConditionType.mdx)",
"type": "[DiscountConditionType](../enums/DiscountConditionType.mdx)",
"description": "The type of the condition. The type affects the available resources associated with the condition. For example, if the type is `products`, that means the `products` relation will hold the products associated with this condition and other relations will be empty.",
"optional": false,
"defaultValue": "",
@@ -167,7 +167,7 @@ This represents the association between a discount condition and a product
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -176,7 +176,7 @@ This represents the association between a discount condition and a product
},
{
"name": "product",
"type": "[`Product`](Product.mdx)",
"type": "[Product](Product.mdx)",
"description": "The details of the product.",
"optional": true,
"defaultValue": "",
@@ -184,7 +184,7 @@ This represents the association between a discount condition and a product
"children": [
{
"name": "categories",
"type": "[`ProductCategory`](ProductCategory.mdx)[]",
"type": "[ProductCategory](ProductCategory.mdx)[]",
"description": "The details of the product categories that this product belongs to.",
"optional": false,
"defaultValue": "",
@@ -194,7 +194,7 @@ This represents the association between a discount condition and a product
},
{
"name": "collection",
"type": "[`ProductCollection`](ProductCollection.mdx)",
"type": "[ProductCollection](ProductCollection.mdx)",
"description": "The details of the product collection that the product belongs to.",
"optional": false,
"defaultValue": "",
@@ -293,7 +293,7 @@ This represents the association between a discount condition and a product
},
{
"name": "images",
"type": "[`Image`](Image.mdx)[]",
"type": "[Image](Image.mdx)[]",
"description": "The details of the product's images.",
"optional": false,
"defaultValue": "",
@@ -329,7 +329,7 @@ This represents the association between a discount condition and a product
},
{
"name": "metadata",
"type": "``null`` \\| Record<`string`, `unknown`\\>",
"type": "``null`` \\| `Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -347,7 +347,7 @@ This represents the association between a discount condition and a product
},
{
"name": "options",
"type": "[`ProductOption`](ProductOption.mdx)[]",
"type": "[ProductOption](ProductOption.mdx)[]",
"description": "The details of the Product Options that are defined for the Product. The product's variants will have a unique combination of values of the product's options.",
"optional": false,
"defaultValue": "",
@@ -365,7 +365,7 @@ This represents the association between a discount condition and a product
},
{
"name": "profile",
"type": "[`ShippingProfile`](ShippingProfile.mdx)",
"type": "[ShippingProfile](ShippingProfile.mdx)",
"description": "The details of the shipping profile that the product belongs to. The shipping profile has a set of defined shipping options that can be used to fulfill the product.",
"optional": false,
"defaultValue": "",
@@ -383,7 +383,7 @@ This represents the association between a discount condition and a product
},
{
"name": "profiles",
"type": "[`ShippingProfile`](ShippingProfile.mdx)[]",
"type": "[ShippingProfile](ShippingProfile.mdx)[]",
"description": "Available if the relation `profiles` is expanded.",
"optional": false,
"defaultValue": "",
@@ -392,7 +392,7 @@ This represents the association between a discount condition and a product
},
{
"name": "sales_channels",
"type": "[`SalesChannel`](SalesChannel.mdx)[]",
"type": "[SalesChannel](SalesChannel.mdx)[]",
"description": "The details of the sales channels this product is available in.",
"optional": false,
"defaultValue": "",
@@ -401,7 +401,7 @@ This represents the association between a discount condition and a product
},
{
"name": "status",
"type": "[`ProductStatus`](../enums/ProductStatus.mdx)",
"type": "[ProductStatus](../enums/ProductStatus.mdx)",
"description": "The status of the product",
"optional": false,
"defaultValue": "draft",
@@ -419,7 +419,7 @@ This represents the association between a discount condition and a product
},
{
"name": "tags",
"type": "[`ProductTag`](ProductTag.mdx)[]",
"type": "[ProductTag](ProductTag.mdx)[]",
"description": "The details of the product tags used in this product.",
"optional": false,
"defaultValue": "",
@@ -446,7 +446,7 @@ This represents the association between a discount condition and a product
},
{
"name": "type",
"type": "[`ProductType`](ProductType.mdx)",
"type": "[ProductType](ProductType.mdx)",
"description": "The details of the product type that the product belongs to.",
"optional": false,
"defaultValue": "",
@@ -473,7 +473,7 @@ This represents the association between a discount condition and a product
},
{
"name": "variants",
"type": "[`ProductVariant`](ProductVariant.mdx)[]",
"type": "[ProductVariant](ProductVariant.mdx)[]",
"description": "The details of the Product Variants that belong to the Product. Each will have a unique combination of values of the product's options.",
"optional": false,
"defaultValue": "",
@@ -31,7 +31,7 @@ This represents the association between a discount condition and a product colle
},
{
"name": "discount_condition",
"type": "[`DiscountCondition`](DiscountCondition.mdx)",
"type": "[DiscountCondition](DiscountCondition.mdx)",
"description": "The details of the discount condition.",
"optional": true,
"defaultValue": "",
@@ -48,8 +48,8 @@ This represents the association between a discount condition and a product colle
},
{
"name": "customer_groups",
"type": "[`CustomerGroup`](CustomerGroup.mdx)[]",
"description": "Customer groups associated with this condition if `type` is `customer_groups`.",
"type": "[CustomerGroup](CustomerGroup.mdx)[]",
"description": "Customer groups associated with this condition if `type` is `customer\\_groups`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -66,7 +66,7 @@ This represents the association between a discount condition and a product colle
},
{
"name": "discount_rule",
"type": "[`DiscountRule`](DiscountRule.mdx)",
"type": "[DiscountRule](DiscountRule.mdx)",
"description": "The details of the discount rule associated with the condition.",
"optional": false,
"defaultValue": "",
@@ -93,7 +93,7 @@ This represents the association between a discount condition and a product colle
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -102,8 +102,8 @@ This represents the association between a discount condition and a product colle
},
{
"name": "operator",
"type": "[`DiscountConditionOperator`](../enums/DiscountConditionOperator.mdx)",
"description": "The operator of the condition. `in` indicates that discountable resources are within the specified resources. `not_in` indicates that discountable resources are everything but the specified resources.",
"type": "[DiscountConditionOperator](../enums/DiscountConditionOperator.mdx)",
"description": "The operator of the condition. `in` indicates that discountable resources are within the specified resources. `not\\_in` indicates that discountable resources are everything but the specified resources.",
"optional": false,
"defaultValue": "",
"expandable": false,
@@ -111,8 +111,8 @@ This represents the association between a discount condition and a product colle
},
{
"name": "product_collections",
"type": "[`ProductCollection`](ProductCollection.mdx)[]",
"description": "Product collections associated with this condition if `type` is `product_collections`.",
"type": "[ProductCollection](ProductCollection.mdx)[]",
"description": "Product collections associated with this condition if `type` is `product\\_collections`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -120,8 +120,8 @@ This represents the association between a discount condition and a product colle
},
{
"name": "product_tags",
"type": "[`ProductTag`](ProductTag.mdx)[]",
"description": "Product tags associated with this condition if `type` is `product_tags`.",
"type": "[ProductTag](ProductTag.mdx)[]",
"description": "Product tags associated with this condition if `type` is `product\\_tags`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -129,8 +129,8 @@ This represents the association between a discount condition and a product colle
},
{
"name": "product_types",
"type": "[`ProductType`](ProductType.mdx)[]",
"description": "Product types associated with this condition if `type` is `product_types`.",
"type": "[ProductType](ProductType.mdx)[]",
"description": "Product types associated with this condition if `type` is `product\\_types`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -138,7 +138,7 @@ This represents the association between a discount condition and a product colle
},
{
"name": "products",
"type": "[`Product`](Product.mdx)[]",
"type": "[Product](Product.mdx)[]",
"description": "products associated with this condition if `type` is `products`.",
"optional": false,
"defaultValue": "",
@@ -147,7 +147,7 @@ This represents the association between a discount condition and a product colle
},
{
"name": "type",
"type": "[`DiscountConditionType`](../enums/DiscountConditionType.mdx)",
"type": "[DiscountConditionType](../enums/DiscountConditionType.mdx)",
"description": "The type of the condition. The type affects the available resources associated with the condition. For example, if the type is `products`, that means the `products` relation will hold the products associated with this condition and other relations will be empty.",
"optional": false,
"defaultValue": "",
@@ -167,7 +167,7 @@ This represents the association between a discount condition and a product colle
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -176,7 +176,7 @@ This represents the association between a discount condition and a product colle
},
{
"name": "product_collection",
"type": "[`ProductCollection`](ProductCollection.mdx)",
"type": "[ProductCollection](ProductCollection.mdx)",
"description": "The details of the product collection.",
"optional": true,
"defaultValue": "",
@@ -220,7 +220,7 @@ This represents the association between a discount condition and a product colle
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -229,7 +229,7 @@ This represents the association between a discount condition and a product colle
},
{
"name": "products",
"type": "[`Product`](Product.mdx)[]",
"type": "[Product](Product.mdx)[]",
"description": "The details of the products that belong to this product collection.",
"optional": false,
"defaultValue": "",
@@ -31,7 +31,7 @@ This represents the association between a discount condition and a product tag
},
{
"name": "discount_condition",
"type": "[`DiscountCondition`](DiscountCondition.mdx)",
"type": "[DiscountCondition](DiscountCondition.mdx)",
"description": "The details of the discount condition.",
"optional": true,
"defaultValue": "",
@@ -48,8 +48,8 @@ This represents the association between a discount condition and a product tag
},
{
"name": "customer_groups",
"type": "[`CustomerGroup`](CustomerGroup.mdx)[]",
"description": "Customer groups associated with this condition if `type` is `customer_groups`.",
"type": "[CustomerGroup](CustomerGroup.mdx)[]",
"description": "Customer groups associated with this condition if `type` is `customer\\_groups`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -66,7 +66,7 @@ This represents the association between a discount condition and a product tag
},
{
"name": "discount_rule",
"type": "[`DiscountRule`](DiscountRule.mdx)",
"type": "[DiscountRule](DiscountRule.mdx)",
"description": "The details of the discount rule associated with the condition.",
"optional": false,
"defaultValue": "",
@@ -93,7 +93,7 @@ This represents the association between a discount condition and a product tag
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -102,8 +102,8 @@ This represents the association between a discount condition and a product tag
},
{
"name": "operator",
"type": "[`DiscountConditionOperator`](../enums/DiscountConditionOperator.mdx)",
"description": "The operator of the condition. `in` indicates that discountable resources are within the specified resources. `not_in` indicates that discountable resources are everything but the specified resources.",
"type": "[DiscountConditionOperator](../enums/DiscountConditionOperator.mdx)",
"description": "The operator of the condition. `in` indicates that discountable resources are within the specified resources. `not\\_in` indicates that discountable resources are everything but the specified resources.",
"optional": false,
"defaultValue": "",
"expandable": false,
@@ -111,8 +111,8 @@ This represents the association between a discount condition and a product tag
},
{
"name": "product_collections",
"type": "[`ProductCollection`](ProductCollection.mdx)[]",
"description": "Product collections associated with this condition if `type` is `product_collections`.",
"type": "[ProductCollection](ProductCollection.mdx)[]",
"description": "Product collections associated with this condition if `type` is `product\\_collections`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -120,8 +120,8 @@ This represents the association between a discount condition and a product tag
},
{
"name": "product_tags",
"type": "[`ProductTag`](ProductTag.mdx)[]",
"description": "Product tags associated with this condition if `type` is `product_tags`.",
"type": "[ProductTag](ProductTag.mdx)[]",
"description": "Product tags associated with this condition if `type` is `product\\_tags`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -129,8 +129,8 @@ This represents the association between a discount condition and a product tag
},
{
"name": "product_types",
"type": "[`ProductType`](ProductType.mdx)[]",
"description": "Product types associated with this condition if `type` is `product_types`.",
"type": "[ProductType](ProductType.mdx)[]",
"description": "Product types associated with this condition if `type` is `product\\_types`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -138,7 +138,7 @@ This represents the association between a discount condition and a product tag
},
{
"name": "products",
"type": "[`Product`](Product.mdx)[]",
"type": "[Product](Product.mdx)[]",
"description": "products associated with this condition if `type` is `products`.",
"optional": false,
"defaultValue": "",
@@ -147,7 +147,7 @@ This represents the association between a discount condition and a product tag
},
{
"name": "type",
"type": "[`DiscountConditionType`](../enums/DiscountConditionType.mdx)",
"type": "[DiscountConditionType](../enums/DiscountConditionType.mdx)",
"description": "The type of the condition. The type affects the available resources associated with the condition. For example, if the type is `products`, that means the `products` relation will hold the products associated with this condition and other relations will be empty.",
"optional": false,
"defaultValue": "",
@@ -167,7 +167,7 @@ This represents the association between a discount condition and a product tag
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -176,7 +176,7 @@ This represents the association between a discount condition and a product tag
},
{
"name": "product_tag",
"type": "[`ProductTag`](ProductTag.mdx)",
"type": "[ProductTag](ProductTag.mdx)",
"description": "The details of the product tag.",
"optional": true,
"defaultValue": "",
@@ -211,7 +211,7 @@ This represents the association between a discount condition and a product tag
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -31,7 +31,7 @@ This represents the association between a discount condition and a product type
},
{
"name": "discount_condition",
"type": "[`DiscountCondition`](DiscountCondition.mdx)",
"type": "[DiscountCondition](DiscountCondition.mdx)",
"description": "The details of the discount condition.",
"optional": true,
"defaultValue": "",
@@ -48,8 +48,8 @@ This represents the association between a discount condition and a product type
},
{
"name": "customer_groups",
"type": "[`CustomerGroup`](CustomerGroup.mdx)[]",
"description": "Customer groups associated with this condition if `type` is `customer_groups`.",
"type": "[CustomerGroup](CustomerGroup.mdx)[]",
"description": "Customer groups associated with this condition if `type` is `customer\\_groups`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -66,7 +66,7 @@ This represents the association between a discount condition and a product type
},
{
"name": "discount_rule",
"type": "[`DiscountRule`](DiscountRule.mdx)",
"type": "[DiscountRule](DiscountRule.mdx)",
"description": "The details of the discount rule associated with the condition.",
"optional": false,
"defaultValue": "",
@@ -93,7 +93,7 @@ This represents the association between a discount condition and a product type
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -102,8 +102,8 @@ This represents the association between a discount condition and a product type
},
{
"name": "operator",
"type": "[`DiscountConditionOperator`](../enums/DiscountConditionOperator.mdx)",
"description": "The operator of the condition. `in` indicates that discountable resources are within the specified resources. `not_in` indicates that discountable resources are everything but the specified resources.",
"type": "[DiscountConditionOperator](../enums/DiscountConditionOperator.mdx)",
"description": "The operator of the condition. `in` indicates that discountable resources are within the specified resources. `not\\_in` indicates that discountable resources are everything but the specified resources.",
"optional": false,
"defaultValue": "",
"expandable": false,
@@ -111,8 +111,8 @@ This represents the association between a discount condition and a product type
},
{
"name": "product_collections",
"type": "[`ProductCollection`](ProductCollection.mdx)[]",
"description": "Product collections associated with this condition if `type` is `product_collections`.",
"type": "[ProductCollection](ProductCollection.mdx)[]",
"description": "Product collections associated with this condition if `type` is `product\\_collections`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -120,8 +120,8 @@ This represents the association between a discount condition and a product type
},
{
"name": "product_tags",
"type": "[`ProductTag`](ProductTag.mdx)[]",
"description": "Product tags associated with this condition if `type` is `product_tags`.",
"type": "[ProductTag](ProductTag.mdx)[]",
"description": "Product tags associated with this condition if `type` is `product\\_tags`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -129,8 +129,8 @@ This represents the association between a discount condition and a product type
},
{
"name": "product_types",
"type": "[`ProductType`](ProductType.mdx)[]",
"description": "Product types associated with this condition if `type` is `product_types`.",
"type": "[ProductType](ProductType.mdx)[]",
"description": "Product types associated with this condition if `type` is `product\\_types`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -138,7 +138,7 @@ This represents the association between a discount condition and a product type
},
{
"name": "products",
"type": "[`Product`](Product.mdx)[]",
"type": "[Product](Product.mdx)[]",
"description": "products associated with this condition if `type` is `products`.",
"optional": false,
"defaultValue": "",
@@ -147,7 +147,7 @@ This represents the association between a discount condition and a product type
},
{
"name": "type",
"type": "[`DiscountConditionType`](../enums/DiscountConditionType.mdx)",
"type": "[DiscountConditionType](../enums/DiscountConditionType.mdx)",
"description": "The type of the condition. The type affects the available resources associated with the condition. For example, if the type is `products`, that means the `products` relation will hold the products associated with this condition and other relations will be empty.",
"optional": false,
"defaultValue": "",
@@ -167,7 +167,7 @@ This represents the association between a discount condition and a product type
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -176,7 +176,7 @@ This represents the association between a discount condition and a product type
},
{
"name": "product_type",
"type": "[`ProductType`](ProductType.mdx)",
"type": "[ProductType](ProductType.mdx)",
"description": "The details of the product type.",
"optional": true,
"defaultValue": "",
@@ -211,7 +211,7 @@ This represents the association between a discount condition and a product type
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -13,7 +13,7 @@ A discount rule defines how a Discount is calculated when applied to a Cart.
<ParameterTypes parameters={[
{
"name": "allocation",
"type": "[`AllocationType`](../enums/AllocationType.mdx)",
"type": "[AllocationType](../enums/AllocationType.mdx)",
"description": "The scope that the discount should apply to.",
"optional": false,
"defaultValue": "",
@@ -41,7 +41,7 @@ A discount rule defines how a Discount is calculated when applied to a Cart.
},
{
"name": "conditions",
"type": "[`DiscountCondition`](DiscountCondition.mdx)[]",
"type": "[DiscountCondition](DiscountCondition.mdx)[]",
"description": "The details of the discount conditions associated with the rule. They can be used to limit when the discount can be used.",
"optional": false,
"defaultValue": "",
@@ -58,8 +58,8 @@ A discount rule defines how a Discount is calculated when applied to a Cart.
},
{
"name": "customer_groups",
"type": "[`CustomerGroup`](CustomerGroup.mdx)[]",
"description": "Customer groups associated with this condition if `type` is `customer_groups`.",
"type": "[CustomerGroup](CustomerGroup.mdx)[]",
"description": "Customer groups associated with this condition if `type` is `customer\\_groups`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -76,7 +76,7 @@ A discount rule defines how a Discount is calculated when applied to a Cart.
},
{
"name": "discount_rule",
"type": "[`DiscountRule`](DiscountRule.mdx)",
"type": "[DiscountRule](DiscountRule.mdx)",
"description": "The details of the discount rule associated with the condition.",
"optional": false,
"defaultValue": "",
@@ -103,7 +103,7 @@ A discount rule defines how a Discount is calculated when applied to a Cart.
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -112,8 +112,8 @@ A discount rule defines how a Discount is calculated when applied to a Cart.
},
{
"name": "operator",
"type": "[`DiscountConditionOperator`](../enums/DiscountConditionOperator.mdx)",
"description": "The operator of the condition. `in` indicates that discountable resources are within the specified resources. `not_in` indicates that discountable resources are everything but the specified resources.",
"type": "[DiscountConditionOperator](../enums/DiscountConditionOperator.mdx)",
"description": "The operator of the condition. `in` indicates that discountable resources are within the specified resources. `not\\_in` indicates that discountable resources are everything but the specified resources.",
"optional": false,
"defaultValue": "",
"expandable": false,
@@ -121,8 +121,8 @@ A discount rule defines how a Discount is calculated when applied to a Cart.
},
{
"name": "product_collections",
"type": "[`ProductCollection`](ProductCollection.mdx)[]",
"description": "Product collections associated with this condition if `type` is `product_collections`.",
"type": "[ProductCollection](ProductCollection.mdx)[]",
"description": "Product collections associated with this condition if `type` is `product\\_collections`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -130,8 +130,8 @@ A discount rule defines how a Discount is calculated when applied to a Cart.
},
{
"name": "product_tags",
"type": "[`ProductTag`](ProductTag.mdx)[]",
"description": "Product tags associated with this condition if `type` is `product_tags`.",
"type": "[ProductTag](ProductTag.mdx)[]",
"description": "Product tags associated with this condition if `type` is `product\\_tags`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -139,8 +139,8 @@ A discount rule defines how a Discount is calculated when applied to a Cart.
},
{
"name": "product_types",
"type": "[`ProductType`](ProductType.mdx)[]",
"description": "Product types associated with this condition if `type` is `product_types`.",
"type": "[ProductType](ProductType.mdx)[]",
"description": "Product types associated with this condition if `type` is `product\\_types`.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -148,7 +148,7 @@ A discount rule defines how a Discount is calculated when applied to a Cart.
},
{
"name": "products",
"type": "[`Product`](Product.mdx)[]",
"type": "[Product](Product.mdx)[]",
"description": "products associated with this condition if `type` is `products`.",
"optional": false,
"defaultValue": "",
@@ -157,7 +157,7 @@ A discount rule defines how a Discount is calculated when applied to a Cart.
},
{
"name": "type",
"type": "[`DiscountConditionType`](../enums/DiscountConditionType.mdx)",
"type": "[DiscountConditionType](../enums/DiscountConditionType.mdx)",
"description": "The type of the condition. The type affects the available resources associated with the condition. For example, if the type is `products`, that means the `products` relation will hold the products associated with this condition and other relations will be empty.",
"optional": false,
"defaultValue": "",
@@ -213,7 +213,7 @@ A discount rule defines how a Discount is calculated when applied to a Cart.
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -222,8 +222,8 @@ A discount rule defines how a Discount is calculated when applied to a Cart.
},
{
"name": "type",
"type": "[`DiscountRuleType`](../enums/DiscountRuleType.mdx)",
"description": "The type of the Discount, can be `fixed` for discounts that reduce the price by a fixed amount, `percentage` for percentage reductions or `free_shipping` for shipping vouchers.",
"type": "[DiscountRuleType](../enums/DiscountRuleType.mdx)",
"description": "The type of the Discount, can be `fixed` for discounts that reduce the price by a fixed amount, `percentage` for percentage reductions or `free\\_shipping` for shipping vouchers.",
"optional": false,
"defaultValue": "",
"expandable": false,
@@ -22,7 +22,7 @@ A draft order is created by an admin without direct involvement of the customer.
},
{
"name": "cart",
"type": "[`Cart`](Cart.mdx)",
"type": "[Cart](Cart.mdx)",
"description": "The details of the cart associated with the draft order.",
"optional": false,
"defaultValue": "",
@@ -85,7 +85,7 @@ A draft order is created by an admin without direct involvement of the customer.
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -103,7 +103,7 @@ A draft order is created by an admin without direct involvement of the customer.
},
{
"name": "order",
"type": "[`Order`](Order.mdx)",
"type": "[Order](Order.mdx)",
"description": "The details of the order created from the draft order when its payment is captured.",
"optional": false,
"defaultValue": "",
@@ -121,7 +121,7 @@ A draft order is created by an admin without direct involvement of the customer.
},
{
"name": "status",
"type": "[`DraftOrderStatus`](../enums/DraftOrderStatus.mdx)",
"type": "[DraftOrderStatus](../enums/DraftOrderStatus.mdx)",
"description": "The status of the draft order. It's changed to `completed` when it's transformed to an order.",
"optional": false,
"defaultValue": "open",
@@ -22,7 +22,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "claim_order",
"type": "[`ClaimOrder`](ClaimOrder.mdx)",
"type": "[ClaimOrder](ClaimOrder.mdx)",
"description": "The details of the claim that the fulfillment may belong to.",
"optional": false,
"defaultValue": "",
@@ -30,7 +30,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
"children": [
{
"name": "additional_items",
"type": "[`LineItem`](LineItem.mdx)[]",
"type": "[LineItem](LineItem.mdx)[]",
"description": "The details of the new items to be shipped when the claim's type is `replace`",
"optional": false,
"defaultValue": "",
@@ -48,7 +48,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "claim_items",
"type": "[`ClaimItem`](ClaimItem.mdx)[]",
"type": "[ClaimItem](ClaimItem.mdx)[]",
"description": "The details of the items that should be replaced or refunded.",
"optional": false,
"defaultValue": "",
@@ -75,7 +75,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "fulfillment_status",
"type": "[`ClaimFulfillmentStatus`](../enums/ClaimFulfillmentStatus.mdx)",
"type": "[ClaimFulfillmentStatus](../enums/ClaimFulfillmentStatus.mdx)",
"description": "The claim's fulfillment status",
"optional": false,
"defaultValue": "not_fulfilled",
@@ -84,7 +84,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "fulfillments",
"type": "[`Fulfillment`](Fulfillment.mdx)[]",
"type": "[Fulfillment](Fulfillment.mdx)[]",
"description": "The fulfillments of the new items to be shipped",
"optional": false,
"defaultValue": "",
@@ -111,7 +111,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -129,7 +129,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "order",
"type": "[`Order`](Order.mdx)",
"type": "[Order](Order.mdx)",
"description": "The details of the order that this claim was created for.",
"optional": false,
"defaultValue": "",
@@ -147,7 +147,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "payment_status",
"type": "[`ClaimPaymentStatus`](../enums/ClaimPaymentStatus.mdx)",
"type": "[ClaimPaymentStatus](../enums/ClaimPaymentStatus.mdx)",
"description": "The status of the claim's payment",
"optional": false,
"defaultValue": "na",
@@ -165,7 +165,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "return_order",
"type": "[`Return`](Return.mdx)",
"type": "[Return](Return.mdx)",
"description": "The details of the return associated with the claim if the claim's type is `replace`.",
"optional": false,
"defaultValue": "",
@@ -174,7 +174,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "shipping_address",
"type": "[`Address`](Address.mdx)",
"type": "[Address](Address.mdx)",
"description": "The details of the address that new items should be shipped to.",
"optional": false,
"defaultValue": "",
@@ -192,7 +192,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "shipping_methods",
"type": "[`ShippingMethod`](ShippingMethod.mdx)[]",
"type": "[ShippingMethod](ShippingMethod.mdx)[]",
"description": "The details of the shipping methods that the claim order will be shipped with.",
"optional": false,
"defaultValue": "",
@@ -201,7 +201,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "type",
"type": "[`ClaimType`](../enums/ClaimType.mdx)",
"type": "[ClaimType](../enums/ClaimType.mdx)",
"description": "The claim's type",
"optional": false,
"defaultValue": "",
@@ -239,7 +239,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "data",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "This contains all the data necessary for the Fulfillment provider to handle the fulfillment.",
"optional": false,
"defaultValue": "",
@@ -266,7 +266,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "items",
"type": "[`FulfillmentItem`](FulfillmentItem.mdx)[]",
"type": "[FulfillmentItem](FulfillmentItem.mdx)[]",
"description": "The Fulfillment Items in the Fulfillment. These hold information about how many of each Line Item has been fulfilled.",
"optional": false,
"defaultValue": "",
@@ -274,7 +274,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
"children": [
{
"name": "fulfillment",
"type": "[`Fulfillment`](Fulfillment.mdx)",
"type": "[Fulfillment](Fulfillment.mdx)",
"description": "The details of the fulfillment.",
"optional": false,
"defaultValue": "",
@@ -292,7 +292,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "item",
"type": "[`LineItem`](LineItem.mdx)",
"type": "[LineItem](LineItem.mdx)",
"description": "The details of the line item.",
"optional": false,
"defaultValue": "",
@@ -330,7 +330,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -348,7 +348,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "order",
"type": "[`Order`](Order.mdx)",
"type": "[Order](Order.mdx)",
"description": "The details of the order that the fulfillment may belong to.",
"optional": false,
"defaultValue": "",
@@ -356,7 +356,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
"children": [
{
"name": "billing_address",
"type": "[`Address`](Address.mdx)",
"type": "[Address](Address.mdx)",
"description": "The details of the billing address associated with the order.",
"optional": false,
"defaultValue": "",
@@ -383,7 +383,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "cart",
"type": "[`Cart`](Cart.mdx)",
"type": "[Cart](Cart.mdx)",
"description": "The details of the cart associated with the order.",
"optional": false,
"defaultValue": "",
@@ -401,7 +401,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "claims",
"type": "[`ClaimOrder`](ClaimOrder.mdx)[]",
"type": "[ClaimOrder](ClaimOrder.mdx)[]",
"description": "The details of the claims created for the order.",
"optional": false,
"defaultValue": "",
@@ -419,7 +419,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "currency",
"type": "[`Currency`](Currency.mdx)",
"type": "[Currency](Currency.mdx)",
"description": "The details of the currency used in the order.",
"optional": false,
"defaultValue": "",
@@ -437,7 +437,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "customer",
"type": "[`Customer`](Customer.mdx)",
"type": "[Customer](Customer.mdx)",
"description": "The details of the customer associated with the order.",
"optional": false,
"defaultValue": "",
@@ -464,7 +464,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "discounts",
"type": "[`Discount`](Discount.mdx)[]",
"type": "[Discount](Discount.mdx)[]",
"description": "The details of the discounts applied on the order.",
"optional": false,
"defaultValue": "",
@@ -482,7 +482,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "draft_order",
"type": "[`DraftOrder`](DraftOrder.mdx)",
"type": "[DraftOrder](DraftOrder.mdx)",
"description": "The details of the draft order this order was created from.",
"optional": false,
"defaultValue": "",
@@ -500,7 +500,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "edits",
"type": "[`OrderEdit`](OrderEdit.mdx)[]",
"type": "[OrderEdit](OrderEdit.mdx)[]",
"description": "The details of the order edits done on the order.",
"optional": false,
"defaultValue": "",
@@ -527,7 +527,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "fulfillment_status",
"type": "[`FulfillmentStatus`](../enums/FulfillmentStatus.mdx)",
"type": "[FulfillmentStatus](../enums/FulfillmentStatus.mdx)",
"description": "The order's fulfillment status",
"optional": false,
"defaultValue": "not_fulfilled",
@@ -536,7 +536,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "fulfillments",
"type": "[`Fulfillment`](Fulfillment.mdx)[]",
"type": "[Fulfillment](Fulfillment.mdx)[]",
"description": "The details of the fulfillments created for the order.",
"optional": false,
"defaultValue": "",
@@ -563,7 +563,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "gift_card_transactions",
"type": "[`GiftCardTransaction`](GiftCardTransaction.mdx)[]",
"type": "[GiftCardTransaction](GiftCardTransaction.mdx)[]",
"description": "The gift card transactions made in the order.",
"optional": false,
"defaultValue": "",
@@ -572,7 +572,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "gift_cards",
"type": "[`GiftCard`](GiftCard.mdx)[]",
"type": "[GiftCard](GiftCard.mdx)[]",
"description": "The details of the gift card used in the order.",
"optional": false,
"defaultValue": "",
@@ -608,7 +608,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "items",
"type": "[`LineItem`](LineItem.mdx)[]",
"type": "[LineItem](LineItem.mdx)[]",
"description": "The details of the line items that belong to the order.",
"optional": false,
"defaultValue": "",
@@ -617,7 +617,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -653,7 +653,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "payment_status",
"type": "[`PaymentStatus`](../enums/PaymentStatus.mdx)",
"type": "[PaymentStatus](../enums/PaymentStatus.mdx)",
"description": "The order's payment status",
"optional": false,
"defaultValue": "not_paid",
@@ -662,7 +662,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "payments",
"type": "[`Payment`](Payment.mdx)[]",
"type": "[Payment](Payment.mdx)[]",
"description": "The details of the payments used in the order.",
"optional": false,
"defaultValue": "",
@@ -698,7 +698,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "refunds",
"type": "[`Refund`](Refund.mdx)[]",
"type": "[Refund](Refund.mdx)[]",
"description": "The details of the refunds created for the order.",
"optional": false,
"defaultValue": "",
@@ -707,7 +707,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "region",
"type": "[`Region`](Region.mdx)",
"type": "[Region](Region.mdx)",
"description": "The details of the region this order was created in.",
"optional": false,
"defaultValue": "",
@@ -725,7 +725,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "returnable_items",
"type": "[`LineItem`](LineItem.mdx)[]",
"type": "[LineItem](LineItem.mdx)[]",
"description": "The details of the line items that are returnable as part of the order, swaps, or claims",
"optional": true,
"defaultValue": "",
@@ -734,7 +734,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "returns",
"type": "[`Return`](Return.mdx)[]",
"type": "[Return](Return.mdx)[]",
"description": "The details of the returns created for the order.",
"optional": false,
"defaultValue": "",
@@ -743,7 +743,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "sales_channel",
"type": "[`SalesChannel`](SalesChannel.mdx)",
"type": "[SalesChannel](SalesChannel.mdx)",
"description": "The details of the sales channel this order belongs to.",
"optional": false,
"defaultValue": "",
@@ -761,7 +761,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "shipping_address",
"type": "[`Address`](Address.mdx)",
"type": "[Address](Address.mdx)",
"description": "The details of the shipping address associated with the order.",
"optional": false,
"defaultValue": "",
@@ -779,7 +779,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "shipping_methods",
"type": "[`ShippingMethod`](ShippingMethod.mdx)[]",
"type": "[ShippingMethod](ShippingMethod.mdx)[]",
"description": "The details of the shipping methods used in the order.",
"optional": false,
"defaultValue": "",
@@ -806,7 +806,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "status",
"type": "[`OrderStatus`](../enums/OrderStatus.mdx)",
"type": "[OrderStatus](../enums/OrderStatus.mdx)",
"description": "The order's status",
"optional": false,
"defaultValue": "pending",
@@ -824,7 +824,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "swaps",
"type": "[`Swap`](Swap.mdx)[]",
"type": "[Swap](Swap.mdx)[]",
"description": "The details of the swaps created for the order.",
"optional": false,
"defaultValue": "",
@@ -880,7 +880,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "provider",
"type": "[`FulfillmentProvider`](FulfillmentProvider.mdx)",
"type": "[FulfillmentProvider](FulfillmentProvider.mdx)",
"description": "The details of the fulfillment provider responsible for handling the fulfillment.",
"optional": false,
"defaultValue": "",
@@ -898,7 +898,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
{
"name": "is_installed",
"type": "`boolean`",
"description": "Whether the fulfillment service is installed in the current version. If a fulfillment service is no longer installed, the `is_installed` attribute is set to `false`.",
"description": "Whether the fulfillment service is installed in the current version. If a fulfillment service is no longer installed, the `is\\_installed` attribute is set to `false`.",
"optional": false,
"defaultValue": "true",
"expandable": false,
@@ -926,7 +926,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "swap",
"type": "[`Swap`](Swap.mdx)",
"type": "[Swap](Swap.mdx)",
"description": "The details of the swap that the fulfillment may belong to.",
"optional": false,
"defaultValue": "",
@@ -934,7 +934,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
"children": [
{
"name": "additional_items",
"type": "[`LineItem`](LineItem.mdx)[]",
"type": "[LineItem](LineItem.mdx)[]",
"description": "The details of the new products to send to the customer, represented as line items.",
"optional": false,
"defaultValue": "",
@@ -961,7 +961,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "cart",
"type": "[`Cart`](Cart.mdx)",
"type": "[Cart](Cart.mdx)",
"description": "The details of the cart that the customer uses to complete the swap.",
"optional": false,
"defaultValue": "",
@@ -1015,7 +1015,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "fulfillment_status",
"type": "[`SwapFulfillmentStatus`](../enums/SwapFulfillmentStatus.mdx)",
"type": "[SwapFulfillmentStatus](../enums/SwapFulfillmentStatus.mdx)",
"description": "The status of the Fulfillment of the Swap.",
"optional": false,
"defaultValue": "",
@@ -1024,7 +1024,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "fulfillments",
"type": "[`Fulfillment`](Fulfillment.mdx)[]",
"type": "[Fulfillment](Fulfillment.mdx)[]",
"description": "The details of the fulfillments that are used to send the new items to the customer.",
"optional": false,
"defaultValue": "",
@@ -1051,7 +1051,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -1069,7 +1069,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "order",
"type": "[`Order`](Order.mdx)",
"type": "[Order](Order.mdx)",
"description": "The details of the order that the swap belongs to.",
"optional": false,
"defaultValue": "",
@@ -1087,8 +1087,8 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "payment",
"type": "[`Payment`](Payment.mdx)",
"description": "The details of the additional payment authorized by the customer when `difference_due` is positive.",
"type": "[Payment](Payment.mdx)",
"description": "The details of the additional payment authorized by the customer when `difference\\_due` is positive.",
"optional": false,
"defaultValue": "",
"expandable": true,
@@ -1096,7 +1096,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "payment_status",
"type": "[`SwapPaymentStatus`](../enums/SwapPaymentStatus.mdx)",
"type": "[SwapPaymentStatus](../enums/SwapPaymentStatus.mdx)",
"description": "The status of the Payment of the Swap. The payment may either refer to the refund of an amount or the authorization of a new amount.",
"optional": false,
"defaultValue": "",
@@ -1105,7 +1105,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "return_order",
"type": "[`Return`](Return.mdx)",
"type": "[Return](Return.mdx)",
"description": "The details of the return that belongs to the swap, which holds the details on the items being returned.",
"optional": false,
"defaultValue": "",
@@ -1114,7 +1114,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "shipping_address",
"type": "[`Address`](Address.mdx)",
"type": "[Address](Address.mdx)",
"description": "The details of the shipping address that the new items should be sent to.",
"optional": false,
"defaultValue": "",
@@ -1132,7 +1132,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "shipping_methods",
"type": "[`ShippingMethod`](ShippingMethod.mdx)[]",
"type": "[ShippingMethod](ShippingMethod.mdx)[]",
"description": "The details of the shipping methods used to fulfill the additional items purchased.",
"optional": false,
"defaultValue": "",
@@ -1161,7 +1161,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "tracking_links",
"type": "[`TrackingLink`](TrackingLink.mdx)[]",
"type": "[TrackingLink](TrackingLink.mdx)[]",
"description": "The Tracking Links that can be used to track the status of the Fulfillment. These will usually be provided by the Fulfillment Provider.",
"optional": false,
"defaultValue": "",
@@ -1187,7 +1187,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "fulfillment",
"type": "[`Fulfillment`](Fulfillment.mdx)",
"type": "[Fulfillment](Fulfillment.mdx)",
"description": "The details of the fulfillment that the tracking link belongs to.",
"optional": false,
"defaultValue": "",
@@ -1223,7 +1223,7 @@ A Fulfillment is created once an admin can prepare the purchased goods. Fulfillm
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -13,7 +13,7 @@ This represents the association between a Line Item and a Fulfillment.
<ParameterTypes parameters={[
{
"name": "fulfillment",
"type": "[`Fulfillment`](Fulfillment.mdx)",
"type": "[Fulfillment](Fulfillment.mdx)",
"description": "The details of the fulfillment.",
"optional": false,
"defaultValue": "",
@@ -30,7 +30,7 @@ This represents the association between a Line Item and a Fulfillment.
},
{
"name": "claim_order",
"type": "[`ClaimOrder`](ClaimOrder.mdx)",
"type": "[ClaimOrder](ClaimOrder.mdx)",
"description": "The details of the claim that the fulfillment may belong to.",
"optional": false,
"defaultValue": "",
@@ -57,7 +57,7 @@ This represents the association between a Line Item and a Fulfillment.
},
{
"name": "data",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "This contains all the data necessary for the Fulfillment provider to handle the fulfillment.",
"optional": false,
"defaultValue": "",
@@ -84,7 +84,7 @@ This represents the association between a Line Item and a Fulfillment.
},
{
"name": "items",
"type": "[`FulfillmentItem`](FulfillmentItem.mdx)[]",
"type": "[FulfillmentItem](FulfillmentItem.mdx)[]",
"description": "The Fulfillment Items in the Fulfillment. These hold information about how many of each Line Item has been fulfilled.",
"optional": false,
"defaultValue": "",
@@ -102,7 +102,7 @@ This represents the association between a Line Item and a Fulfillment.
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -120,7 +120,7 @@ This represents the association between a Line Item and a Fulfillment.
},
{
"name": "order",
"type": "[`Order`](Order.mdx)",
"type": "[Order](Order.mdx)",
"description": "The details of the order that the fulfillment may belong to.",
"optional": false,
"defaultValue": "",
@@ -138,7 +138,7 @@ This represents the association between a Line Item and a Fulfillment.
},
{
"name": "provider",
"type": "[`FulfillmentProvider`](FulfillmentProvider.mdx)",
"type": "[FulfillmentProvider](FulfillmentProvider.mdx)",
"description": "The details of the fulfillment provider responsible for handling the fulfillment.",
"optional": false,
"defaultValue": "",
@@ -165,7 +165,7 @@ This represents the association between a Line Item and a Fulfillment.
},
{
"name": "swap",
"type": "[`Swap`](Swap.mdx)",
"type": "[Swap](Swap.mdx)",
"description": "The details of the swap that the fulfillment may belong to.",
"optional": false,
"defaultValue": "",
@@ -183,7 +183,7 @@ This represents the association between a Line Item and a Fulfillment.
},
{
"name": "tracking_links",
"type": "[`TrackingLink`](TrackingLink.mdx)[]",
"type": "[TrackingLink](TrackingLink.mdx)[]",
"description": "The Tracking Links that can be used to track the status of the Fulfillment. These will usually be provided by the Fulfillment Provider.",
"optional": false,
"defaultValue": "",
@@ -221,7 +221,7 @@ This represents the association between a Line Item and a Fulfillment.
},
{
"name": "item",
"type": "[`LineItem`](LineItem.mdx)",
"type": "[LineItem](LineItem.mdx)",
"description": "The details of the line item.",
"optional": false,
"defaultValue": "",
@@ -229,7 +229,7 @@ This represents the association between a Line Item and a Fulfillment.
"children": [
{
"name": "adjustments",
"type": "[`LineItemAdjustment`](LineItemAdjustment.mdx)[]",
"type": "[LineItemAdjustment](LineItemAdjustment.mdx)[]",
"description": "The details of the item's adjustments, which are available when a discount is applied on the item.",
"optional": false,
"defaultValue": "",
@@ -247,7 +247,7 @@ This represents the association between a Line Item and a Fulfillment.
},
{
"name": "cart",
"type": "[`Cart`](Cart.mdx)",
"type": "[Cart](Cart.mdx)",
"description": "The details of the cart that the line item may belongs to.",
"optional": false,
"defaultValue": "",
@@ -265,7 +265,7 @@ This represents the association between a Line Item and a Fulfillment.
},
{
"name": "claim_order",
"type": "[`ClaimOrder`](ClaimOrder.mdx)",
"type": "[ClaimOrder](ClaimOrder.mdx)",
"description": "The details of the claim that the line item may belong to.",
"optional": false,
"defaultValue": "",
@@ -347,7 +347,7 @@ This represents the association between a Line Item and a Fulfillment.
{
"name": "includes_tax",
"type": "`boolean`",
"description": "Indicates if the line item unit_price include tax",
"description": "Indicates if the line item unit\\_price include tax",
"optional": false,
"defaultValue": "false",
"expandable": false,
@@ -374,7 +374,7 @@ This represents the association between a Line Item and a Fulfillment.
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -383,7 +383,7 @@ This represents the association between a Line Item and a Fulfillment.
},
{
"name": "order",
"type": "[`Order`](Order.mdx)",
"type": "[Order](Order.mdx)",
"description": "The details of the order that the line item may belongs to.",
"optional": false,
"defaultValue": "",
@@ -392,7 +392,7 @@ This represents the association between a Line Item and a Fulfillment.
},
{
"name": "order_edit",
"type": "``null`` \\| [`OrderEdit`](OrderEdit.mdx)",
"type": "``null`` \\| [OrderEdit](OrderEdit.mdx)",
"description": "The details of the order edit.",
"optional": true,
"defaultValue": "",
@@ -518,7 +518,7 @@ This represents the association between a Line Item and a Fulfillment.
},
{
"name": "swap",
"type": "[`Swap`](Swap.mdx)",
"type": "[Swap](Swap.mdx)",
"description": "The details of the swap that the line item may belong to.",
"optional": false,
"defaultValue": "",
@@ -536,7 +536,7 @@ This represents the association between a Line Item and a Fulfillment.
},
{
"name": "tax_lines",
"type": "[`LineItemTaxLine`](LineItemTaxLine.mdx)[]",
"type": "[LineItemTaxLine](LineItemTaxLine.mdx)[]",
"description": "The details of the item's tax lines.",
"optional": false,
"defaultValue": "",
@@ -599,7 +599,7 @@ This represents the association between a Line Item and a Fulfillment.
},
{
"name": "variant",
"type": "[`ProductVariant`](ProductVariant.mdx)",
"type": "[ProductVariant](ProductVariant.mdx)",
"description": "The details of the product variant that this item was created from.",
"optional": false,
"defaultValue": "",
@@ -23,7 +23,7 @@ A fulfillment provider represents a fulfillment service installed in the Medusa
{
"name": "is_installed",
"type": "`boolean`",
"description": "Whether the fulfillment service is installed in the current version. If a fulfillment service is no longer installed, the `is_installed` attribute is set to `false`.",
"description": "Whether the fulfillment service is installed in the current version. If a fulfillment service is no longer installed, the `is\\_installed` attribute is set to `false`.",
"optional": false,
"defaultValue": "true",
"expandable": false,
@@ -76,7 +76,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -85,7 +85,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "order",
"type": "[`Order`](Order.mdx)",
"type": "[Order](Order.mdx)",
"description": "The details of the order that the gift card was purchased in.",
"optional": false,
"defaultValue": "",
@@ -93,7 +93,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
"children": [
{
"name": "billing_address",
"type": "[`Address`](Address.mdx)",
"type": "[Address](Address.mdx)",
"description": "The details of the billing address associated with the order.",
"optional": false,
"defaultValue": "",
@@ -120,7 +120,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "cart",
"type": "[`Cart`](Cart.mdx)",
"type": "[Cart](Cart.mdx)",
"description": "The details of the cart associated with the order.",
"optional": false,
"defaultValue": "",
@@ -138,7 +138,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "claims",
"type": "[`ClaimOrder`](ClaimOrder.mdx)[]",
"type": "[ClaimOrder](ClaimOrder.mdx)[]",
"description": "The details of the claims created for the order.",
"optional": false,
"defaultValue": "",
@@ -156,7 +156,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "currency",
"type": "[`Currency`](Currency.mdx)",
"type": "[Currency](Currency.mdx)",
"description": "The details of the currency used in the order.",
"optional": false,
"defaultValue": "",
@@ -174,7 +174,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "customer",
"type": "[`Customer`](Customer.mdx)",
"type": "[Customer](Customer.mdx)",
"description": "The details of the customer associated with the order.",
"optional": false,
"defaultValue": "",
@@ -201,7 +201,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "discounts",
"type": "[`Discount`](Discount.mdx)[]",
"type": "[Discount](Discount.mdx)[]",
"description": "The details of the discounts applied on the order.",
"optional": false,
"defaultValue": "",
@@ -219,7 +219,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "draft_order",
"type": "[`DraftOrder`](DraftOrder.mdx)",
"type": "[DraftOrder](DraftOrder.mdx)",
"description": "The details of the draft order this order was created from.",
"optional": false,
"defaultValue": "",
@@ -237,7 +237,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "edits",
"type": "[`OrderEdit`](OrderEdit.mdx)[]",
"type": "[OrderEdit](OrderEdit.mdx)[]",
"description": "The details of the order edits done on the order.",
"optional": false,
"defaultValue": "",
@@ -264,7 +264,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "fulfillment_status",
"type": "[`FulfillmentStatus`](../enums/FulfillmentStatus.mdx)",
"type": "[FulfillmentStatus](../enums/FulfillmentStatus.mdx)",
"description": "The order's fulfillment status",
"optional": false,
"defaultValue": "not_fulfilled",
@@ -273,7 +273,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "fulfillments",
"type": "[`Fulfillment`](Fulfillment.mdx)[]",
"type": "[Fulfillment](Fulfillment.mdx)[]",
"description": "The details of the fulfillments created for the order.",
"optional": false,
"defaultValue": "",
@@ -300,7 +300,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "gift_card_transactions",
"type": "[`GiftCardTransaction`](GiftCardTransaction.mdx)[]",
"type": "[GiftCardTransaction](GiftCardTransaction.mdx)[]",
"description": "The gift card transactions made in the order.",
"optional": false,
"defaultValue": "",
@@ -309,7 +309,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "gift_cards",
"type": "[`GiftCard`](GiftCard.mdx)[]",
"type": "[GiftCard](GiftCard.mdx)[]",
"description": "The details of the gift card used in the order.",
"optional": false,
"defaultValue": "",
@@ -345,7 +345,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "items",
"type": "[`LineItem`](LineItem.mdx)[]",
"type": "[LineItem](LineItem.mdx)[]",
"description": "The details of the line items that belong to the order.",
"optional": false,
"defaultValue": "",
@@ -354,7 +354,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -390,7 +390,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "payment_status",
"type": "[`PaymentStatus`](../enums/PaymentStatus.mdx)",
"type": "[PaymentStatus](../enums/PaymentStatus.mdx)",
"description": "The order's payment status",
"optional": false,
"defaultValue": "not_paid",
@@ -399,7 +399,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "payments",
"type": "[`Payment`](Payment.mdx)[]",
"type": "[Payment](Payment.mdx)[]",
"description": "The details of the payments used in the order.",
"optional": false,
"defaultValue": "",
@@ -435,7 +435,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "refunds",
"type": "[`Refund`](Refund.mdx)[]",
"type": "[Refund](Refund.mdx)[]",
"description": "The details of the refunds created for the order.",
"optional": false,
"defaultValue": "",
@@ -444,7 +444,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "region",
"type": "[`Region`](Region.mdx)",
"type": "[Region](Region.mdx)",
"description": "The details of the region this order was created in.",
"optional": false,
"defaultValue": "",
@@ -462,7 +462,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "returnable_items",
"type": "[`LineItem`](LineItem.mdx)[]",
"type": "[LineItem](LineItem.mdx)[]",
"description": "The details of the line items that are returnable as part of the order, swaps, or claims",
"optional": true,
"defaultValue": "",
@@ -471,7 +471,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "returns",
"type": "[`Return`](Return.mdx)[]",
"type": "[Return](Return.mdx)[]",
"description": "The details of the returns created for the order.",
"optional": false,
"defaultValue": "",
@@ -480,7 +480,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "sales_channel",
"type": "[`SalesChannel`](SalesChannel.mdx)",
"type": "[SalesChannel](SalesChannel.mdx)",
"description": "The details of the sales channel this order belongs to.",
"optional": false,
"defaultValue": "",
@@ -498,7 +498,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "shipping_address",
"type": "[`Address`](Address.mdx)",
"type": "[Address](Address.mdx)",
"description": "The details of the shipping address associated with the order.",
"optional": false,
"defaultValue": "",
@@ -516,7 +516,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "shipping_methods",
"type": "[`ShippingMethod`](ShippingMethod.mdx)[]",
"type": "[ShippingMethod](ShippingMethod.mdx)[]",
"description": "The details of the shipping methods used in the order.",
"optional": false,
"defaultValue": "",
@@ -543,7 +543,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "status",
"type": "[`OrderStatus`](../enums/OrderStatus.mdx)",
"type": "[OrderStatus](../enums/OrderStatus.mdx)",
"description": "The order's status",
"optional": false,
"defaultValue": "pending",
@@ -561,7 +561,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "swaps",
"type": "[`Swap`](Swap.mdx)[]",
"type": "[Swap](Swap.mdx)[]",
"description": "The details of the swaps created for the order.",
"optional": false,
"defaultValue": "",
@@ -617,7 +617,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "region",
"type": "[`Region`](Region.mdx)",
"type": "[Region](Region.mdx)",
"description": "The details of the region this gift card is available in.",
"optional": false,
"defaultValue": "",
@@ -634,7 +634,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "countries",
"type": "[`Country`](Country.mdx)[]",
"type": "[Country](Country.mdx)[]",
"description": "The details of the countries included in this region.",
"optional": false,
"defaultValue": "",
@@ -652,7 +652,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "currency",
"type": "[`Currency`](Currency.mdx)",
"type": "[Currency](Currency.mdx)",
"description": "The details of the currency used in the region.",
"optional": false,
"defaultValue": "",
@@ -679,7 +679,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "fulfillment_providers",
"type": "[`FulfillmentProvider`](FulfillmentProvider.mdx)[]",
"type": "[FulfillmentProvider](FulfillmentProvider.mdx)[]",
"description": "The details of the fulfillment providers that can be used to fulfill items of orders and similar resources in the region.",
"optional": false,
"defaultValue": "",
@@ -716,7 +716,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -734,7 +734,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "payment_providers",
"type": "[`PaymentProvider`](PaymentProvider.mdx)[]",
"type": "[PaymentProvider](PaymentProvider.mdx)[]",
"description": "The details of the payment providers that can be used to process payments in the region.",
"optional": false,
"defaultValue": "",
@@ -752,7 +752,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "tax_provider",
"type": "[`TaxProvider`](TaxProvider.mdx)",
"type": "[TaxProvider](TaxProvider.mdx)",
"description": "The details of the tax provider used in the region.",
"optional": false,
"defaultValue": "",
@@ -779,7 +779,7 @@ Gift Cards are redeemable and represent a value that can be used towards the pay
},
{
"name": "tax_rates",
"type": "``null`` \\| [`TaxRate`](TaxRate.mdx)[]",
"type": "``null`` \\| [TaxRate](TaxRate.mdx)[]",
"description": "The details of the tax rates used in the region, aside from the default rate.",
"optional": false,
"defaultValue": "",
@@ -31,7 +31,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "gift_card",
"type": "[`GiftCard`](GiftCard.mdx)",
"type": "[GiftCard](GiftCard.mdx)",
"description": "The details of the gift card associated used in this transaction.",
"optional": false,
"defaultValue": "",
@@ -102,7 +102,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -111,7 +111,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "order",
"type": "[`Order`](Order.mdx)",
"type": "[Order](Order.mdx)",
"description": "The details of the order that the gift card was purchased in.",
"optional": false,
"defaultValue": "",
@@ -129,7 +129,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "region",
"type": "[`Region`](Region.mdx)",
"type": "[Region](Region.mdx)",
"description": "The details of the region this gift card is available in.",
"optional": false,
"defaultValue": "",
@@ -203,7 +203,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "order",
"type": "[`Order`](Order.mdx)",
"type": "[Order](Order.mdx)",
"description": "The details of the order that the gift card was used for payment.",
"optional": false,
"defaultValue": "",
@@ -211,7 +211,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
"children": [
{
"name": "billing_address",
"type": "[`Address`](Address.mdx)",
"type": "[Address](Address.mdx)",
"description": "The details of the billing address associated with the order.",
"optional": false,
"defaultValue": "",
@@ -238,7 +238,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "cart",
"type": "[`Cart`](Cart.mdx)",
"type": "[Cart](Cart.mdx)",
"description": "The details of the cart associated with the order.",
"optional": false,
"defaultValue": "",
@@ -256,7 +256,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "claims",
"type": "[`ClaimOrder`](ClaimOrder.mdx)[]",
"type": "[ClaimOrder](ClaimOrder.mdx)[]",
"description": "The details of the claims created for the order.",
"optional": false,
"defaultValue": "",
@@ -274,7 +274,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "currency",
"type": "[`Currency`](Currency.mdx)",
"type": "[Currency](Currency.mdx)",
"description": "The details of the currency used in the order.",
"optional": false,
"defaultValue": "",
@@ -292,7 +292,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "customer",
"type": "[`Customer`](Customer.mdx)",
"type": "[Customer](Customer.mdx)",
"description": "The details of the customer associated with the order.",
"optional": false,
"defaultValue": "",
@@ -319,7 +319,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "discounts",
"type": "[`Discount`](Discount.mdx)[]",
"type": "[Discount](Discount.mdx)[]",
"description": "The details of the discounts applied on the order.",
"optional": false,
"defaultValue": "",
@@ -337,7 +337,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "draft_order",
"type": "[`DraftOrder`](DraftOrder.mdx)",
"type": "[DraftOrder](DraftOrder.mdx)",
"description": "The details of the draft order this order was created from.",
"optional": false,
"defaultValue": "",
@@ -355,7 +355,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "edits",
"type": "[`OrderEdit`](OrderEdit.mdx)[]",
"type": "[OrderEdit](OrderEdit.mdx)[]",
"description": "The details of the order edits done on the order.",
"optional": false,
"defaultValue": "",
@@ -382,7 +382,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "fulfillment_status",
"type": "[`FulfillmentStatus`](../enums/FulfillmentStatus.mdx)",
"type": "[FulfillmentStatus](../enums/FulfillmentStatus.mdx)",
"description": "The order's fulfillment status",
"optional": false,
"defaultValue": "not_fulfilled",
@@ -391,7 +391,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "fulfillments",
"type": "[`Fulfillment`](Fulfillment.mdx)[]",
"type": "[Fulfillment](Fulfillment.mdx)[]",
"description": "The details of the fulfillments created for the order.",
"optional": false,
"defaultValue": "",
@@ -418,7 +418,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "gift_card_transactions",
"type": "[`GiftCardTransaction`](GiftCardTransaction.mdx)[]",
"type": "[GiftCardTransaction](GiftCardTransaction.mdx)[]",
"description": "The gift card transactions made in the order.",
"optional": false,
"defaultValue": "",
@@ -427,7 +427,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "gift_cards",
"type": "[`GiftCard`](GiftCard.mdx)[]",
"type": "[GiftCard](GiftCard.mdx)[]",
"description": "The details of the gift card used in the order.",
"optional": false,
"defaultValue": "",
@@ -463,7 +463,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "items",
"type": "[`LineItem`](LineItem.mdx)[]",
"type": "[LineItem](LineItem.mdx)[]",
"description": "The details of the line items that belong to the order.",
"optional": false,
"defaultValue": "",
@@ -472,7 +472,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -508,7 +508,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "payment_status",
"type": "[`PaymentStatus`](../enums/PaymentStatus.mdx)",
"type": "[PaymentStatus](../enums/PaymentStatus.mdx)",
"description": "The order's payment status",
"optional": false,
"defaultValue": "not_paid",
@@ -517,7 +517,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "payments",
"type": "[`Payment`](Payment.mdx)[]",
"type": "[Payment](Payment.mdx)[]",
"description": "The details of the payments used in the order.",
"optional": false,
"defaultValue": "",
@@ -553,7 +553,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "refunds",
"type": "[`Refund`](Refund.mdx)[]",
"type": "[Refund](Refund.mdx)[]",
"description": "The details of the refunds created for the order.",
"optional": false,
"defaultValue": "",
@@ -562,7 +562,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "region",
"type": "[`Region`](Region.mdx)",
"type": "[Region](Region.mdx)",
"description": "The details of the region this order was created in.",
"optional": false,
"defaultValue": "",
@@ -580,7 +580,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "returnable_items",
"type": "[`LineItem`](LineItem.mdx)[]",
"type": "[LineItem](LineItem.mdx)[]",
"description": "The details of the line items that are returnable as part of the order, swaps, or claims",
"optional": true,
"defaultValue": "",
@@ -589,7 +589,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "returns",
"type": "[`Return`](Return.mdx)[]",
"type": "[Return](Return.mdx)[]",
"description": "The details of the returns created for the order.",
"optional": false,
"defaultValue": "",
@@ -598,7 +598,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "sales_channel",
"type": "[`SalesChannel`](SalesChannel.mdx)",
"type": "[SalesChannel](SalesChannel.mdx)",
"description": "The details of the sales channel this order belongs to.",
"optional": false,
"defaultValue": "",
@@ -616,7 +616,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "shipping_address",
"type": "[`Address`](Address.mdx)",
"type": "[Address](Address.mdx)",
"description": "The details of the shipping address associated with the order.",
"optional": false,
"defaultValue": "",
@@ -634,7 +634,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "shipping_methods",
"type": "[`ShippingMethod`](ShippingMethod.mdx)[]",
"type": "[ShippingMethod](ShippingMethod.mdx)[]",
"description": "The details of the shipping methods used in the order.",
"optional": false,
"defaultValue": "",
@@ -661,7 +661,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "status",
"type": "[`OrderStatus`](../enums/OrderStatus.mdx)",
"type": "[OrderStatus](../enums/OrderStatus.mdx)",
"description": "The order's status",
"optional": false,
"defaultValue": "pending",
@@ -679,7 +679,7 @@ Gift Card Transactions are created once a Customer uses a Gift Card to pay for t
},
{
"name": "swaps",
"type": "[`Swap`](Swap.mdx)[]",
"type": "[Swap](Swap.mdx)[]",
"description": "The details of the swaps created for the order.",
"optional": false,
"defaultValue": "",
@@ -67,7 +67,7 @@ Idempotency Key is used to continue a process in case of any failure that might
},
{
"name": "request_params",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "The parameters passed to the request",
"optional": false,
"defaultValue": "",
@@ -85,7 +85,7 @@ Idempotency Key is used to continue a process in case of any failure that might
},
{
"name": "response_body",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "The response's body",
"optional": false,
"defaultValue": "",
@@ -40,7 +40,7 @@ An Image is used to store details about uploaded images. Images are uploaded by
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -58,7 +58,7 @@ An invite is created when an admin user invites a new user to join the store's t
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -67,7 +67,7 @@ An invite is created when an admin user invites a new user to join the store's t
},
{
"name": "role",
"type": "[`UserRoles`](../enums/UserRoles.mdx)",
"type": "[UserRoles](../enums/UserRoles.mdx)",
"description": "The user's role. These roles don't change the privileges of the user.",
"optional": false,
"defaultValue": "member",
@@ -13,7 +13,7 @@ Line Items are created when a product is added to a Cart. When Line Items are pu
<ParameterTypes parameters={[
{
"name": "adjustments",
"type": "[`LineItemAdjustment`](LineItemAdjustment.mdx)[]",
"type": "[LineItemAdjustment](LineItemAdjustment.mdx)[]",
"description": "The details of the item's adjustments, which are available when a discount is applied on the item.",
"optional": false,
"defaultValue": "",
@@ -31,7 +31,7 @@ Line Items are created when a product is added to a Cart. When Line Items are pu
},
{
"name": "cart",
"type": "[`Cart`](Cart.mdx)",
"type": "[Cart](Cart.mdx)",
"description": "The details of the cart that the line item may belongs to.",
"optional": false,
"defaultValue": "",
@@ -49,7 +49,7 @@ Line Items are created when a product is added to a Cart. When Line Items are pu
},
{
"name": "claim_order",
"type": "[`ClaimOrder`](ClaimOrder.mdx)",
"type": "[ClaimOrder](ClaimOrder.mdx)",
"description": "The details of the claim that the line item may belong to.",
"optional": false,
"defaultValue": "",
@@ -131,7 +131,7 @@ Line Items are created when a product is added to a Cart. When Line Items are pu
{
"name": "includes_tax",
"type": "`boolean`",
"description": "Indicates if the line item unit_price include tax",
"description": "Indicates if the line item unit\\_price include tax",
"optional": false,
"defaultValue": "false",
"expandable": false,
@@ -158,7 +158,7 @@ Line Items are created when a product is added to a Cart. When Line Items are pu
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -167,7 +167,7 @@ Line Items are created when a product is added to a Cart. When Line Items are pu
},
{
"name": "order",
"type": "[`Order`](Order.mdx)",
"type": "[Order](Order.mdx)",
"description": "The details of the order that the line item may belongs to.",
"optional": false,
"defaultValue": "",
@@ -176,7 +176,7 @@ Line Items are created when a product is added to a Cart. When Line Items are pu
},
{
"name": "order_edit",
"type": "``null`` \\| [`OrderEdit`](OrderEdit.mdx)",
"type": "``null`` \\| [OrderEdit](OrderEdit.mdx)",
"description": "The details of the order edit.",
"optional": true,
"defaultValue": "",
@@ -302,7 +302,7 @@ Line Items are created when a product is added to a Cart. When Line Items are pu
},
{
"name": "swap",
"type": "[`Swap`](Swap.mdx)",
"type": "[Swap](Swap.mdx)",
"description": "The details of the swap that the line item may belong to.",
"optional": false,
"defaultValue": "",
@@ -320,7 +320,7 @@ Line Items are created when a product is added to a Cart. When Line Items are pu
},
{
"name": "tax_lines",
"type": "[`LineItemTaxLine`](LineItemTaxLine.mdx)[]",
"type": "[LineItemTaxLine](LineItemTaxLine.mdx)[]",
"description": "The details of the item's tax lines.",
"optional": false,
"defaultValue": "",
@@ -383,7 +383,7 @@ Line Items are created when a product is added to a Cart. When Line Items are pu
},
{
"name": "variant",
"type": "[`ProductVariant`](ProductVariant.mdx)",
"type": "[ProductVariant](ProductVariant.mdx)",
"description": "The details of the product variant that this item was created from.",
"optional": false,
"defaultValue": "",
@@ -31,7 +31,7 @@ A Line Item Adjustment includes details on discounts applied on a line item.
},
{
"name": "discount",
"type": "[`Discount`](Discount.mdx)",
"type": "[Discount](Discount.mdx)",
"description": "The details of the discount associated with the adjustment.",
"optional": false,
"defaultValue": "",
@@ -58,7 +58,7 @@ A Line Item Adjustment includes details on discounts applied on a line item.
},
{
"name": "item",
"type": "[`LineItem`](LineItem.mdx)",
"type": "[LineItem](LineItem.mdx)",
"description": "The details of the line item.",
"optional": false,
"defaultValue": "",
@@ -76,7 +76,7 @@ A Line Item Adjustment includes details on discounts applied on a line item.
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -40,7 +40,7 @@ A Line Item Tax Line represents the taxes applied on a line item.
},
{
"name": "item",
"type": "[`LineItem`](LineItem.mdx)",
"type": "[LineItem](LineItem.mdx)",
"description": "The details of the line item.",
"optional": false,
"defaultValue": "",
@@ -58,7 +58,7 @@ A Line Item Tax Line represents the taxes applied on a line item.
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -31,7 +31,7 @@ A Money Amount represent a price amount, for example, a product variant's price
},
{
"name": "currency",
"type": "[`Currency`](Currency.mdx)",
"type": "[Currency](Currency.mdx)",
"description": "The details of the currency that the money amount may belong to.",
"optional": true,
"defaultValue": "",
@@ -132,7 +132,7 @@ A Money Amount represent a price amount, for example, a product variant's price
},
{
"name": "price_list",
"type": "``null`` \\| [`PriceList`](PriceList.mdx)",
"type": "``null`` \\| [PriceList](PriceList.mdx)",
"description": "The details of the price list that the money amount may belong to.",
"optional": false,
"defaultValue": "",
@@ -150,7 +150,7 @@ A Money Amount represent a price amount, for example, a product variant's price
},
{
"name": "region",
"type": "[`Region`](Region.mdx)",
"type": "[Region](Region.mdx)",
"description": "The details of the region that the money amount may belong to.",
"optional": true,
"defaultValue": "",
@@ -167,7 +167,7 @@ A Money Amount represent a price amount, for example, a product variant's price
},
{
"name": "countries",
"type": "[`Country`](Country.mdx)[]",
"type": "[Country](Country.mdx)[]",
"description": "The details of the countries included in this region.",
"optional": false,
"defaultValue": "",
@@ -185,7 +185,7 @@ A Money Amount represent a price amount, for example, a product variant's price
},
{
"name": "currency",
"type": "[`Currency`](Currency.mdx)",
"type": "[Currency](Currency.mdx)",
"description": "The details of the currency used in the region.",
"optional": false,
"defaultValue": "",
@@ -212,7 +212,7 @@ A Money Amount represent a price amount, for example, a product variant's price
},
{
"name": "fulfillment_providers",
"type": "[`FulfillmentProvider`](FulfillmentProvider.mdx)[]",
"type": "[FulfillmentProvider](FulfillmentProvider.mdx)[]",
"description": "The details of the fulfillment providers that can be used to fulfill items of orders and similar resources in the region.",
"optional": false,
"defaultValue": "",
@@ -249,7 +249,7 @@ A Money Amount represent a price amount, for example, a product variant's price
},
{
"name": "metadata",
"type": "Record<`string`, `unknown`\\>",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -267,7 +267,7 @@ A Money Amount represent a price amount, for example, a product variant's price
},
{
"name": "payment_providers",
"type": "[`PaymentProvider`](PaymentProvider.mdx)[]",
"type": "[PaymentProvider](PaymentProvider.mdx)[]",
"description": "The details of the payment providers that can be used to process payments in the region.",
"optional": false,
"defaultValue": "",
@@ -285,7 +285,7 @@ A Money Amount represent a price amount, for example, a product variant's price
},
{
"name": "tax_provider",
"type": "[`TaxProvider`](TaxProvider.mdx)",
"type": "[TaxProvider](TaxProvider.mdx)",
"description": "The details of the tax provider used in the region.",
"optional": false,
"defaultValue": "",
@@ -312,7 +312,7 @@ A Money Amount represent a price amount, for example, a product variant's price
},
{
"name": "tax_rates",
"type": "``null`` \\| [`TaxRate`](TaxRate.mdx)[]",
"type": "``null`` \\| [TaxRate](TaxRate.mdx)[]",
"description": "The details of the tax rates used in the region, aside from the default rate.",
"optional": false,
"defaultValue": "",
@@ -350,7 +350,7 @@ A Money Amount represent a price amount, for example, a product variant's price
},
{
"name": "variant",
"type": "[`ProductVariant`](ProductVariant.mdx)",
"type": "[ProductVariant](ProductVariant.mdx)",
"description": "The details of the product variant that the money amount may belong to.",
"optional": false,
"defaultValue": "",
@@ -359,7 +359,7 @@ A Money Amount represent a price amount, for example, a product variant's price
{
"name": "allow_backorder",
"type": "`boolean`",
"description": "Whether the Product Variant should be purchasable when `inventory_quantity` is 0.",
"description": "Whether the Product Variant should be purchasable when `inventory\\_quantity` is 0.",
"optional": false,
"defaultValue": "false",
"expandable": false,
@@ -430,7 +430,7 @@ A Money Amount represent a price amount, for example, a product variant's price
},
{
"name": "inventory_items",
"type": "[`ProductVariantInventoryItem`](ProductVariantInventoryItem.mdx)[]",
"type": "[ProductVariantInventoryItem](ProductVariantInventoryItem.mdx)[]",
"description": "The details inventory items of the product variant.",
"optional": false,
"defaultValue": "",
@@ -475,7 +475,7 @@ A Money Amount represent a price amount, for example, a product variant's price
},
{
"name": "metadata",
"type": "``null`` \\| Record<`string`, `unknown`\\>",
"type": "``null`` \\| `Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -493,7 +493,7 @@ A Money Amount represent a price amount, for example, a product variant's price
},
{
"name": "options",
"type": "[`ProductOptionValue`](ProductOptionValue.mdx)[]",
"type": "[ProductOptionValue](ProductOptionValue.mdx)[]",
"description": "The details of the product options that this product variant defines values for.",
"optional": false,
"defaultValue": "",
@@ -511,7 +511,7 @@ A Money Amount represent a price amount, for example, a product variant's price
},
{
"name": "prices",
"type": "[`MoneyAmount`](MoneyAmount.mdx)[]",
"type": "[MoneyAmount](MoneyAmount.mdx)[]",
"description": "The details of the prices of the Product Variant, each represented as a Money Amount. Each Money Amount represents a price in a given currency or a specific Region.",
"optional": false,
"defaultValue": "",
@@ -520,7 +520,7 @@ A Money Amount represent a price amount, for example, a product variant's price
},
{
"name": "product",
"type": "[`Product`](Product.mdx)",
"type": "[Product](Product.mdx)",
"description": "The details of the product that the product variant belongs to.",
"optional": false,
"defaultValue": "",
@@ -621,7 +621,7 @@ A Money Amount represent a price amount, for example, a product variant's price
},
{
"name": "variants",
"type": "[`ProductVariant`](ProductVariant.mdx)[]",
"type": "[ProductVariant](ProductVariant.mdx)[]",
"description": "",
"optional": false,
"defaultValue": "",
@@ -630,7 +630,7 @@ A Money Amount represent a price amount, for example, a product variant's price
{
"name": "allow_backorder",
"type": "`boolean`",
"description": "Whether the Product Variant should be purchasable when `inventory_quantity` is 0.",
"description": "Whether the Product Variant should be purchasable when `inventory\\_quantity` is 0.",
"optional": false,
"defaultValue": "false",
"expandable": false,
@@ -701,7 +701,7 @@ A Money Amount represent a price amount, for example, a product variant's price
},
{
"name": "inventory_items",
"type": "[`ProductVariantInventoryItem`](ProductVariantInventoryItem.mdx)[]",
"type": "[ProductVariantInventoryItem](ProductVariantInventoryItem.mdx)[]",
"description": "The details inventory items of the product variant.",
"optional": false,
"defaultValue": "",
@@ -746,7 +746,7 @@ A Money Amount represent a price amount, for example, a product variant's price
},
{
"name": "metadata",
"type": "``null`` \\| Record<`string`, `unknown`\\>",
"type": "``null`` \\| `Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
@@ -764,7 +764,7 @@ A Money Amount represent a price amount, for example, a product variant's price
},
{
"name": "options",
"type": "[`ProductOptionValue`](ProductOptionValue.mdx)[]",
"type": "[ProductOptionValue](ProductOptionValue.mdx)[]",
"description": "The details of the product options that this product variant defines values for.",
"optional": false,
"defaultValue": "",
@@ -782,7 +782,7 @@ A Money Amount represent a price amount, for example, a product variant's price
},
{
"name": "prices",
"type": "[`MoneyAmount`](MoneyAmount.mdx)[]",
"type": "[MoneyAmount](MoneyAmount.mdx)[]",
"description": "The details of the prices of the Product Variant, each represented as a Money Amount. Each Money Amount represents a price in a given currency or a specific Region.",
"optional": false,
"defaultValue": "",
@@ -791,7 +791,7 @@ A Money Amount represent a price amount, for example, a product variant's price
},
{
"name": "product",
"type": "[`Product`](Product.mdx)",
"type": "[Product](Product.mdx)",
"description": "The details of the product that the product variant belongs to.",
"optional": false,
"defaultValue": "",
Loaded 100 of 2265 files, more files were not shown because too many files have changed in this diff. Show more