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:
1 parent
cedab58339
commit
c6dff873de
2265 files changed
+36827
-37859
No files matched your search
@@ -22,7 +22,7 @@ jobs:
|
|||||||
- name: Setup Node.js environment
|
- name: Setup Node.js environment
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: "16.14.0"
|
node-version: "18"
|
||||||
cache: "yarn"
|
cache: "yarn"
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ module.exports = {
|
|||||||
sections: {
|
sections: {
|
||||||
member_sources_definedIn: false,
|
member_sources_definedIn: false,
|
||||||
reflection_hierarchy: false,
|
reflection_hierarchy: false,
|
||||||
|
member_sources_inheritedFrom: false,
|
||||||
|
member_sources_implementationOf: false,
|
||||||
|
reflection_implementedBy: false,
|
||||||
|
member_signature_sources: false,
|
||||||
|
reflection_callable: false,
|
||||||
|
reflection_indexable: false,
|
||||||
},
|
},
|
||||||
parameterStyle: "component",
|
parameterStyle: "component",
|
||||||
parameterComponent: "ParameterTypes",
|
parameterComponent: "ParameterTypes",
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ const defaultFormattingOptions = {
|
|||||||
member_signature_title: false,
|
member_signature_title: false,
|
||||||
member_signature_returns: false,
|
member_signature_returns: false,
|
||||||
title_reflectionPath: false,
|
title_reflectionPath: false,
|
||||||
|
reflection_callable: false,
|
||||||
|
reflection_indexable: false,
|
||||||
|
reflection_implementedBy: false,
|
||||||
|
member_declaration_title: false,
|
||||||
},
|
},
|
||||||
parameterStyle: "component",
|
parameterStyle: "component",
|
||||||
parameterComponent: "ParameterTypes",
|
parameterComponent: "ParameterTypes",
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import * as Handlebars from "handlebars"
|
|||||||
import * as Path from "path"
|
import * as Path from "path"
|
||||||
import { CommentDisplayPart } from "typedoc/dist/lib/models/comments/comment"
|
import { CommentDisplayPart } from "typedoc/dist/lib/models/comments/comment"
|
||||||
import { MarkdownTheme } from "../../theme"
|
import { MarkdownTheme } from "../../theme"
|
||||||
|
import { escapeChars } from "../../utils"
|
||||||
|
|
||||||
export default function (theme: MarkdownTheme) {
|
export default function (theme: MarkdownTheme) {
|
||||||
Handlebars.registerHelper("comment", function (parts: CommentDisplayPart[]) {
|
Handlebars.registerHelper("comment", function (parts: CommentDisplayPart[]) {
|
||||||
@@ -10,6 +11,8 @@ export default function (theme: MarkdownTheme) {
|
|||||||
for (const part of parts) {
|
for (const part of parts) {
|
||||||
switch (part.kind) {
|
switch (part.kind) {
|
||||||
case "text":
|
case "text":
|
||||||
|
result.push(escapeChars(part.text, false))
|
||||||
|
break
|
||||||
case "code":
|
case "code":
|
||||||
result.push(part.text)
|
result.push(part.text)
|
||||||
break
|
break
|
||||||
|
|||||||
+3
-6
@@ -31,7 +31,8 @@ export default function (theme: MarkdownTheme) {
|
|||||||
(reflection.parent?.kindOf(ReflectionKind.Enum) ? " = " : ": ") +
|
(reflection.parent?.kindOf(ReflectionKind.Enum) ? " = " : ": ") +
|
||||||
Handlebars.helpers.type.call(
|
Handlebars.helpers.type.call(
|
||||||
reflectionType ? reflectionType : reflection,
|
reflectionType ? reflectionType : reflection,
|
||||||
"object"
|
"object",
|
||||||
|
false
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -43,11 +44,7 @@ export default function (theme: MarkdownTheme) {
|
|||||||
`${this.flags.isRest ? "... " : ""} **${escapeChars(this.name)}**`
|
`${this.flags.isRest ? "... " : ""} **${escapeChars(this.name)}**`
|
||||||
)
|
)
|
||||||
if (this instanceof DeclarationReflection && this.typeParameters) {
|
if (this instanceof DeclarationReflection && this.typeParameters) {
|
||||||
md.push(
|
md.push(`\`<${this.typeParameters.join(", ")}>\``)
|
||||||
`<${this.typeParameters
|
|
||||||
.map((typeParameter) => `\`${typeParameter.name}\``)
|
|
||||||
.join(", ")}\\>`
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
md.push(getType(this))
|
md.push(getType(this))
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ export default function (theme: MarkdownTheme) {
|
|||||||
const typeParameters = this.model.typeParameters
|
const typeParameters = this.model.typeParameters
|
||||||
.map((typeParameter: ParameterReflection) => typeParameter.name)
|
.map((typeParameter: ParameterReflection) => typeParameter.name)
|
||||||
.join(", ")
|
.join(", ")
|
||||||
title.push(`<${typeParameters}${shouldEscape ? "\\>" : ">"}`)
|
title.push(`\`<${typeParameters}>\``)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (reflectionTitle?.suffix) {
|
if (reflectionTitle?.suffix) {
|
||||||
|
|||||||
+18
-28
@@ -4,7 +4,7 @@ import {
|
|||||||
ReflectionKind,
|
ReflectionKind,
|
||||||
SignatureReflection,
|
SignatureReflection,
|
||||||
} from "typedoc"
|
} from "typedoc"
|
||||||
import { memberSymbol } from "../../utils"
|
import { getHTMLChar, memberSymbol } from "../../utils"
|
||||||
import { MarkdownTheme } from "../../theme"
|
import { MarkdownTheme } from "../../theme"
|
||||||
|
|
||||||
export default function (theme: MarkdownTheme) {
|
export default function (theme: MarkdownTheme) {
|
||||||
@@ -21,30 +21,23 @@ export default function (theme: MarkdownTheme) {
|
|||||||
}
|
}
|
||||||
const md: string[] = []
|
const md: string[] = []
|
||||||
|
|
||||||
|
if (!expandMembers) {
|
||||||
|
md.push("`")
|
||||||
|
}
|
||||||
|
|
||||||
if (standalone && !theme.hideMembersSymbol) {
|
if (standalone && !theme.hideMembersSymbol) {
|
||||||
md.push(`${memberSymbol(this)} `)
|
md.push(`${memberSymbol(this)} `)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.parent && this.parent.flags?.length > 0) {
|
if (this.parent && this.parent.flags?.length > 0) {
|
||||||
md.push(
|
md.push(this.parent.flags.join(" ") + " ")
|
||||||
this.parent.flags
|
|
||||||
.map(
|
|
||||||
(flag) =>
|
|
||||||
`${!expandMembers ? "`" : ""}${flag}${
|
|
||||||
!expandMembers ? "`" : ""
|
|
||||||
}`
|
|
||||||
)
|
|
||||||
.join(" ") + " "
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (accessor) {
|
if (accessor) {
|
||||||
md.push(
|
md.push(
|
||||||
`${!expandMembers ? "`" : ""}${accessor}${
|
`${accessor}${
|
||||||
!expandMembers ? "`" : ""
|
expandMembers ? `${Handlebars.helpers.titleLevel(4)} ` : "**"
|
||||||
} ${expandMembers ? `${Handlebars.helpers.titleLevel(4)} ` : "**"}${
|
}${this.name}${!expandMembers ? "**" : ""}`
|
||||||
this.name
|
|
||||||
}${!expandMembers ? "**" : ""}`
|
|
||||||
)
|
)
|
||||||
} else if (this.name !== "__call" && this.name !== "__type") {
|
} else if (this.name !== "__call" && this.name !== "__type") {
|
||||||
md.push(
|
md.push(
|
||||||
@@ -56,22 +49,19 @@ export default function (theme: MarkdownTheme) {
|
|||||||
|
|
||||||
if (this.typeParameters) {
|
if (this.typeParameters) {
|
||||||
md.push(
|
md.push(
|
||||||
`<${this.typeParameters
|
`${expandMembers ? getHTMLChar("<") : "<"}${this.typeParameters.join(
|
||||||
.map(
|
", "
|
||||||
(typeParameter) =>
|
)}${expandMembers ? getHTMLChar(">") : ">"}`
|
||||||
`${!expandMembers ? "`" : ""}${typeParameter.name}${
|
|
||||||
!expandMembers ? "`" : ""
|
|
||||||
}`
|
|
||||||
)
|
|
||||||
.join(", ")}\\>`
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
md.push(`(${getParameters(this.parameters, !expandMembers)})`)
|
md.push(`(${getParameters(this.parameters, false)})`)
|
||||||
|
|
||||||
if (this.type && !this.parent?.kindOf(ReflectionKind.Constructor)) {
|
if (this.type && !this.parent?.kindOf(ReflectionKind.Constructor)) {
|
||||||
md.push(
|
md.push(`: ${Handlebars.helpers.type.call(this.type, "none", false)}`)
|
||||||
`: ${Handlebars.helpers.type.call(this.type, "none", !expandMembers)}`
|
}
|
||||||
)
|
|
||||||
|
if (!expandMembers) {
|
||||||
|
md.push("`")
|
||||||
}
|
}
|
||||||
return md.join("") + (standalone ? "\n" : "")
|
return md.join("") + (standalone ? "\n" : "")
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
{{#if hasVisibleComponent}}
|
{{#if hasVisibleComponent}}
|
||||||
|
|
||||||
{{{comments this}}}
|
{{{comments this true true 4 model}}}
|
||||||
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
|||||||
+14
-6
@@ -1,10 +1,18 @@
|
|||||||
|
{{#if (sectionEnabled "member_declaration_title")}}
|
||||||
|
|
||||||
{{{declarationTitle}}}
|
{{{declarationTitle}}}
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if (sectionEnabled "member_declaration_comment")}}
|
||||||
|
|
||||||
{{> comment}}
|
{{> comment}}
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{#if (sectionEnabled "member_declaration_example")}}
|
{{#if (sectionEnabled "member_declaration_example")}}
|
||||||
|
|
||||||
{{{example this 4}}}
|
{{{example this 3}}}
|
||||||
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
@@ -12,7 +20,7 @@
|
|||||||
|
|
||||||
{{#if typeParameters}}
|
{{#if typeParameters}}
|
||||||
|
|
||||||
{{titleLevel 4}} Type parameters
|
{{titleLevel 3}} Type parameters
|
||||||
|
|
||||||
{{#with typeParameters}}
|
{{#with typeParameters}}
|
||||||
|
|
||||||
@@ -32,7 +40,7 @@
|
|||||||
|
|
||||||
{{#with type.declaration.indexSignature}}
|
{{#with type.declaration.indexSignature}}
|
||||||
|
|
||||||
{{titleLevel 4}} Index signature
|
{{titleLevel 3}} Index signature
|
||||||
|
|
||||||
{{{indexSignatureTitle}}}
|
{{{indexSignatureTitle}}}
|
||||||
|
|
||||||
@@ -50,11 +58,11 @@
|
|||||||
|
|
||||||
{{#if type.declaration.children}}
|
{{#if type.declaration.children}}
|
||||||
|
|
||||||
{{titleLevel 4}} Call signature
|
{{titleLevel 3}} Call signature
|
||||||
|
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
||||||
{{titleLevel 4}} Type declaration
|
{{titleLevel 3}} Type declaration
|
||||||
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
@@ -74,7 +82,7 @@
|
|||||||
|
|
||||||
{{#with type.declaration}}
|
{{#with type.declaration}}
|
||||||
|
|
||||||
{{titleLevel 4}} Type declaration
|
{{titleLevel 3}} Type declaration
|
||||||
|
|
||||||
{{/with}}
|
{{/with}}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ export type ObjectLiteralDeclarationStyle = "table" | "list" | "component"
|
|||||||
|
|
||||||
export type SectionKey =
|
export type SectionKey =
|
||||||
| "comment"
|
| "comment"
|
||||||
|
| "member_declaration"
|
||||||
|
| "member_declaration_title"
|
||||||
|
| "member_declaration_comment"
|
||||||
| "member_declaration_typeParameters"
|
| "member_declaration_typeParameters"
|
||||||
| "member_declaration_indexSignature"
|
| "member_declaration_indexSignature"
|
||||||
| "member_declaration_signatures"
|
| "member_declaration_signatures"
|
||||||
@@ -29,7 +32,6 @@ export type SectionKey =
|
|||||||
| "member_signatures"
|
| "member_signatures"
|
||||||
| "member_getterSetter"
|
| "member_getterSetter"
|
||||||
| "member_reference"
|
| "member_reference"
|
||||||
| "member_declaration"
|
|
||||||
| "member_signature_title"
|
| "member_signature_title"
|
||||||
| "member_signature_comment"
|
| "member_signature_comment"
|
||||||
| "member_signature_typeParameters"
|
| "member_signature_typeParameters"
|
||||||
|
|||||||
@@ -16,13 +16,17 @@ export function formatContents(contents: string) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function escapeChars(str: string) {
|
export function getHTMLChar(str: string) {
|
||||||
return str
|
return str
|
||||||
.replace(/>/g, "\\>")
|
.replace(/</g, "<")
|
||||||
.replace(/>/g, "\\>")
|
.replace(/{/g, "{")
|
||||||
.replace(/_/g, "\\_")
|
.replace(/}/g, "}")
|
||||||
.replace(/`/g, "\\`")
|
.replace(/>/g, ">")
|
||||||
.replace(/\|/g, "\\|")
|
}
|
||||||
|
|
||||||
|
export function escapeChars(str: string, escapeBackticks = true) {
|
||||||
|
const result = getHTMLChar(str).replace(/_/g, "\\_").replace(/\|/g, "\\|")
|
||||||
|
return escapeBackticks ? result.replace(/`/g, "\\`") : result
|
||||||
}
|
}
|
||||||
|
|
||||||
export function memberSymbol(
|
export function memberSymbol(
|
||||||
|
|||||||
+13
-6
@@ -1,4 +1,9 @@
|
|||||||
import { Comment, ReflectionKind, ReflectionType } from "typedoc"
|
import {
|
||||||
|
Comment,
|
||||||
|
DeclarationReflection,
|
||||||
|
ReflectionKind,
|
||||||
|
ReflectionType,
|
||||||
|
} from "typedoc"
|
||||||
import * as Handlebars from "handlebars"
|
import * as Handlebars from "handlebars"
|
||||||
import { stripCode, stripLineBreaks } from "../utils"
|
import { stripCode, stripLineBreaks } from "../utils"
|
||||||
import { Parameter, ParameterStyle, ReflectionParameterType } from "../types"
|
import { Parameter, ParameterStyle, ReflectionParameterType } from "../types"
|
||||||
@@ -72,7 +77,7 @@ export function reflectionListFormatter(
|
|||||||
: getTypeChildren(reflection.type!, reflection.project)
|
: getTypeChildren(reflection.type!, reflection.project)
|
||||||
const itemChildren: string[] = []
|
const itemChildren: string[] = []
|
||||||
let itemChildrenKind: ReflectionKind | null = null
|
let itemChildrenKind: ReflectionKind | null = null
|
||||||
children?.forEach((childItem) => {
|
children?.forEach((childItem: DeclarationReflection) => {
|
||||||
if (!itemChildrenKind) {
|
if (!itemChildrenKind) {
|
||||||
itemChildrenKind = childItem.kind
|
itemChildrenKind = childItem.kind
|
||||||
}
|
}
|
||||||
@@ -102,7 +107,7 @@ export function reflectionComponentFormatter(
|
|||||||
name: reflection.name,
|
name: reflection.name,
|
||||||
type: reflection.type
|
type: reflection.type
|
||||||
? getType(reflection.type, "object")
|
? getType(reflection.type, "object")
|
||||||
: getReflectionType(reflection, "object"),
|
: getReflectionType(reflection, "object", true),
|
||||||
description: comments
|
description: comments
|
||||||
? stripLineBreaks(Handlebars.helpers.comments(comments, true, false))
|
? stripLineBreaks(Handlebars.helpers.comments(comments, true, false))
|
||||||
: "",
|
: "",
|
||||||
@@ -124,8 +129,10 @@ export function reflectionComponentFormatter(
|
|||||||
: getTypeChildren(reflection.type!, reflection.project)
|
: getTypeChildren(reflection.type!, reflection.project)
|
||||||
|
|
||||||
children
|
children
|
||||||
?.filter((childItem) => childItem.kindOf(ALLOWED_KINDS))
|
?.filter((childItem: DeclarationReflection) =>
|
||||||
.forEach((childItem) => {
|
childItem.kindOf(ALLOWED_KINDS)
|
||||||
|
)
|
||||||
|
.forEach((childItem: DeclarationReflection) => {
|
||||||
componentItem.children?.push(
|
componentItem.children?.push(
|
||||||
reflectionComponentFormatter(childItem, level + 1, maxLevel)
|
reflectionComponentFormatter(childItem, level + 1, maxLevel)
|
||||||
)
|
)
|
||||||
@@ -163,7 +170,7 @@ export function reflectionTableFormatter(
|
|||||||
row.push(
|
row.push(
|
||||||
parameter.type
|
parameter.type
|
||||||
? Handlebars.helpers.type.call(parameter.type, "object")
|
? Handlebars.helpers.type.call(parameter.type, "object")
|
||||||
: getReflectionType(parameter, "object")
|
: getReflectionType(parameter, "object", true)
|
||||||
)
|
)
|
||||||
|
|
||||||
if (showDefaults) {
|
if (showDefaults) {
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ export function returnReflectionComponentFormatter(
|
|||||||
level = 1,
|
level = 1,
|
||||||
maxLevel?: number | undefined
|
maxLevel?: number | undefined
|
||||||
): Parameter[] {
|
): Parameter[] {
|
||||||
const typeName = getType(reflectionType, "object", false)
|
const typeName = getType(reflectionType, "object", false, true)
|
||||||
const type = getType(reflectionType, "object")
|
const type = getType(reflectionType, "object")
|
||||||
const componentItem: Parameter[] = []
|
const componentItem: Parameter[] = []
|
||||||
if (reflectionType.type === "reference") {
|
if (reflectionType.type === "reference") {
|
||||||
|
|||||||
@@ -20,33 +20,34 @@ import {
|
|||||||
} from "typedoc"
|
} from "typedoc"
|
||||||
import * as Handlebars from "handlebars"
|
import * as Handlebars from "handlebars"
|
||||||
import { ReflectionParameterType } from "../types"
|
import { ReflectionParameterType } from "../types"
|
||||||
import { escapeChars } from "../utils"
|
import { escapeChars, getHTMLChar } from "../utils"
|
||||||
|
|
||||||
export type Collapse = "object" | "function" | "all" | "none"
|
export type Collapse = "object" | "function" | "all" | "none"
|
||||||
|
|
||||||
export default function getType(
|
export default function getType(
|
||||||
reflectionType: SomeType,
|
reflectionType: SomeType,
|
||||||
collapse: Collapse = "none",
|
collapse: Collapse = "none",
|
||||||
emphasis = true
|
emphasis = true,
|
||||||
|
hideLink = false
|
||||||
): string {
|
): string {
|
||||||
if (reflectionType instanceof ReferenceType) {
|
if (reflectionType instanceof ReferenceType) {
|
||||||
return getReferenceType(reflectionType, emphasis)
|
return getReferenceType(reflectionType, emphasis, hideLink)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reflectionType instanceof ArrayType && reflectionType.elementType) {
|
if (reflectionType instanceof ArrayType && reflectionType.elementType) {
|
||||||
return getArrayType(reflectionType, emphasis)
|
return getArrayType(reflectionType, emphasis, hideLink)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reflectionType instanceof UnionType && reflectionType.types) {
|
if (reflectionType instanceof UnionType && reflectionType.types) {
|
||||||
return getUnionType(reflectionType, emphasis)
|
return getUnionType(reflectionType, emphasis, hideLink)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reflectionType instanceof IntersectionType && reflectionType.types) {
|
if (reflectionType instanceof IntersectionType && reflectionType.types) {
|
||||||
return getIntersectionType(reflectionType)
|
return getIntersectionType(reflectionType, emphasis, hideLink)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reflectionType instanceof TupleType && reflectionType.elements) {
|
if (reflectionType instanceof TupleType && reflectionType.elements) {
|
||||||
return getTupleType(reflectionType)
|
return getTupleType(reflectionType, emphasis, hideLink)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reflectionType instanceof IntrinsicType && reflectionType.name) {
|
if (reflectionType instanceof IntrinsicType && reflectionType.name) {
|
||||||
@@ -54,27 +55,32 @@ export default function getType(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (reflectionType instanceof ReflectionType) {
|
if (reflectionType instanceof ReflectionType) {
|
||||||
return getReflectionType(reflectionType.declaration, collapse)
|
return getReflectionType(
|
||||||
|
reflectionType.declaration,
|
||||||
|
collapse,
|
||||||
|
emphasis,
|
||||||
|
hideLink
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reflectionType instanceof DeclarationReflection) {
|
if (reflectionType instanceof DeclarationReflection) {
|
||||||
return getReflectionType(reflectionType, collapse)
|
return getReflectionType(reflectionType, collapse, emphasis, hideLink)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reflectionType instanceof TypeOperatorType) {
|
if (reflectionType instanceof TypeOperatorType) {
|
||||||
return getTypeOperatorType(reflectionType)
|
return getTypeOperatorType(reflectionType, emphasis, hideLink)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reflectionType instanceof QueryType) {
|
if (reflectionType instanceof QueryType) {
|
||||||
return getQueryType(reflectionType)
|
return getQueryType(reflectionType, emphasis, hideLink)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reflectionType instanceof ConditionalType) {
|
if (reflectionType instanceof ConditionalType) {
|
||||||
return getConditionalType(reflectionType)
|
return getConditionalType(reflectionType, emphasis, hideLink)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reflectionType instanceof IndexedAccessType) {
|
if (reflectionType instanceof IndexedAccessType) {
|
||||||
return getIndexAccessType(reflectionType)
|
return getIndexAccessType(reflectionType, emphasis, hideLink)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reflectionType instanceof UnknownType) {
|
if (reflectionType instanceof UnknownType) {
|
||||||
@@ -86,7 +92,7 @@ export default function getType(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (reflectionType instanceof LiteralType) {
|
if (reflectionType instanceof LiteralType) {
|
||||||
return getLiteralType(reflectionType)
|
return getLiteralType(reflectionType, emphasis)
|
||||||
}
|
}
|
||||||
|
|
||||||
return reflectionType ? escapeChars(reflectionType.toString()) : ""
|
return reflectionType ? escapeChars(reflectionType.toString()) : ""
|
||||||
@@ -94,148 +100,203 @@ export default function getType(
|
|||||||
|
|
||||||
export function getReflectionType(
|
export function getReflectionType(
|
||||||
model: ReflectionParameterType,
|
model: ReflectionParameterType,
|
||||||
collapse: Collapse
|
collapse: Collapse,
|
||||||
|
emphasis: boolean,
|
||||||
|
hideLink = false
|
||||||
): string {
|
): string {
|
||||||
if ("signatures" in model && model.signatures) {
|
if ("signatures" in model && model.signatures) {
|
||||||
return collapse === "function" || collapse === "all"
|
return collapse === "function" || collapse === "all"
|
||||||
? `\`fn\``
|
? `${emphasis ? "`" : ""}fn${emphasis ? "`" : ""}`
|
||||||
: getFunctionType(model.signatures)
|
: getFunctionType(model.signatures, emphasis, hideLink)
|
||||||
}
|
}
|
||||||
return collapse === "object" || collapse === "all"
|
return collapse === "object" || collapse === "all"
|
||||||
? `\`object\``
|
? `${emphasis ? "`" : ""}object${emphasis ? "`" : ""}`
|
||||||
: getDeclarationType(model as DeclarationReflection)
|
: `${emphasis ? "`" : ""}${getDeclarationType(
|
||||||
|
model as DeclarationReflection,
|
||||||
|
false,
|
||||||
|
hideLink
|
||||||
|
)}${emphasis ? "`" : ""}`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDeclarationType(model: DeclarationReflection): string {
|
export function getDeclarationType(
|
||||||
|
model: DeclarationReflection,
|
||||||
|
emphasis: boolean,
|
||||||
|
hideLink = false
|
||||||
|
): string {
|
||||||
if (model.indexSignature || model.children) {
|
if (model.indexSignature || model.children) {
|
||||||
let indexSignature = ""
|
let indexSignature = ""
|
||||||
const declarationIndexSignature = model.indexSignature
|
const declarationIndexSignature = model.indexSignature
|
||||||
if (declarationIndexSignature) {
|
if (declarationIndexSignature) {
|
||||||
const key = declarationIndexSignature.parameters
|
const key = declarationIndexSignature.parameters
|
||||||
? declarationIndexSignature.parameters.map(
|
? declarationIndexSignature.parameters.map(
|
||||||
(param) => `\`[${param.name}: ${param.type}]\``
|
(param) => `[${param.name}: ${param.type}]`
|
||||||
)
|
)
|
||||||
: ""
|
: ""
|
||||||
const obj = declarationIndexSignature.type
|
const obj = declarationIndexSignature.type
|
||||||
? getType(declarationIndexSignature.type)
|
? getType(declarationIndexSignature.type, "none", false, hideLink)
|
||||||
: ""
|
: ""
|
||||||
indexSignature = `${key}: ${obj}; `
|
indexSignature = `${key}: ${obj}; `
|
||||||
}
|
}
|
||||||
const types =
|
const types =
|
||||||
model.children &&
|
model.children &&
|
||||||
model.children.map((obj) => {
|
model.children.map((obj) => {
|
||||||
return `\`${obj.name}${obj.flags.isOptional ? "?" : ""}\`: ${
|
return `${obj.name}${obj.flags.isOptional ? "?" : ""}: ${
|
||||||
obj.type ? getType(obj.type) : escapeChars(obj.toString())
|
obj.type
|
||||||
|
? getType(obj.type, "none", false, hideLink)
|
||||||
|
: escapeChars(obj.toString())
|
||||||
} ${
|
} ${
|
||||||
obj.defaultValue && obj.defaultValue !== "..."
|
obj.defaultValue && obj.defaultValue !== "..."
|
||||||
? `= ${escapeChars(`${obj.defaultValue}`)}`
|
? `= ${escapeChars(`${obj.defaultValue}`)}`
|
||||||
: ""
|
: ""
|
||||||
}`
|
}`
|
||||||
})
|
})
|
||||||
return `{ ${indexSignature ? indexSignature : ""}${
|
return `${emphasis ? "`{" : getHTMLChar("{")} ${
|
||||||
types ? types.join("; ") : ""
|
indexSignature ? indexSignature : ""
|
||||||
} }${
|
}${types ? types.join("; ") : ""} ${emphasis ? "}`" : getHTMLChar("}")}${
|
||||||
model.defaultValue && model.defaultValue !== "..."
|
model.defaultValue && model.defaultValue !== "..."
|
||||||
? `= ${escapeChars(`${model.defaultValue}`)}`
|
? `= ${escapeChars(`${model.defaultValue}`)}`
|
||||||
: ""
|
: ""
|
||||||
}`
|
}`
|
||||||
}
|
}
|
||||||
return "{}"
|
return emphasis ? "`{}`" : escapeChars("{}")
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getFunctionType(
|
export function getFunctionType(
|
||||||
modelSignatures: SignatureReflection[]
|
modelSignatures: SignatureReflection[],
|
||||||
|
emphasis: boolean,
|
||||||
|
hideLink = false
|
||||||
): string {
|
): string {
|
||||||
const functions = modelSignatures.map((fn) => {
|
const functions = modelSignatures.map((fn) => {
|
||||||
const typeParams = fn.typeParameters
|
const typeParams = fn.typeParameters
|
||||||
? `<${fn.typeParameters
|
? `${emphasis ? "`<" : getHTMLChar("<")}${fn.typeParameters
|
||||||
.map((typeParameter) => typeParameter.name)
|
.map((typeParameter) => typeParameter.name)
|
||||||
.join(", ")}\\>`
|
.join(", ")}${emphasis ? ">`" : getHTMLChar(">")}`
|
||||||
: []
|
: []
|
||||||
const params = fn.parameters
|
const params = fn.parameters
|
||||||
? fn.parameters.map((param) => {
|
? fn.parameters.map((param) => {
|
||||||
return `${param.flags.isRest ? "..." : ""}\`${param.name}${
|
return `${param.flags.isRest ? "..." : ""}${emphasis ? "`" : ""}${
|
||||||
param.flags.isOptional ? "?" : ""
|
param.name
|
||||||
}\`: ${
|
}${param.flags.isOptional ? "?" : ""}${emphasis ? "`" : ""}: ${
|
||||||
param.type ? getType(param.type) : escapeChars(param.toString())
|
param.type
|
||||||
|
? getType(param.type, "none", emphasis, hideLink)
|
||||||
|
: escapeChars(param.toString())
|
||||||
}`
|
}`
|
||||||
})
|
})
|
||||||
: []
|
: []
|
||||||
const returns = fn.type ? getType(fn.type) : escapeChars(fn.toString())
|
const returns = fn.type
|
||||||
|
? getType(fn.type, "none", emphasis, hideLink)
|
||||||
|
: escapeChars(fn.toString())
|
||||||
return typeParams + `(${params.join(", ")}) => ${returns}`
|
return typeParams + `(${params.join(", ")}) => ${returns}`
|
||||||
})
|
})
|
||||||
return functions.join("")
|
return functions.join("")
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLiteralType(model: LiteralType): string {
|
export function getLiteralType(model: LiteralType, emphasis: boolean): string {
|
||||||
if (typeof model.value === "bigint") {
|
if (typeof model.value === "bigint") {
|
||||||
return `\`${model.value}n\``
|
return `${emphasis ? "`" : ""}${model.value}n${emphasis ? "`" : ""}`
|
||||||
}
|
}
|
||||||
return `\`\`${JSON.stringify(model.value)}\`\``
|
return `${emphasis ? "`" : ""}\`${JSON.stringify(model.value)}\`${
|
||||||
|
emphasis ? "`" : ""
|
||||||
|
}`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getReferenceType(
|
export function getReferenceType(
|
||||||
model: ReferenceType,
|
model: ReferenceType,
|
||||||
emphasis: boolean
|
emphasis: boolean,
|
||||||
|
hideLink = false
|
||||||
): string {
|
): string {
|
||||||
const shouldShowLink = emphasis && model.name !== "Record"
|
const shouldShowLink = !hideLink && model.name !== "Record"
|
||||||
|
const wrappingBackticks = emphasis && !shouldShowLink
|
||||||
if (model.reflection || (model.name && model.typeArguments)) {
|
if (model.reflection || (model.name && model.typeArguments)) {
|
||||||
const reflection: string[] = []
|
const reflection: string[] = [wrappingBackticks ? "`" : ""]
|
||||||
|
|
||||||
if (model.reflection?.url) {
|
if (model.reflection?.url) {
|
||||||
reflection.push(
|
reflection.push(
|
||||||
shouldShowLink
|
shouldShowLink
|
||||||
? `[${`\`${model.reflection.name}\``}](${Handlebars.helpers.relativeURL(
|
? `[${model.reflection.name}](${Handlebars.helpers.relativeURL(
|
||||||
model.reflection.url
|
model.reflection.url
|
||||||
)})`
|
)})`
|
||||||
: model.reflection.name
|
: emphasis
|
||||||
|
? model.reflection.name
|
||||||
|
: escapeChars(model.reflection.name)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
reflection.push(
|
reflection.push(
|
||||||
shouldShowLink
|
shouldShowLink
|
||||||
? model.externalUrl
|
? model.externalUrl
|
||||||
? `[${`\`${model.name}\``}]( ${model.externalUrl} )`
|
? `[${model.name}]( ${model.externalUrl} )`
|
||||||
: `\`${model.name}\``
|
|
||||||
: model.name
|
: model.name
|
||||||
|
: emphasis
|
||||||
|
? model.name
|
||||||
|
: escapeChars(model.name)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (model.typeArguments && model.typeArguments.length > 0) {
|
if (model.typeArguments && model.typeArguments.length > 0) {
|
||||||
reflection.push(
|
reflection.push(
|
||||||
`<${model.typeArguments
|
`${wrappingBackticks ? "<" : getHTMLChar("<")}${model.typeArguments
|
||||||
.map((typeArgument) => getType(typeArgument, "none", emphasis))
|
.map((typeArgument) => getType(typeArgument, "none", false, hideLink))
|
||||||
.join(", ")}\\>`
|
.join(", ")}${wrappingBackticks ? ">" : getHTMLChar(">")}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if (wrappingBackticks) {
|
||||||
|
reflection.push("`")
|
||||||
|
}
|
||||||
return reflection.join("")
|
return reflection.join("")
|
||||||
}
|
}
|
||||||
return shouldShowLink
|
return shouldShowLink
|
||||||
? model.externalUrl
|
? model.externalUrl
|
||||||
? `[${`\`${model.name}\``}]( ${model.externalUrl} )`
|
? `[${emphasis ? `\`${model.name}\`` : escapeChars(model.name)}]( ${
|
||||||
: `\`${model.name}\``
|
model.externalUrl
|
||||||
|
} )`
|
||||||
|
: emphasis
|
||||||
|
? `\`${model.name}\``
|
||||||
|
: escapeChars(model.name)
|
||||||
|
: emphasis
|
||||||
|
? `\`${model.name}\``
|
||||||
: escapeChars(model.name)
|
: escapeChars(model.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getArrayType(model: ArrayType, emphasis: boolean): string {
|
export function getArrayType(
|
||||||
const arrayType = getType(model.elementType, "none", emphasis)
|
model: ArrayType,
|
||||||
|
emphasis: boolean,
|
||||||
|
hideLink = false
|
||||||
|
): string {
|
||||||
|
const arrayType = getType(model.elementType, "none", emphasis, hideLink)
|
||||||
return model.elementType.type === "union"
|
return model.elementType.type === "union"
|
||||||
? `(${arrayType})[]`
|
? `(${arrayType})[]`
|
||||||
: `${arrayType}[]`
|
: `${arrayType}[]`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getUnionType(model: UnionType, emphasis: boolean): string {
|
export function getUnionType(
|
||||||
|
model: UnionType,
|
||||||
|
emphasis: boolean,
|
||||||
|
hideLink = false
|
||||||
|
): string {
|
||||||
return model.types
|
return model.types
|
||||||
.map((unionType) => getType(unionType, "none", emphasis))
|
.map((unionType) => getType(unionType, "none", emphasis, hideLink))
|
||||||
.join(` \\| `)
|
.join(` \\| `)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getIntersectionType(model: IntersectionType): string {
|
export function getIntersectionType(
|
||||||
|
model: IntersectionType,
|
||||||
|
emphasis: boolean,
|
||||||
|
hideLink = false
|
||||||
|
): string {
|
||||||
return model.types
|
return model.types
|
||||||
.map((intersectionType) => getType(intersectionType))
|
.map((intersectionType) =>
|
||||||
|
getType(intersectionType, "none", emphasis, hideLink)
|
||||||
|
)
|
||||||
.join(" & ")
|
.join(" & ")
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTupleType(model: TupleType): string {
|
export function getTupleType(
|
||||||
return `[${model.elements.map((element) => getType(element)).join(", ")}]`
|
model: TupleType,
|
||||||
|
emphasis: boolean,
|
||||||
|
hideLink = false
|
||||||
|
): string {
|
||||||
|
return `[${model.elements
|
||||||
|
.map((element) => getType(element, "none", emphasis, hideLink))
|
||||||
|
.join(", ")}]`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getIntrinsicType(
|
export function getIntrinsicType(
|
||||||
@@ -245,12 +306,25 @@ export function getIntrinsicType(
|
|||||||
return emphasis ? `\`${model.name}\`` : escapeChars(model.name)
|
return emphasis ? `\`${model.name}\`` : escapeChars(model.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTypeOperatorType(model: TypeOperatorType): string {
|
export function getTypeOperatorType(
|
||||||
return `${model.operator} ${getType(model.target)}`
|
model: TypeOperatorType,
|
||||||
|
emphasis: boolean,
|
||||||
|
hideLink = false
|
||||||
|
): string {
|
||||||
|
return `${model.operator} ${getType(
|
||||||
|
model.target,
|
||||||
|
"none",
|
||||||
|
emphasis,
|
||||||
|
hideLink
|
||||||
|
)}`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getQueryType(model: QueryType): string {
|
export function getQueryType(
|
||||||
return `typeof ${getType(model.queryType)}`
|
model: QueryType,
|
||||||
|
emphasis: boolean,
|
||||||
|
hideLink = false
|
||||||
|
): string {
|
||||||
|
return `typeof ${getType(model.queryType, "none", emphasis, hideLink)}`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getInferredType(model: InferredType): string {
|
export function getInferredType(model: InferredType): string {
|
||||||
@@ -261,33 +335,41 @@ export function getUnknownType(model: UnknownType): string {
|
|||||||
return escapeChars(model.name)
|
return escapeChars(model.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getConditionalType(model: ConditionalType): string {
|
export function getConditionalType(
|
||||||
|
model: ConditionalType,
|
||||||
|
emphasis: boolean,
|
||||||
|
hideLink = false
|
||||||
|
): string {
|
||||||
const md: string[] = []
|
const md: string[] = []
|
||||||
if (model.checkType) {
|
if (model.checkType) {
|
||||||
md.push(getType(model.checkType))
|
md.push(getType(model.checkType, "none", emphasis, hideLink))
|
||||||
}
|
}
|
||||||
md.push("extends")
|
md.push("extends")
|
||||||
if (model.extendsType) {
|
if (model.extendsType) {
|
||||||
md.push(getType(model.extendsType))
|
md.push(getType(model.extendsType, "none", emphasis, hideLink))
|
||||||
}
|
}
|
||||||
md.push("?")
|
md.push("?")
|
||||||
if (model.trueType) {
|
if (model.trueType) {
|
||||||
md.push(getType(model.trueType))
|
md.push(getType(model.trueType, "none", emphasis, hideLink))
|
||||||
}
|
}
|
||||||
md.push(":")
|
md.push(":")
|
||||||
if (model.falseType) {
|
if (model.falseType) {
|
||||||
md.push(getType(model.falseType))
|
md.push(getType(model.falseType, "none", emphasis, hideLink))
|
||||||
}
|
}
|
||||||
return md.join(" ")
|
return md.join(" ")
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getIndexAccessType(model: IndexedAccessType): string {
|
export function getIndexAccessType(
|
||||||
|
model: IndexedAccessType,
|
||||||
|
emphasis: boolean,
|
||||||
|
hideLink = false
|
||||||
|
): string {
|
||||||
const md: string[] = []
|
const md: string[] = []
|
||||||
if (model.objectType) {
|
if (model.objectType) {
|
||||||
md.push(getType(model.objectType))
|
md.push(getType(model.objectType, "none", emphasis, hideLink))
|
||||||
}
|
}
|
||||||
if (model.indexType) {
|
if (model.indexType) {
|
||||||
md.push(`[${getType(model.indexType)}]`)
|
md.push(`[${getType(model.indexType, "none", false, hideLink)}]`)
|
||||||
}
|
}
|
||||||
return md.join("")
|
return md.join("")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ export class FlagRouter implements FeatureFlagTypes.IFlagRouter {
|
|||||||
/**
|
/**
|
||||||
* Sets a feature flag.
|
* Sets a feature flag.
|
||||||
* Flags take two shapes:
|
* Flags take two shapes:
|
||||||
* setFlag("myFeatureFlag", true)
|
* `setFlag("myFeatureFlag", true)`
|
||||||
* setFlag("myFeatureFlag", { nestedFlag: true })
|
* `setFlag("myFeatureFlag", { nestedFlag: true })`
|
||||||
* These shapes are used for top-level and nested flags respectively, as explained in isFeatureEnabled.
|
* These shapes are used for top-level and nested flags respectively, as explained in isFeatureEnabled.
|
||||||
* @param key - The key of the flag to set.
|
* @param key - The key of the flag to set.
|
||||||
* @param value - The value of the flag to set.
|
* @param value - The value of the flag to set.
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -351,26 +351,26 @@ import TabItem from '@theme/TabItem';
|
|||||||
|
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.uploads.create(file) // file is an instance of File
|
medusa.admin.uploads.create(file) // file is an instance of File
|
||||||
.then(({ uploads }) => {
|
.then(({ uploads }) => {
|
||||||
const key = uploads[0].key
|
const key = uploads[0].key
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/uploads' \
|
curl -L -X POST '<BACKEND_URL>/admin/uploads' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: text/csv' \
|
-H 'Content-Type: text/csv' \
|
||||||
-F 'files=@"<FILE_PATH_1>"'
|
-F 'files=@"<FILE_PATH_1>"'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
|
|||||||
@@ -63,62 +63,53 @@ In your terminal, run the following command:
|
|||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>
|
<Summary>Command Options</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`.
|
- `--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.
|
- `--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-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.
|
- `--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.
|
- `--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.
|
- `--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`.
|
- `--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.
|
- `--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`.
|
- `--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>
|
||||||
|
|
||||||
</details>
|
<Details className="border-t-0">
|
||||||
|
<Summary>Example: Connect to a Vercel PostgreSQL Database</Summary>
|
||||||
|
|
||||||
<details className="border-t-0">
|
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:
|
||||||
<summary>
|
|
||||||
Example: Connect to a Vercel PostgreSQL Database
|
|
||||||
</summary>
|
|
||||||
|
|
||||||
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:
|
```bash
|
||||||
|
npx create-medusa-app@latest --db-url "postgres://default:<password><host-region>.postgres.vercel-storage.com:5432/verceldb?sslmode=require"
|
||||||
|
```
|
||||||
|
|
||||||
```bash
|
:::note
|
||||||
npx create-medusa-app@latest --db-url "postgres://default:<password><host-region>.postgres.vercel-storage.com:5432/verceldb?sslmode=require"
|
|
||||||
```
|
|
||||||
|
|
||||||
:::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.
|
||||||
|
|
||||||
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 className="border-t-0">
|
||||||
|
<Summary>Example: Connect to a Supabase Database</Summary>
|
||||||
|
|
||||||
</details>
|
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 className="border-t-0">
|
```bash
|
||||||
<summary>
|
npx create-medusa-app@latest --db-url postgresql://postgres:<password>@<host>.supabase.co:5432/postgres
|
||||||
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:
|
:::note
|
||||||
|
|
||||||
```bash
|
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.
|
||||||
npx create-medusa-app@latest --db-url postgresql://postgres:<password>@<host>.supabase.co:5432/postgres
|
|
||||||
```
|
|
||||||
|
|
||||||
:::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>
|
|
||||||
|
|
||||||
## Step 2: Specify Project Name
|
## 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:
|
If you also don't have a Medusa project, you can deploy to Railway instantly with this button:
|
||||||
|
|
||||||
<a
|
<a
|
||||||
href="https://railway.app/template/zC7eOq?referralCode=TW4Qi0" class="img-url 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" class="no-zoom-img"/>
|
<img src="https://railway.app/button.svg" alt="Deploy with Railway" className="no-zoom-img"/>
|
||||||
</a>
|
</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.
|
Alternatively, you can directly deploy the Next.js Starter Template to Vercel with this button.
|
||||||
|
|
||||||
<a
|
<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">
|
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" class="no-zoom-img"/>
|
<img src="https://vercel.com/button" alt="Deploy with Vercel" className="no-zoom-img"/>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
:::note
|
:::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`:
|
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}>
|
<Tabs groupId="endpoint-type" isCodeTabs={true}>
|
||||||
<TabItem value="storefront" label="Storefront CORS" default>
|
<TabItem value="storefront" label="Storefront CORS" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const storeCorsOptions = {
|
const storeCorsOptions = {
|
||||||
origin: projectConfig.store_cors.split(","),
|
origin: projectConfig.store_cors.split(","),
|
||||||
credentials: true,
|
credentials: true,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="admin" label="Admin CORS">
|
<TabItem value="admin" label="Admin CORS">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const adminCorsOptions = {
|
const adminCorsOptions = {
|
||||||
origin: projectConfig.admin_cors.split(","),
|
origin: projectConfig.admin_cors.split(","),
|
||||||
credentials: true,
|
credentials: true,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
Finally, you can either pass the `cors` middleware for a specific route, or pass it to the entire router:
|
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}>
|
<Tabs groupId="pass-type" isCodeTabs={true}>
|
||||||
<TabItem value="single" label="Pass to Endpoint" default>
|
<TabItem value="single" label="Pass to Endpoint" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
adminRouter.options("/admin/hello", cors(adminCorsOptions))
|
adminRouter.options("/admin/hello", cors(adminCorsOptions))
|
||||||
adminRouter.get(
|
adminRouter.get(
|
||||||
"/admin/hello",
|
"/admin/hello",
|
||||||
cors(adminCorsOptions),
|
cors(adminCorsOptions),
|
||||||
(req, res) => {
|
(req, res) => {
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="router" label="Pass to Router">
|
<TabItem value="router" label="Pass to Router">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
adminRouter.use(cors(adminCorsOptions))
|
adminRouter.use(cors(adminCorsOptions))
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -252,12 +252,12 @@ import { requireCustomerAuthentication } from "@medusajs/medusa"
|
|||||||
Then, pass the middleware to either a single route or an entire router:
|
Then, pass the middleware to either a single route or an entire router:
|
||||||
|
|
||||||
<Tabs groupId="pass-type" isCodeTabs={true}>
|
<Tabs groupId="pass-type" isCodeTabs={true}>
|
||||||
<TabItem value="single" label="Pass to Endpoint" default>
|
<TabItem value="single" label="Pass to Endpoint" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
// only necessary if you're passing cors options per route
|
// only necessary if you're passing cors options per route
|
||||||
router.options("/store/hello", cors(storeCorsOptions))
|
router.options("/store/hello", cors(storeCorsOptions))
|
||||||
router.get(
|
router.get(
|
||||||
"/store/hello",
|
"/store/hello",
|
||||||
cors(storeCorsOptions),
|
cors(storeCorsOptions),
|
||||||
requireCustomerAuthentication(),
|
requireCustomerAuthentication(),
|
||||||
@@ -273,22 +273,22 @@ router.get(
|
|||||||
const customer = await customerService.retrieve(id)
|
const customer = await customerService.retrieve(id)
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="router" label="Pass to Router">
|
<TabItem value="router" label="Pass to Router">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
storeRouter.use(requireCustomerAuthentication())
|
storeRouter.use(requireCustomerAuthentication())
|
||||||
// all routes added to storeRouter are now protected
|
// all routes added to storeRouter are now protected
|
||||||
// the logged in customer can be accessed using:
|
// the logged in customer can be accessed using:
|
||||||
// req.user.customer_id
|
// req.user.customer_id
|
||||||
|
|
||||||
// storeRouter.use(authenticateCustomer())
|
// storeRouter.use(authenticateCustomer())
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
### Protect Admin Routes
|
### Protect Admin Routes
|
||||||
@@ -304,12 +304,12 @@ import { authenticate } from "@medusajs/medusa"
|
|||||||
Then, pass the middleware to either a single route or an entire router:
|
Then, pass the middleware to either a single route or an entire router:
|
||||||
|
|
||||||
<Tabs groupId="pass-type" isCodeTabs={true}>
|
<Tabs groupId="pass-type" isCodeTabs={true}>
|
||||||
<TabItem value="single" label="Pass to Endpoint" default>
|
<TabItem value="single" label="Pass to Endpoint" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
// only necessary if you're passing cors options per route
|
// only necessary if you're passing cors options per route
|
||||||
adminRouter.options("/admin/hello", cors(adminCorsOptions))
|
adminRouter.options("/admin/hello", cors(adminCorsOptions))
|
||||||
adminRouter.get(
|
adminRouter.get(
|
||||||
"/admin/hello",
|
"/admin/hello",
|
||||||
cors(adminCorsOptions),
|
cors(adminCorsOptions),
|
||||||
authenticate(),
|
authenticate(),
|
||||||
@@ -321,20 +321,20 @@ adminRouter.get(
|
|||||||
const user = await userService.retrieve(id)
|
const user = await userService.retrieve(id)
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="router" label="Pass to Router">
|
<TabItem value="router" label="Pass to Router">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
adminRouter.use(authenticate())
|
adminRouter.use(authenticate())
|
||||||
// all routes added to adminRouter are now protected
|
// all routes added to adminRouter are now protected
|
||||||
// the logged in user can be accessed using:
|
// the logged in user can be accessed using:
|
||||||
// req.user.userId
|
// req.user.userId
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -628,15 +628,15 @@ 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.
|
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}>
|
<Tabs groupId="files" isCodeTabs={true}>
|
||||||
<TabItem value="index" label="src/api/index.ts" default>
|
<TabItem value="index" label="src/api/index.ts" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import express, { Router } from "express"
|
import express, { Router } from "express"
|
||||||
import adminRoutes from "./admin"
|
import adminRoutes from "./admin"
|
||||||
import storeRoutes from "./store"
|
import storeRoutes from "./store"
|
||||||
import { errorHandler } from "@medusajs/medusa"
|
import { errorHandler } from "@medusajs/medusa"
|
||||||
|
|
||||||
export default (rootDirectory, options) => {
|
export default (rootDirectory, options) => {
|
||||||
const router = Router()
|
const router = Router()
|
||||||
|
|
||||||
router.use(express.json())
|
router.use(express.json())
|
||||||
@@ -648,26 +648,26 @@ export default (rootDirectory, options) => {
|
|||||||
router.use(errorHandler())
|
router.use(errorHandler())
|
||||||
|
|
||||||
return router
|
return router
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="admin" label="src/api/admin.ts">
|
<TabItem value="admin" label="src/api/admin.ts">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { Router } from "express"
|
import { Router } from "express"
|
||||||
import PostService from "../services/post"
|
import PostService from "../services/post"
|
||||||
import {
|
import {
|
||||||
ConfigModule,
|
ConfigModule,
|
||||||
} from "@medusajs/medusa/dist/types/global"
|
} from "@medusajs/medusa/dist/types/global"
|
||||||
import cors from "cors"
|
import cors from "cors"
|
||||||
import { authenticate, wrapHandler } from "@medusajs/medusa"
|
import { authenticate, wrapHandler } from "@medusajs/medusa"
|
||||||
import AuthorService from "../services/author"
|
import AuthorService from "../services/author"
|
||||||
|
|
||||||
export default function adminRoutes(
|
export default function adminRoutes(
|
||||||
router: Router,
|
router: Router,
|
||||||
options: ConfigModule
|
options: ConfigModule
|
||||||
) {
|
) {
|
||||||
const { projectConfig } = options
|
const { projectConfig } = options
|
||||||
|
|
||||||
const corsOptions = {
|
const corsOptions = {
|
||||||
@@ -853,26 +853,26 @@ export default function adminRoutes(
|
|||||||
|
|
||||||
res.status(200).end()
|
res.status(200).end()
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="store" label="src/api/store.ts">
|
<TabItem value="store" label="src/api/store.ts">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { Router } from "express"
|
import { Router } from "express"
|
||||||
import {
|
import {
|
||||||
ConfigModule,
|
ConfigModule,
|
||||||
} from "@medusajs/medusa/dist/types/global"
|
} from "@medusajs/medusa/dist/types/global"
|
||||||
import PostService from "../services/post"
|
import PostService from "../services/post"
|
||||||
import cors from "cors"
|
import cors from "cors"
|
||||||
import AuthorService from "../services/author"
|
import AuthorService from "../services/author"
|
||||||
import { wrapHandler } from "@medusajs/medusa"
|
import { wrapHandler } from "@medusajs/medusa"
|
||||||
|
|
||||||
export default function storeRoutes(
|
export default function storeRoutes(
|
||||||
router: Router,
|
router: Router,
|
||||||
options: ConfigModule
|
options: ConfigModule
|
||||||
) {
|
) {
|
||||||
const { projectConfig } = options
|
const { projectConfig } = options
|
||||||
|
|
||||||
const storeCorsOptions = {
|
const storeCorsOptions = {
|
||||||
@@ -936,10 +936,10 @@ export default function storeRoutes(
|
|||||||
post: await authorService.retrieve(req.params.id),
|
post: await authorService.retrieve(req.params.id),
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -538,25 +538,23 @@ After using `MedusaError`, the returned error in the response provides a clearer
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>
|
<Summary>Available MedusaError Types and their respective status codes</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.DB_ERROR`: Sets the response code to `500`.
|
||||||
- `MedusaError.Types.DUPLICATE_ERROR`: Sets the response code to `422`.
|
- `MedusaError.Types.DUPLICATE_ERROR`: Sets the response code to `422`.
|
||||||
- `MedusaError.Types.INVALID_ARGUMENT`
|
- `MedusaError.Types.INVALID_ARGUMENT`
|
||||||
- `MedusaError.Types.INVALID_DATA`: Sets the resposne code to `400`.
|
- `MedusaError.Types.INVALID_DATA`: Sets the resposne code to `400`.
|
||||||
- `MedusaError.Types.UNAUTHORIZED`: Sets the resposne code to `401`.
|
- `MedusaError.Types.UNAUTHORIZED`: Sets the resposne code to `401`.
|
||||||
- `MedusaError.Types.NOT_FOUND`: Sets the response code to `404`.
|
- `MedusaError.Types.NOT_FOUND`: Sets the response code to `404`.
|
||||||
- `MedusaError.Types.NOT_ALLOWED`: Sets the resposne code to `400`.
|
- `MedusaError.Types.NOT_ALLOWED`: Sets the resposne code to `400`.
|
||||||
- `MedusaError.Types.UNEXPECTED_STATE`
|
- `MedusaError.Types.UNEXPECTED_STATE`
|
||||||
- `MedusaError.Types.CONFLICT`: Sets the resposne code to `409`.
|
- `MedusaError.Types.CONFLICT`: Sets the resposne code to `409`.
|
||||||
- `MedusaError.Types.PAYMENT_AUTHORIZATION_ERROR`: Sets the resposne code to `422`.
|
- `MedusaError.Types.PAYMENT_AUTHORIZATION_ERROR`: Sets the resposne code to `422`.
|
||||||
|
|
||||||
</details>
|
</Details>
|
||||||
|
|
||||||
### Override Error Handler
|
### Override Error Handler
|
||||||
|
|
||||||
@@ -691,28 +689,28 @@ Files and directories prefixed with `_` are ignored. This can be helpful if you
|
|||||||
For example:
|
For example:
|
||||||
|
|
||||||
<Tabs groupId="files" isCodeTabs={true}>
|
<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
|
```ts
|
||||||
import getProducts from "../_methods/get-products"
|
import getProducts from "../_methods/get-products"
|
||||||
|
|
||||||
export const GET = getProducts
|
export const GET = getProducts
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="internal-method" label="src/api/_methods/get-product.ts">
|
<TabItem value="internal-method" label="src/api/_methods/get-product.ts">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import {
|
import {
|
||||||
MedusaRequest,
|
MedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
ProductService,
|
ProductService,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
|
|
||||||
export default async function (
|
export default async function (
|
||||||
req: MedusaRequest,
|
req: MedusaRequest,
|
||||||
res: MedusaResponse
|
res: MedusaResponse
|
||||||
) {
|
) {
|
||||||
const productService = req.scope.resolve<ProductService>(
|
const productService = req.scope.resolve<ProductService>(
|
||||||
"productService"
|
"productService"
|
||||||
)
|
)
|
||||||
@@ -722,10 +720,10 @@ export default async function (
|
|||||||
res.json({
|
res.json({
|
||||||
products,
|
products,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -741,20 +739,20 @@ You can refer to the [Entities](../entities/create.mdx#adding-relations) and [Se
|
|||||||
:::
|
:::
|
||||||
|
|
||||||
<Tabs groupId="files" isCodeTabs={true}>
|
<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
|
```ts
|
||||||
import type {
|
import type {
|
||||||
MedusaRequest,
|
MedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
import { PostService } from "../../../services/post"
|
import { PostService } from "../../../services/post"
|
||||||
|
|
||||||
// list posts
|
// list posts
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: MedusaRequest,
|
req: MedusaRequest,
|
||||||
res: MedusaResponse
|
res: MedusaResponse
|
||||||
) => {
|
) => {
|
||||||
const postService: PostService = req.scope.resolve(
|
const postService: PostService = req.scope.resolve(
|
||||||
"postService"
|
"postService"
|
||||||
)
|
)
|
||||||
@@ -762,13 +760,13 @@ export const GET = async (
|
|||||||
res.json({
|
res.json({
|
||||||
posts: await postService.list(),
|
posts: await postService.list(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a post
|
// create a post
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: MedusaRequest,
|
req: MedusaRequest,
|
||||||
res: MedusaResponse
|
res: MedusaResponse
|
||||||
) => {
|
) => {
|
||||||
const postService: PostService = req.scope.resolve(
|
const postService: PostService = req.scope.resolve(
|
||||||
"postService"
|
"postService"
|
||||||
)
|
)
|
||||||
@@ -783,24 +781,24 @@ export const POST = async (
|
|||||||
res.json({
|
res.json({
|
||||||
post,
|
post,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="posts-id-routes" label="src/api/admin/posts/[id]/route.ts">
|
<TabItem value="posts-id-routes" label="src/api/admin/posts/[id]/route.ts">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import type {
|
import type {
|
||||||
MedusaRequest,
|
MedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
import { PostService } from "../../../services/post"
|
import { PostService } from "../../../services/post"
|
||||||
|
|
||||||
// retrieve a post by its ID
|
// retrieve a post by its ID
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: MedusaRequest,
|
req: MedusaRequest,
|
||||||
res: MedusaResponse
|
res: MedusaResponse
|
||||||
) => {
|
) => {
|
||||||
const postService: PostService = req.scope.resolve(
|
const postService: PostService = req.scope.resolve(
|
||||||
"postService"
|
"postService"
|
||||||
)
|
)
|
||||||
@@ -810,13 +808,13 @@ export const GET = async (
|
|||||||
res.json({
|
res.json({
|
||||||
post,
|
post,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// update a post by its ID
|
// update a post by its ID
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: MedusaRequest,
|
req: MedusaRequest,
|
||||||
res: MedusaResponse
|
res: MedusaResponse
|
||||||
) => {
|
) => {
|
||||||
const postService: PostService = req.scope.resolve(
|
const postService: PostService = req.scope.resolve(
|
||||||
"postService"
|
"postService"
|
||||||
)
|
)
|
||||||
@@ -834,13 +832,13 @@ export const POST = async (
|
|||||||
res.json({
|
res.json({
|
||||||
post,
|
post,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete a post by its ID
|
// delete a post by its ID
|
||||||
export const DELETE = async (
|
export const DELETE = async (
|
||||||
req: MedusaRequest,
|
req: MedusaRequest,
|
||||||
res: MedusaResponse
|
res: MedusaResponse
|
||||||
) => {
|
) => {
|
||||||
const postService: PostService = req.scope.resolve(
|
const postService: PostService = req.scope.resolve(
|
||||||
"postService"
|
"postService"
|
||||||
)
|
)
|
||||||
@@ -848,10 +846,10 @@ export const DELETE = async (
|
|||||||
await postService.delete(req.params.id)
|
await postService.delete(req.params.id)
|
||||||
|
|
||||||
res.status(200).end()
|
res.status(200).end()
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -25,60 +25,48 @@ node -v
|
|||||||
:::
|
:::
|
||||||
|
|
||||||
<Tabs groupId="operating-systems" queryString="os">
|
<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>
|
For other Linux distributions, you can check out [Node.js’s guide](https://nodejs.org/en/download/package-manager/).
|
||||||
<TabItem value="linux" label="Linux">
|
</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
|
```bash
|
||||||
#Ubuntu
|
brew install node
|
||||||
sudo apt update
|
```
|
||||||
sudo apt install nodejs
|
</TabItem>
|
||||||
```
|
<TabItem value="no-homebrew" label="Without Homebrew">
|
||||||
|
```bash
|
||||||
For other Linux distributions, you can check out [Node.js’s guide](https://nodejs.org/en/download/package-manager/).
|
curl \
|
||||||
|
|
||||||
</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/node-${VERSION:-$(wget -qO- \
|
||||||
https://nodejs.org/dist/latest/ | sed -nE \
|
https://nodejs.org/dist/latest/ | sed -nE \
|
||||||
's|.*>node-(.*)\.pkg</a>.*|\1|p')}.pkg" \
|
's|.*>node-(.*)\.pkg</a>.*|\1|p')}.pkg" \
|
||||||
> "$HOME/Downloads/node-latest.pkg" &&
|
> "$HOME/Downloads/node-latest.pkg" &&
|
||||||
sudo installer -store -pkg "$HOME/Downloads/node-latest.pkg" -target "/"
|
sudo installer -store -pkg "$HOME/Downloads/node-latest.pkg" -target "/"
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
</TabItem>
|
For other approaches, you can check out [Node.js’s guide](https://nodejs.org/en/download/package-manager/#macos).
|
||||||
</Tabs>
|
|
||||||
|
|
||||||
For other approaches, you can check out [Node.js’s guide](https://nodejs.org/en/download/package-manager/#macos).
|
Make sure that you have Xcode command line tools installed. If not, run the following command to install it: `xcode-select --install`.
|
||||||
|
|
||||||
:::tip
|
</TabItem>
|
||||||
|
|
||||||
Make sure that you have Xcode command line tools installed; if not, run the following command to install it: `xcode-select --install`
|
|
||||||
|
|
||||||
:::
|
|
||||||
</TabItem>
|
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
## Git
|
## 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.
|
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">
|
<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>
|
As for other Linux distributions, please check [git’s guide](https://git-scm.com/download/linux).
|
||||||
<TabItem value="linux" label="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
|
```bash
|
||||||
apt-get install git
|
brew install git
|
||||||
```
|
```
|
||||||
|
|
||||||
As for other Linux distributions, please check [git’s guide](https://git-scm.com/download/linux).
|
You can also check out [git’s guide](https://git-scm.com/download/mac) for more installation options.
|
||||||
|
</TabItem>
|
||||||
</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>
|
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
## PostgreSQL
|
## 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.
|
The Medusa backend uses PostgreSQL to store data of your commerce system.
|
||||||
|
|
||||||
<Tabs groupId="operating-systems" queryString="os">
|
<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 \
|
||||||
</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'
|
'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
|
||||||
wget --quiet -O - \
|
wget --quiet -O - \
|
||||||
https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
|
https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get -y install postgresql
|
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/).
|
For other distributions, you can check out [PostgreSQL’s website for more guides](https://www.postgresql.org/download/linux/).
|
||||||
|
</TabItem>
|
||||||
</TabItem>
|
<TabItem value="macos" label="macOS">
|
||||||
<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>
|
||||||
You can download PostgreSQL on your macOS using [the installer on their website](https://www.postgresql.org/download/macosx/).
|
|
||||||
|
|
||||||
</TabItem>
|
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
## (Optional) Medusa CLI
|
## (Optional) Medusa CLI
|
||||||
|
|||||||
@@ -293,24 +293,24 @@ 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`:
|
For example, this creates a batch job of the type `publish-products`:
|
||||||
|
|
||||||
<Tabs groupId="request-types" isCodeTabs={true}>
|
<Tabs groupId="request-types" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
medusa.admin.batchJobs.create({
|
medusa.admin.batchJobs.create({
|
||||||
type: "publish-products",
|
type: "publish-products",
|
||||||
context: { },
|
context: { },
|
||||||
dry_run: true,
|
dry_run: true,
|
||||||
})
|
})
|
||||||
.then(( batch_job ) => {
|
.then(( batch_job ) => {
|
||||||
console.log(batch_job.status)
|
console.log(batch_job.status)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
fetch(`<BACKEND_URL>/admin/batch-jobs`, {
|
fetch(`<BACKEND_URL>/admin/batch-jobs`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -321,26 +321,26 @@ fetch(`<BACKEND_URL>/admin/batch-jobs`, {
|
|||||||
context: { },
|
context: { },
|
||||||
dry_run: true,
|
dry_run: true,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ batch_job }) => {
|
.then(({ batch_job }) => {
|
||||||
console.log(batch_job.status)
|
console.log(batch_job.status)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/batch-jobs' \
|
curl -L -X POST '<BACKEND_URL>/admin/batch-jobs' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"type": "publish-products",
|
"type": "publish-products",
|
||||||
"context": { },
|
"context": { },
|
||||||
"dry_run": true
|
"dry_run": true
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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:
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
medusa.admin.batchJobs.retrieve(batchJobId)
|
medusa.admin.batchJobs.retrieve(batchJobId)
|
||||||
.then(( batch_job ) => {
|
.then(( batch_job ) => {
|
||||||
console.log(batch_job.status, batch_job.result)
|
console.log(batch_job.status, batch_job.result)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
fetch(`<BACKEND_URL>/admin/batch-jobs/${batchJobId}`, {
|
fetch(`<BACKEND_URL>/admin/batch-jobs/${batchJobId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ batch_job }) => {
|
.then(({ batch_job }) => {
|
||||||
console.log(batch_job.status, batch_job.result)
|
console.log(batch_job.status, batch_job.result)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/batch-jobs/<BATCH_JOB_ID>' \
|
curl -L -X GET '<BACKEND_URL>/admin/batch-jobs/<BATCH_JOB_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
# <BATCH_JOB_ID> is the ID of the batch job
|
# <BATCH_JOB_ID> is the ID of the batch job
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
Based on the batch job strategy implemented in this documentation, the `result` property could be something like this:
|
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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
medusa.admin.batchJobs.confirm(batchJobId)
|
medusa.admin.batchJobs.confirm(batchJobId)
|
||||||
.then(( batch_job ) => {
|
.then(( batch_job ) => {
|
||||||
console.log(batch_job.status)
|
console.log(batch_job.status)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
fetch(`<BACKEND_URL>/admin/batch-jobs/${batchJobId}/confirm`, {
|
fetch(`<BACKEND_URL>/admin/batch-jobs/${batchJobId}/confirm`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ batch_job }) => {
|
.then(({ batch_job }) => {
|
||||||
console.log(batch_job.status)
|
console.log(batch_job.status)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/batch-jobs/<BATCH_JOB_ID>/confirm' \
|
curl -L -X POST '<BACKEND_URL>/admin/batch-jobs/<BATCH_JOB_ID>/confirm' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
# <BATCH_JOB_ID> is the ID of the batch job
|
# <BATCH_JOB_ID> is the ID of the batch job
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
The batch job will start processing afterward. Based on the batch job strategy implemented in this documentation, draft products will be published.
|
The batch job will start processing afterward. Based on the batch job strategy implemented in this documentation, draft products will be published.
|
||||||
|
|||||||
@@ -70,22 +70,22 @@ 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`:
|
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}>
|
<Tabs groupId="files" isCodeTabs={true}>
|
||||||
<TabItem value="post" label="src/models/post.ts" default>
|
<TabItem value="post" label="src/models/post.ts" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import {
|
import {
|
||||||
BeforeInsert,
|
BeforeInsert,
|
||||||
Column,
|
Column,
|
||||||
Entity,
|
Entity,
|
||||||
JoinColumn,
|
JoinColumn,
|
||||||
ManyToOne,
|
ManyToOne,
|
||||||
} from "typeorm"
|
} from "typeorm"
|
||||||
import { BaseEntity } from "@medusajs/medusa"
|
import { BaseEntity } from "@medusajs/medusa"
|
||||||
import { generateEntityId } from "@medusajs/medusa/dist/utils"
|
import { generateEntityId } from "@medusajs/medusa/dist/utils"
|
||||||
import { Author } from "./author"
|
import { Author } from "./author"
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Post extends BaseEntity {
|
export class Post extends BaseEntity {
|
||||||
@Column({ type: "varchar" })
|
@Column({ type: "varchar" })
|
||||||
title: string | null
|
title: string | null
|
||||||
|
|
||||||
@@ -100,24 +100,24 @@ export class Post extends BaseEntity {
|
|||||||
private beforeInsert(): void {
|
private beforeInsert(): void {
|
||||||
this.id = generateEntityId(this.id, "post")
|
this.id = generateEntityId(this.id, "post")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="author" label="src/models/author.ts">
|
<TabItem value="author" label="src/models/author.ts">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { BaseEntity, generateEntityId } from "@medusajs/medusa"
|
import { BaseEntity, generateEntityId } from "@medusajs/medusa"
|
||||||
import {
|
import {
|
||||||
BeforeInsert,
|
BeforeInsert,
|
||||||
Column,
|
Column,
|
||||||
Entity,
|
Entity,
|
||||||
OneToMany,
|
OneToMany,
|
||||||
} from "typeorm"
|
} from "typeorm"
|
||||||
import { Post } from "./post"
|
import { Post } from "./post"
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Author extends BaseEntity {
|
export class Author extends BaseEntity {
|
||||||
@Column({ type: "varchar" })
|
@Column({ type: "varchar" })
|
||||||
name: string
|
name: string
|
||||||
|
|
||||||
@@ -131,10 +131,10 @@ export class Author extends BaseEntity {
|
|||||||
private beforeInsert(): void {
|
private beforeInsert(): void {
|
||||||
this.id = generateEntityId(this.id, "auth")
|
this.id = generateEntityId(this.id, "auth")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
Adding these relations allows you to later on expand these relations when retrieving records of this entity with repositories.
|
Adding these relations allows you to later on expand these relations when retrieving records of this entity with repositories.
|
||||||
|
|||||||
@@ -417,7 +417,6 @@ While you develop your plugin, you’ll need to test it on an actual Medusa back
|
|||||||
|
|
||||||
<Tabs groupId="plugin-preference">
|
<Tabs groupId="plugin-preference">
|
||||||
<TabItem value="without-admin" label="Without Admin Customizations" default>
|
<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
|
```bash
|
||||||
@@ -426,7 +425,6 @@ While you develop your plugin, you’ll need to test it on an actual Medusa back
|
|||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="with-admin" label="With Admin Customizations">
|
<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
|
```bash
|
||||||
@@ -434,7 +432,6 @@ While you develop your plugin, you’ll need to test it on an actual Medusa back
|
|||||||
```
|
```
|
||||||
|
|
||||||
If the `prepare` script is not available in your project, you can find it in [this section](#changes-for-admin-plugins).
|
If the `prepare` script is not available in your project, you can find it in [this section](#changes-for-admin-plugins).
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ Before publishing your plugin, make sure you've set the following fields in your
|
|||||||
|
|
||||||
<Tabs groupId="plugin-preference">
|
<Tabs groupId="plugin-preference">
|
||||||
<TabItem value="without-admin" label="Without Admin Customizations" default>
|
<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
|
```json title=package.json
|
||||||
@@ -59,10 +58,8 @@ Before publishing your plugin, make sure you've set the following fields in your
|
|||||||
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 `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 `prepare` script facilitates your publishing process. You would typically run this script before publishing your plugin.
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="with-admin" label="With Admin Customizations">
|
<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`
|
||||||
@@ -78,7 +75,6 @@ Before publishing your plugin, make sure you've set the following fields in your
|
|||||||
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 `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.
|
The `prepare` script creates a production build of both backend and admin resources.
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
|
|||||||
+261
-261
@@ -64,23 +64,23 @@ You can learn more about [authenticating as an admin user in the API reference](
|
|||||||
You can retrieve a list of publishable API keys by sending a request to the [List Publishable API Keys route](https://docs.medusajs.com/api/admin#publishable-api-keys_getpublishableapikeys):
|
You can retrieve a list of publishable API keys by sending a request to the [List Publishable API Keys route](https://docs.medusajs.com/api/admin#publishable-api-keys_getpublishableapikeys):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.publishableApiKeys.list()
|
medusa.admin.publishableApiKeys.list()
|
||||||
.then(({ publishable_api_keys, count, limit, offset }) => {
|
.then(({ publishable_api_keys, count, limit, offset }) => {
|
||||||
console.log(publishable_api_keys)
|
console.log(publishable_api_keys)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { PublishableApiKey } from "@medusajs/medusa"
|
import { PublishableApiKey } from "@medusajs/medusa"
|
||||||
import { useAdminPublishableApiKeys } from "medusa-react"
|
import { useAdminPublishableApiKeys } from "medusa-react"
|
||||||
|
|
||||||
const PublishabelApiKeys = () => {
|
const PublishabelApiKeys = () => {
|
||||||
const { publishable_api_keys, isLoading } =
|
const { publishable_api_keys, isLoading } =
|
||||||
useAdminPublishableApiKeys()
|
useAdminPublishableApiKeys()
|
||||||
|
|
||||||
@@ -104,33 +104,33 @@ const PublishabelApiKeys = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PublishabelApiKeys
|
export default PublishabelApiKeys
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/publishable-api-keys`, {
|
fetch(`<BACKEND_URL>/admin/publishable-api-keys`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ publishable_api_keys, count, limit, offset }) => {
|
.then(({ publishable_api_keys, count, limit, offset }) => {
|
||||||
console.log(publishable_api_keys)
|
console.log(publishable_api_keys)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/publishable-api-keys' \
|
curl -L -X GET '<BACKEND_URL>/admin/publishable-api-keys' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request does not require any path parameters. You can pass it optional query parameters related to expanding fields and pagination, which you can check out in the [API reference](https://docs.medusajs.com/api/admin#publishable-api-keys_getpublishableapikeys).
|
This request does not require any path parameters. You can pass it optional query parameters related to expanding fields and pagination, which you can check out in the [API reference](https://docs.medusajs.com/api/admin#publishable-api-keys_getpublishableapikeys).
|
||||||
@@ -155,24 +155,24 @@ You can learn more about pagination in the [API reference](https://docs.medusajs
|
|||||||
You can create a publishable API key by sending a request to the [Create Publishable API Key route](https://docs.medusajs.com/api/admin#publishable-api-keys_postpublishableapikeys):
|
You can create a publishable API key by sending a request to the [Create Publishable API Key route](https://docs.medusajs.com/api/admin#publishable-api-keys_postpublishableapikeys):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.publishableApiKeys.create({
|
medusa.admin.publishableApiKeys.create({
|
||||||
title: "Web API Key",
|
title: "Web API Key",
|
||||||
})
|
})
|
||||||
.then(({ publishable_api_key }) => {
|
.then(({ publishable_api_key }) => {
|
||||||
console.log(publishable_api_key.id)
|
console.log(publishable_api_key.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreatePublishableApiKey } from "medusa-react"
|
import { useAdminCreatePublishableApiKey } from "medusa-react"
|
||||||
|
|
||||||
const CreatePublishableApiKey = () => {
|
const CreatePublishableApiKey = () => {
|
||||||
const createKey = useAdminCreatePublishableApiKey()
|
const createKey = useAdminCreatePublishableApiKey()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -183,16 +183,16 @@ const CreatePublishableApiKey = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreatePublishableApiKey
|
export default CreatePublishableApiKey
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/publishable-api-keys`, {
|
fetch(`<BACKEND_URL>/admin/publishable-api-keys`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -201,26 +201,26 @@ fetch(`<BACKEND_URL>/admin/publishable-api-keys`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
title: "Web API Key",
|
title: "Web API Key",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ publishable_api_key }) => {
|
.then(({ publishable_api_key }) => {
|
||||||
console.log(publishable_api_key.id)
|
console.log(publishable_api_key.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/publishable-api-keys' \
|
curl -L -X POST '<BACKEND_URL>/admin/publishable-api-keys' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"title": "Web API Key"
|
"title": "Web API Key"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires a body parameter `title`, which is the title of the Publishable API Key.
|
This request requires a body parameter `title`, which is the title of the Publishable API Key.
|
||||||
@@ -234,24 +234,24 @@ It returns the created publishable API key in the response.
|
|||||||
You can update a publishable API key’s details by sending a request to the [Update Publishable API Key route](https://docs.medusajs.com/api/admin#publishable-api-keys_postpublishableapikyspublishableapikey):
|
You can update a publishable API key’s details by sending a request to the [Update Publishable API Key route](https://docs.medusajs.com/api/admin#publishable-api-keys_postpublishableapikyspublishableapikey):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.publishableApiKeys.update(publishableApiKeyId, {
|
medusa.admin.publishableApiKeys.update(publishableApiKeyId, {
|
||||||
title: "Web API Key",
|
title: "Web API Key",
|
||||||
})
|
})
|
||||||
.then(({ publishable_api_key }) => {
|
.then(({ publishable_api_key }) => {
|
||||||
console.log(publishable_api_key.id)
|
console.log(publishable_api_key.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUpdatePublishableApiKey } from "medusa-react"
|
import { useAdminUpdatePublishableApiKey } from "medusa-react"
|
||||||
|
|
||||||
const UpdatePublishableApiKey = () => {
|
const UpdatePublishableApiKey = () => {
|
||||||
const updateKey = useAdminUpdatePublishableApiKey(
|
const updateKey = useAdminUpdatePublishableApiKey(
|
||||||
publishableApiKeyId
|
publishableApiKeyId
|
||||||
)
|
)
|
||||||
@@ -264,18 +264,18 @@ const UpdatePublishableApiKey = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdatePublishableApiKey
|
export default UpdatePublishableApiKey
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/publishable-api-keys/${publishableApiKeyId}`, {
|
fetch(`<BACKEND_URL>/admin/publishable-api-keys/${publishableApiKeyId}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -284,26 +284,26 @@ fetch(`<BACKEND_URL>/admin/publishable-api-keys/${publishableApiKeyId}`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
title: "Web API Key",
|
title: "Web API Key",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ publishable_api_key }) => {
|
.then(({ publishable_api_key }) => {
|
||||||
console.log(publishable_api_key.id)
|
console.log(publishable_api_key.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/publishable-api-keys/<PUBLISHABLE_API_KEY>' \
|
curl -L -X POST '<BACKEND_URL>/admin/publishable-api-keys/<PUBLISHABLE_API_KEY>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"title": "Web API Key"
|
"title": "Web API Key"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the ID of the publishable API key as a path parameter. In its body, it optionally accepts the new `title` of the publishable API key.
|
This request requires the ID of the publishable API key as a path parameter. In its body, it optionally accepts the new `title` of the publishable API key.
|
||||||
@@ -319,22 +319,22 @@ Revoking a publishable API key does not remove it, but does not allow using it i
|
|||||||
You can revoke a publishable API key by sending a request to the [Revoke Publishable API Key route](https://docs.medusajs.com/api/admin#publishable-api-keys_postpublishableapikeyspublishableapikeyrevoke):
|
You can revoke a publishable API key by sending a request to the [Revoke Publishable API Key route](https://docs.medusajs.com/api/admin#publishable-api-keys_postpublishableapikeyspublishableapikeyrevoke):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.publishableApiKeys.revoke(publishableApiKeyId)
|
medusa.admin.publishableApiKeys.revoke(publishableApiKeyId)
|
||||||
.then(({ publishable_api_key }) => {
|
.then(({ publishable_api_key }) => {
|
||||||
console.log(publishable_api_key.id)
|
console.log(publishable_api_key.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminRevokePublishableApiKey } from "medusa-react"
|
import { useAdminRevokePublishableApiKey } from "medusa-react"
|
||||||
|
|
||||||
const PublishableApiKey = () => {
|
const PublishableApiKey = () => {
|
||||||
const revokeKey = useAdminRevokePublishableApiKey(
|
const revokeKey = useAdminRevokePublishableApiKey(
|
||||||
publishableApiKeyId
|
publishableApiKeyId
|
||||||
)
|
)
|
||||||
@@ -345,39 +345,39 @@ const PublishableApiKey = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PublishableApiKey
|
export default PublishableApiKey
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/admin/publishable-api-keys/${publishableApiKeyId}/revoke`,
|
`<BACKEND_URL>/admin/publishable-api-keys/${publishableApiKeyId}/revoke`,
|
||||||
{
|
{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ publishable_api_key }) => {
|
.then(({ publishable_api_key }) => {
|
||||||
console.log(publishable_api_key.id)
|
console.log(publishable_api_key.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/publishable-api-keys/<PUBLISHABLE_API_KEY>/revoke' \
|
curl -L -X POST '<BACKEND_URL>/admin/publishable-api-keys/<PUBLISHABLE_API_KEY>/revoke' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the ID of the publishable API key as a path parameter. It returns the updated publishable API key in the response.
|
This request requires the ID of the publishable API key as a path parameter. It returns the updated publishable API key in the response.
|
||||||
@@ -389,22 +389,22 @@ This request requires the ID of the publishable API key as a path parameter. It
|
|||||||
You can delete a publishable API key by sending a request to the [Delete Publishable API Key route](https://docs.medusajs.com/api/admin#publishable-api-keys_deletepublishableapikeyspublishableapikey):
|
You can delete a publishable API key by sending a request to the [Delete Publishable API Key route](https://docs.medusajs.com/api/admin#publishable-api-keys_deletepublishableapikeyspublishableapikey):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.publishableApiKeys.delete(publishableApiKeyId)
|
medusa.admin.publishableApiKeys.delete(publishableApiKeyId)
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDeletePublishableApiKey } from "medusa-react"
|
import { useAdminDeletePublishableApiKey } from "medusa-react"
|
||||||
|
|
||||||
const PublishableApiKey = () => {
|
const PublishableApiKey = () => {
|
||||||
const deleteKey = useAdminDeletePublishableApiKey(
|
const deleteKey = useAdminDeletePublishableApiKey(
|
||||||
publishableApiKeyId
|
publishableApiKeyId
|
||||||
)
|
)
|
||||||
@@ -415,36 +415,36 @@ const PublishableApiKey = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PublishableApiKey
|
export default PublishableApiKey
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/publishable-api-keys/${publishableApiKeyId}`, {
|
fetch(`<BACKEND_URL>/admin/publishable-api-keys/${publishableApiKeyId}`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/publishable-api-keys/<PUBLISHABLE_API_KEY>' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/publishable-api-keys/<PUBLISHABLE_API_KEY>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the ID of the publishable API key as a path parameter.
|
This request requires the ID of the publishable API key as a path parameter.
|
||||||
@@ -466,26 +466,26 @@ This section covers how to manage sales channels in a publishable API key. This
|
|||||||
You can retrieve the list of sales channels associated with a publishable API key by sending a request to the [List Sales Channels API Route](https://docs.medusajs.com/api/admin#sales-channels_getsaleschannels):
|
You can retrieve the list of sales channels associated with a publishable API key by sending a request to the [List Sales Channels API Route](https://docs.medusajs.com/api/admin#sales-channels_getsaleschannels):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.publishableApiKeys
|
medusa.admin.publishableApiKeys
|
||||||
.listSalesChannels(publishableApiKeyId)
|
.listSalesChannels(publishableApiKeyId)
|
||||||
.then(({ sales_channels }) => {
|
.then(({ sales_channels }) => {
|
||||||
console.log(sales_channels)
|
console.log(sales_channels)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { SalesChannel } from "@medusajs/medusa"
|
import { SalesChannel } from "@medusajs/medusa"
|
||||||
import {
|
import {
|
||||||
useAdminPublishableApiKeySalesChannels,
|
useAdminPublishableApiKeySalesChannels,
|
||||||
} from "medusa-react"
|
} from "medusa-react"
|
||||||
|
|
||||||
const SalesChannels = () => {
|
const SalesChannels = () => {
|
||||||
const { sales_channels, isLoading } =
|
const { sales_channels, isLoading } =
|
||||||
useAdminPublishableApiKeySalesChannels(
|
useAdminPublishableApiKeySalesChannels(
|
||||||
publishableApiKeyId
|
publishableApiKeyId
|
||||||
@@ -506,38 +506,38 @@ const SalesChannels = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SalesChannels
|
export default SalesChannels
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/admin/publishable-api-keys/${publishableApiKeyId}/sales-channels`,
|
`<BACKEND_URL>/admin/publishable-api-keys/${publishableApiKeyId}/sales-channels`,
|
||||||
{
|
{
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ sales_channels }) => {
|
.then(({ sales_channels }) => {
|
||||||
console.log(sales_channels)
|
console.log(sales_channels)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/publishable-api-keys/<PUBLISHABLE_API_KEY>/sales-channels' \
|
curl -L -X GET '<BACKEND_URL>/admin/publishable-api-keys/<PUBLISHABLE_API_KEY>/sales-channels' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the ID of the publishable API key as a path parameter.
|
This request requires the ID of the publishable API key as a path parameter.
|
||||||
@@ -549,10 +549,10 @@ It returns an array of sales channels associated with the publishable API key in
|
|||||||
You can add a sales channel to a publishable API key by sending a request to the [Add Sales Channels API Route](https://docs.medusajs.com/api/admin#publishable-api-keys_postpublishableapikeysaleschannelschannelsbatch):
|
You can add a sales channel to a publishable API key by sending a request to the [Add Sales Channels API Route](https://docs.medusajs.com/api/admin#publishable-api-keys_postpublishableapikeysaleschannelschannelsbatch):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.publishableApiKeys.addSalesChannelsBatch(
|
medusa.admin.publishableApiKeys.addSalesChannelsBatch(
|
||||||
publishableApiKeyId,
|
publishableApiKeyId,
|
||||||
{
|
{
|
||||||
sales_channel_ids: [
|
sales_channel_ids: [
|
||||||
@@ -561,21 +561,21 @@ medusa.admin.publishableApiKeys.addSalesChannelsBatch(
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(({ publishable_api_key }) => {
|
.then(({ publishable_api_key }) => {
|
||||||
console.log(publishable_api_key.id)
|
console.log(publishable_api_key.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import {
|
import {
|
||||||
useAdminAddPublishableKeySalesChannelsBatch,
|
useAdminAddPublishableKeySalesChannelsBatch,
|
||||||
} from "medusa-react"
|
} from "medusa-react"
|
||||||
|
|
||||||
const PublishableApiKey = () => {
|
const PublishableApiKey = () => {
|
||||||
const addSalesChannels =
|
const addSalesChannels =
|
||||||
useAdminAddPublishableKeySalesChannelsBatch(
|
useAdminAddPublishableKeySalesChannelsBatch(
|
||||||
publishableApiKeyId
|
publishableApiKeyId
|
||||||
@@ -593,18 +593,18 @@ const PublishableApiKey = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PublishableApiKey
|
export default PublishableApiKey
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/admin/publishable-api-keys/${publishableApiKeyId}/sales-channels/batch`,
|
`<BACKEND_URL>/admin/publishable-api-keys/${publishableApiKeyId}/sales-channels/batch`,
|
||||||
{
|
{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -620,30 +620,30 @@ fetch(
|
|||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ publishable_api_key }) => {
|
.then(({ publishable_api_key }) => {
|
||||||
console.log(publishable_api_key.id)
|
console.log(publishable_api_key.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/publishable-api-keys/<PUBLISHABLE_API_KEY>/sales-channels/batch' \
|
curl -L -X POST '<BACKEND_URL>/admin/publishable-api-keys/<PUBLISHABLE_API_KEY>/sales-channels/batch' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"sales_channel_ids": [
|
"sales_channel_ids": [
|
||||||
{
|
{
|
||||||
"id": "<SALES_CHANNEL_ID>"
|
"id": "<SALES_CHANNEL_ID>"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires passing the ID of the publishable API key as a path parameter.
|
This request requires passing the ID of the publishable API key as a path parameter.
|
||||||
@@ -659,10 +659,10 @@ This request returns the updated publishable API key in the response.
|
|||||||
You can delete a sales channel from a publishable API key by sending a request to the [Delete Sales Channels API Route](https://docs.medusajs.com/api/admin#publishable-api-keys_deletepublishableapikeysaleschannelschannelsbatch):
|
You can delete a sales channel from a publishable API key by sending a request to the [Delete Sales Channels API Route](https://docs.medusajs.com/api/admin#publishable-api-keys_deletepublishableapikeysaleschannelschannelsbatch):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.publishableApiKeys.deleteSalesChannelsBatch(
|
medusa.admin.publishableApiKeys.deleteSalesChannelsBatch(
|
||||||
publishableApiKeyId,
|
publishableApiKeyId,
|
||||||
{
|
{
|
||||||
sales_channel_ids: [
|
sales_channel_ids: [
|
||||||
@@ -671,21 +671,21 @@ medusa.admin.publishableApiKeys.deleteSalesChannelsBatch(
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(({ publishable_api_key }) => {
|
.then(({ publishable_api_key }) => {
|
||||||
console.log(publishable_api_key.id)
|
console.log(publishable_api_key.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import {
|
import {
|
||||||
useAdminRemovePublishableKeySalesChannelsBatch,
|
useAdminRemovePublishableKeySalesChannelsBatch,
|
||||||
} from "medusa-react"
|
} from "medusa-react"
|
||||||
|
|
||||||
const PublishableApiKey = () => {
|
const PublishableApiKey = () => {
|
||||||
const deleteSalesChannels =
|
const deleteSalesChannels =
|
||||||
useAdminRemovePublishableKeySalesChannelsBatch(
|
useAdminRemovePublishableKeySalesChannelsBatch(
|
||||||
publishableApiKeyId
|
publishableApiKeyId
|
||||||
@@ -703,18 +703,18 @@ const PublishableApiKey = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PublishableApiKey
|
export default PublishableApiKey
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/admin/publishable-api-keys/${publishableApiKeyId}/sales-channels/batch`,
|
`<BACKEND_URL>/admin/publishable-api-keys/${publishableApiKeyId}/sales-channels/batch`,
|
||||||
{
|
{
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
@@ -730,30 +730,30 @@ fetch(
|
|||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ publishable_api_key }) => {
|
.then(({ publishable_api_key }) => {
|
||||||
console.log(publishable_api_key.id)
|
console.log(publishable_api_key.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/publishable-api-keys/<PUBLISHABLE_API_KEY>/sales-channels/batch' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/publishable-api-keys/<PUBLISHABLE_API_KEY>/sales-channels/batch' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"sales_channel_ids": [
|
"sales_channel_ids": [
|
||||||
{
|
{
|
||||||
"id": "<SALES_CHANNEL_ID>"
|
"id": "<SALES_CHANNEL_ID>"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the ID of the publishable API key as a path parameter.
|
This request requires the ID of the publishable API key as a path parameter.
|
||||||
|
|||||||
@@ -424,20 +424,20 @@ 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.
|
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}>
|
<Tabs groupId="files" isCodeTabs={true}>
|
||||||
<TabItem value="post" label="src/services/post.ts" default>
|
<TabItem value="post" label="src/services/post.ts" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import {
|
import {
|
||||||
FindConfig,
|
FindConfig,
|
||||||
Selector,
|
Selector,
|
||||||
TransactionBaseService,
|
TransactionBaseService,
|
||||||
buildQuery,
|
buildQuery,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
import { PostRepository } from "../repositories/post"
|
import { PostRepository } from "../repositories/post"
|
||||||
import { Post } from "../models/post"
|
import { Post } from "../models/post"
|
||||||
import { MedusaError } from "@medusajs/utils"
|
import { MedusaError } from "@medusajs/utils"
|
||||||
|
|
||||||
class PostService extends TransactionBaseService {
|
class PostService extends TransactionBaseService {
|
||||||
protected postRepository_: typeof PostRepository
|
protected postRepository_: typeof PostRepository
|
||||||
|
|
||||||
constructor(container) {
|
constructor(container) {
|
||||||
@@ -539,27 +539,27 @@ class PostService extends TransactionBaseService {
|
|||||||
await postRepo.remove([post])
|
await postRepo.remove([post])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PostService
|
export default PostService
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="author" label="src/services/author.ts">
|
<TabItem value="author" label="src/services/author.ts">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import {
|
import {
|
||||||
FindConfig,
|
FindConfig,
|
||||||
Selector,
|
Selector,
|
||||||
TransactionBaseService,
|
TransactionBaseService,
|
||||||
buildQuery,
|
buildQuery,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
import { EntityManager } from "typeorm"
|
import { EntityManager } from "typeorm"
|
||||||
import AuthorRepository from "../repositories/author"
|
import AuthorRepository from "../repositories/author"
|
||||||
import { Author } from "../models/author"
|
import { Author } from "../models/author"
|
||||||
import { MedusaError } from "@medusajs/utils"
|
import { MedusaError } from "@medusajs/utils"
|
||||||
|
|
||||||
class AuthorService extends TransactionBaseService {
|
class AuthorService extends TransactionBaseService {
|
||||||
protected manager_: EntityManager
|
protected manager_: EntityManager
|
||||||
protected transactionManager_: EntityManager
|
protected transactionManager_: EntityManager
|
||||||
protected authorRepository_: typeof AuthorRepository
|
protected authorRepository_: typeof AuthorRepository
|
||||||
@@ -661,12 +661,12 @@ class AuthorService extends TransactionBaseService {
|
|||||||
await authorRepo.remove([post])
|
await authorRepo.remove([post])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AuthorService
|
export default AuthorService
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -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.'
|
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 Tabs from '@theme/Tabs'
|
||||||
import TabItem from '@theme/TabItem';
|
import TabItem from '@theme/TabItem'
|
||||||
|
|
||||||
# Medusa JS Client
|
# 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.
|
After initialization, you can use the client's properties and methods to send requests to the Medusa backend.
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>
|
<Summary>Troubleshooting: Could not find a declaration file for module '@medusajs/medusa-js'</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
|
```bash
|
||||||
Could not find a declaration file for module '@medusajs/medusa-js'
|
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
|
```json title=tsconfig.json
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"moduleResolution": "nodenext",
|
"moduleResolution": "nodenext",
|
||||||
// ...
|
// ...
|
||||||
},
|
},
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</Details>
|
||||||
|
|
||||||
## How to Use this Reference
|
## How to Use this Reference
|
||||||
|
|
||||||
@@ -128,38 +126,38 @@ Once the user or customer is authenticated successfully, the Medusa client autom
|
|||||||
For example:
|
For example:
|
||||||
|
|
||||||
<Tabs groupId="client-authentication-type" isCodeTabs={true}>
|
<Tabs groupId="client-authentication-type" isCodeTabs={true}>
|
||||||
<TabItem value="user" label="Admin User" default>
|
<TabItem value="user" label="Admin User" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import Medusa from "@medusajs/medusa-js"
|
import Medusa from "@medusajs/medusa-js"
|
||||||
const medusa = new Medusa({
|
const medusa = new Medusa({
|
||||||
baseUrl: MEDUSA_BACKEND_URL,
|
baseUrl: MEDUSA_BACKEND_URL,
|
||||||
maxRetries: 3,
|
maxRetries: 3,
|
||||||
})
|
})
|
||||||
await medusa.admin.auth.getToken({
|
await medusa.admin.auth.getToken({
|
||||||
email: "user@example.com",
|
email: "user@example.com",
|
||||||
password: "supersecret",
|
password: "supersecret",
|
||||||
})
|
})
|
||||||
// send authenticated requests now
|
// send authenticated requests now
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="customer" label="Customer">
|
<TabItem value="customer" label="Customer">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import Medusa from "@medusajs/medusa-js"
|
import Medusa from "@medusajs/medusa-js"
|
||||||
const medusa = new Medusa({
|
const medusa = new Medusa({
|
||||||
baseUrl: MEDUSA_BACKEND_URL,
|
baseUrl: MEDUSA_BACKEND_URL,
|
||||||
maxRetries: 3,
|
maxRetries: 3,
|
||||||
})
|
})
|
||||||
await medusa.auth.getToken({
|
await medusa.auth.getToken({
|
||||||
email: "user@example.com",
|
email: "user@example.com",
|
||||||
password: "supersecret",
|
password: "supersecret",
|
||||||
})
|
})
|
||||||
// send authenticated requests now
|
// send authenticated requests now
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
### Cookie Session ID
|
### Cookie Session ID
|
||||||
@@ -173,38 +171,38 @@ Once the user or customer is authenticated successfully, the Medusa client sets
|
|||||||
For example:
|
For example:
|
||||||
|
|
||||||
<Tabs groupId="client-authentication-type" isCodeTabs={true}>
|
<Tabs groupId="client-authentication-type" isCodeTabs={true}>
|
||||||
<TabItem value="user" label="Admin User" default>
|
<TabItem value="user" label="Admin User" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import Medusa from "@medusajs/medusa-js"
|
import Medusa from "@medusajs/medusa-js"
|
||||||
const medusa = new Medusa({
|
const medusa = new Medusa({
|
||||||
baseUrl: MEDUSA_BACKEND_URL,
|
baseUrl: MEDUSA_BACKEND_URL,
|
||||||
maxRetries: 3,
|
maxRetries: 3,
|
||||||
})
|
})
|
||||||
await medusa.admin.AdminAuthResource.createSession({
|
await medusa.admin.AdminAuthResource.createSession({
|
||||||
email: "user@example.com",
|
email: "user@example.com",
|
||||||
password: "supersecret",
|
password: "supersecret",
|
||||||
})
|
})
|
||||||
// send authenticated requests now
|
// send authenticated requests now
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="customer" label="Customer">
|
<TabItem value="customer" label="Customer">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import Medusa from "@medusajs/medusa-js"
|
import Medusa from "@medusajs/medusa-js"
|
||||||
const medusa = new Medusa({
|
const medusa = new Medusa({
|
||||||
baseUrl: MEDUSA_BACKEND_URL,
|
baseUrl: MEDUSA_BACKEND_URL,
|
||||||
maxRetries: 3,
|
maxRetries: 3,
|
||||||
})
|
})
|
||||||
await medusa.auth.authenticate({
|
await medusa.auth.authenticate({
|
||||||
email: "user@example.com",
|
email: "user@example.com",
|
||||||
password: "user@example.com",
|
password: "user@example.com",
|
||||||
})
|
})
|
||||||
// send authenticated requests now
|
// send authenticated requests now
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
### API Key
|
### 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:
|
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}>
|
<Tabs groupId="client-type" isCodeTabs={true}>
|
||||||
<TabItem value="js-client" label="JS Client" default>
|
<TabItem value="js-client" label="JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import Medusa from "@medusajs/medusa-js"
|
import Medusa from "@medusajs/medusa-js"
|
||||||
const medusa = new Medusa({
|
const medusa = new Medusa({
|
||||||
baseUrl: MEDUSA_BACKEND_URL,
|
baseUrl: MEDUSA_BACKEND_URL,
|
||||||
maxRetries: 3,
|
maxRetries: 3,
|
||||||
})
|
})
|
||||||
// must be previously logged in or use api token
|
// must be previously logged in or use api token
|
||||||
medusa.admin.users.update(userId, {
|
medusa.admin.users.update(userId, {
|
||||||
api_token,
|
api_token,
|
||||||
})
|
})
|
||||||
.then(({ user }) => {
|
.then(({ user }) => {
|
||||||
console.log(user.api_token)
|
console.log(user.api_token)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/users/<USER_ID>' \\
|
curl -L -X POST '<BACKEND_URL>/admin/users/<USER_ID>' \\
|
||||||
-H 'Cookie: connect.sid={sid}' \\
|
-H 'Cookie: connect.sid={sid}' \\
|
||||||
-H 'Content-Type: application/json' \\
|
-H 'Content-Type: application/json' \\
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"api_token": "{api_token}"
|
"api_token": "{api_token}"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
Then, initialize the Medusa client passing it the `apiKey` option:
|
Then, initialize the Medusa client passing it the `apiKey` option:
|
||||||
|
|||||||
@@ -235,29 +235,29 @@ The request returns an object containing keys like `data` which is an object tha
|
|||||||
For example:
|
For example:
|
||||||
|
|
||||||
<Tabs groupId="admin-custom-query" isCodeTabs={true}>
|
<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
|
```tsx
|
||||||
import { useAdminCustomQuery } from "medusa-react"
|
import { useAdminCustomQuery } from "medusa-react"
|
||||||
import { useParams } from "react-router-dom"
|
import { useParams } from "react-router-dom"
|
||||||
|
|
||||||
type BlogPost = {
|
type BlogPost = {
|
||||||
title: string,
|
title: string,
|
||||||
content: string,
|
content: string,
|
||||||
author_id: string,
|
author_id: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Single post
|
// Single post
|
||||||
type AdminBlogPostQuery = {
|
type AdminBlogPostQuery = {
|
||||||
expand?: string,
|
expand?: string,
|
||||||
fields?: string
|
fields?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
type AdminBlogPostRes = {
|
type AdminBlogPostRes = {
|
||||||
post: BlogPost,
|
post: BlogPost,
|
||||||
}
|
}
|
||||||
|
|
||||||
const BlogPost = () => {
|
const BlogPost = () => {
|
||||||
const { id } = useParams()
|
const { id } = useParams()
|
||||||
|
|
||||||
const { data, isLoading } = useAdminCustomQuery<
|
const { data, isLoading } = useAdminCustomQuery<
|
||||||
@@ -277,37 +277,37 @@ const BlogPost = () => {
|
|||||||
{data && data.post && <span>{data.post.title}</span>}
|
{data && data.post && <span>{data.post.title}</span>}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default BlogPost
|
export default BlogPost
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="posts-page" label="src/admin/routes/blog/author/[id]/posts/page.tsx">
|
<TabItem value="posts-page" label="src/admin/routes/blog/author/[id]/posts/page.tsx">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCustomQuery } from "medusa-react"
|
import { useAdminCustomQuery } from "medusa-react"
|
||||||
import { useParams } from "react-router-dom"
|
import { useParams } from "react-router-dom"
|
||||||
|
|
||||||
type BlogPost = {
|
type BlogPost = {
|
||||||
title: string,
|
title: string,
|
||||||
content: string,
|
content: string,
|
||||||
author_id: string,
|
author_id: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
type AdminBlogPostsRes = {
|
type AdminBlogPostsRes = {
|
||||||
posts: BlogPost[],
|
posts: BlogPost[],
|
||||||
count: number
|
count: number
|
||||||
}
|
}
|
||||||
|
|
||||||
type AdminBlogPostsQuery = {
|
type AdminBlogPostsQuery = {
|
||||||
author_id: string,
|
author_id: string,
|
||||||
created_at?: string,
|
created_at?: string,
|
||||||
expand?: string,
|
expand?: string,
|
||||||
fields?: string
|
fields?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const AuthorsBlogPosts = () => {
|
const AuthorsBlogPosts = () => {
|
||||||
const { id } = useParams()
|
const { id } = useParams()
|
||||||
|
|
||||||
const { data, isLoading } = useAdminCustomQuery<
|
const { data, isLoading } = useAdminCustomQuery<
|
||||||
@@ -333,12 +333,12 @@ const AuthorsBlogPosts = () => {
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AuthorsBlogPosts
|
export default AuthorsBlogPosts
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
#### useAdminCustomPost
|
#### useAdminCustomPost
|
||||||
|
|||||||
@@ -53,24 +53,24 @@ It's also assumed you already have [used CartProvider higher in your component t
|
|||||||
You can create a cart with the following code snippet:
|
You can create a cart with the following code snippet:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.carts.create()
|
medusa.carts.create()
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
localStorage.setItem("cart_id", cart.id)
|
localStorage.setItem("cart_id", cart.id)
|
||||||
// assuming you have a state variable to store the cart
|
// assuming you have a state variable to store the cart
|
||||||
setCart(cart)
|
setCart(cart)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCart } from "medusa-react"
|
import { useCart } from "medusa-react"
|
||||||
|
|
||||||
const Cart = () => {
|
const Cart = () => {
|
||||||
const { cart, createCart } = useCart()
|
const { cart, createCart } = useCart()
|
||||||
|
|
||||||
const handleCreateCart = () => {
|
const handleCreateCart = () => {
|
||||||
@@ -85,28 +85,28 @@ const Cart = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Cart
|
export default Cart
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URLL>/store/carts`, {
|
fetch(`<BACKEND_URLL>/store/carts`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
localStorage.setItem("cart_id", cart.id)
|
localStorage.setItem("cart_id", cart.id)
|
||||||
// assuming you have a state variable to store the cart
|
// assuming you have a state variable to store the cart
|
||||||
setCart(cart)
|
setCart(cart)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request does not require any parameters. It returns the created cart in the response.
|
This request does not require any parameters. It returns the created cart in the response.
|
||||||
@@ -116,26 +116,26 @@ 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:
|
Otherwise, you can assign it a specific region during creation:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
medusa.carts.create({
|
medusa.carts.create({
|
||||||
region_id,
|
region_id,
|
||||||
})
|
})
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
localStorage.setItem("cart_id", cart.id)
|
localStorage.setItem("cart_id", cart.id)
|
||||||
// assuming you have a state variable to store the cart
|
// assuming you have a state variable to store the cart
|
||||||
setCart(cart)
|
setCart(cart)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCart } from "medusa-react"
|
import { useCart } from "medusa-react"
|
||||||
|
|
||||||
const Cart = () => {
|
const Cart = () => {
|
||||||
const { cart, createCart } = useCart()
|
const { cart, createCart } = useCart()
|
||||||
|
|
||||||
const handleCreateCart = () => {
|
const handleCreateCart = () => {
|
||||||
@@ -152,16 +152,16 @@ const Cart = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Cart
|
export default Cart
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
fetch(`<BACKEND_URLL>/store/carts`, {
|
fetch(`<BACKEND_URLL>/store/carts`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -170,16 +170,16 @@ fetch(`<BACKEND_URLL>/store/carts`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
region_id,
|
region_id,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
localStorage.setItem("cart_id", cart.id)
|
localStorage.setItem("cart_id", cart.id)
|
||||||
// assuming you have a state variable to store the cart
|
// assuming you have a state variable to store the cart
|
||||||
setCart(cart)
|
setCart(cart)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
Check out the [API Reference](https://docs.medusajs.com/api/store#carts_postcart) for a full list of available request body parameters.
|
Check out the [API Reference](https://docs.medusajs.com/api/store#carts_postcart) for a full list of available request body parameters.
|
||||||
@@ -199,24 +199,24 @@ 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:
|
You can retrieve the cart at any given point using its ID with the following code snippet:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const id = localStorage.getItem("cart_id")
|
const id = localStorage.getItem("cart_id")
|
||||||
|
|
||||||
if (id) {
|
if (id) {
|
||||||
medusa.carts.retrieve(id)
|
medusa.carts.retrieve(id)
|
||||||
.then(({ cart }) => setCart(cart))
|
.then(({ cart }) => setCart(cart))
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React" default>
|
<TabItem value="medusa-react" label="Medusa React" default>
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCart } from "medusa-react"
|
import { useCart } from "medusa-react"
|
||||||
|
|
||||||
const Cart = () => {
|
const Cart = () => {
|
||||||
const { cart } = useCart()
|
const { cart } = useCart()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -224,27 +224,27 @@ const Cart = () => {
|
|||||||
Items in Cart: {cart?.items.length || 0}
|
Items in Cart: {cart?.items.length || 0}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Cart
|
export default Cart
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const id = localStorage.getItem("cart_id")
|
const id = localStorage.getItem("cart_id")
|
||||||
|
|
||||||
if (id) {
|
if (id) {
|
||||||
fetch(`<BACKEND_URLL>/store/carts/${id}`, {
|
fetch(`<BACKEND_URLL>/store/carts/${id}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ cart }) => setCart(cart))
|
.then(({ cart }) => setCart(cart))
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request accepts the ID of the cart as a path parameter and returns the cart of that ID.
|
This request accepts the ID of the cart as a path parameter and returns the cart of that ID.
|
||||||
@@ -266,22 +266,22 @@ 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:
|
You can use the following snippet to update any of the cart’s data:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.carts.update(cartId, {
|
medusa.carts.update(cartId, {
|
||||||
region_id,
|
region_id,
|
||||||
})
|
})
|
||||||
.then(({ cart }) => setCart(cart))
|
.then(({ cart }) => setCart(cart))
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCart } from "medusa-react"
|
import { useCart } from "medusa-react"
|
||||||
|
|
||||||
const Cart = () => {
|
const Cart = () => {
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
const { updateCart } = useCart()
|
const { updateCart } = useCart()
|
||||||
@@ -293,16 +293,16 @@ const Cart = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Cart
|
export default Cart
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URLL>/store/carts/${cartId}`, {
|
fetch(`<BACKEND_URLL>/store/carts/${cartId}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -311,12 +311,12 @@ fetch(`<BACKEND_URLL>/store/carts/${cartId}`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
region_id,
|
region_id,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ cart }) => setCart(cart))
|
.then(({ cart }) => setCart(cart))
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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,22 +332,22 @@ 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:
|
You can do that using the same update operation:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.carts.update(cartId, {
|
medusa.carts.update(cartId, {
|
||||||
customer_id,
|
customer_id,
|
||||||
})
|
})
|
||||||
.then(({ cart }) => setCart(cart))
|
.then(({ cart }) => setCart(cart))
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCart } from "medusa-react"
|
import { useCart } from "medusa-react"
|
||||||
|
|
||||||
const Cart = () => {
|
const Cart = () => {
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
const { updateCart } = useCart()
|
const { updateCart } = useCart()
|
||||||
@@ -359,16 +359,16 @@ const Cart = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Cart
|
export default Cart
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URLL>/store/carts/${cartId}`, {
|
fetch(`<BACKEND_URLL>/store/carts/${cartId}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -377,12 +377,12 @@ fetch(`<BACKEND_URLL>/store/carts/${cartId}`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
customer_id,
|
customer_id,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ cart }) => setCart(cart))
|
.then(({ cart }) => setCart(cart))
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This updates the `customer_id` associated with the cart to make sure it belongs to a specific customer.
|
This updates the `customer_id` associated with the cart to make sure it belongs to a specific customer.
|
||||||
@@ -394,22 +394,22 @@ 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:
|
You can do that using the same update operation:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.carts.update(cartId, {
|
medusa.carts.update(cartId, {
|
||||||
email: "user@example.com",
|
email: "user@example.com",
|
||||||
})
|
})
|
||||||
.then(({ cart }) => setCart(cart))
|
.then(({ cart }) => setCart(cart))
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCart } from "medusa-react"
|
import { useCart } from "medusa-react"
|
||||||
|
|
||||||
const Cart = () => {
|
const Cart = () => {
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
const { updateCart } = useCart()
|
const { updateCart } = useCart()
|
||||||
@@ -421,16 +421,16 @@ const Cart = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Cart
|
export default Cart
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URLL>/store/carts/${cartId}`, {
|
fetch(`<BACKEND_URLL>/store/carts/${cartId}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -439,12 +439,12 @@ fetch(`<BACKEND_URLL>/store/carts/${cartId}`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
email: "user@example.com",
|
email: "user@example.com",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ cart }) => setCart(cart))
|
.then(({ cart }) => setCart(cart))
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -454,23 +454,23 @@ 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:
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
medusa.carts.lineItems.create(cartId, {
|
medusa.carts.lineItems.create(cartId, {
|
||||||
variant_id,
|
variant_id,
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
})
|
})
|
||||||
.then(({ cart }) => setCart(cart))
|
.then(({ cart }) => setCart(cart))
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCreateLineItem } from "medusa-react"
|
import { useCreateLineItem } from "medusa-react"
|
||||||
|
|
||||||
const Cart = () => {
|
const Cart = () => {
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
const createLineItem = useCreateLineItem(cart_id)
|
const createLineItem = useCreateLineItem(cart_id)
|
||||||
@@ -483,16 +483,16 @@ const Cart = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Cart
|
export default Cart
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
fetch(`<BACKEND_URLL>/store/carts/${cartId}/line-items`, {
|
fetch(`<BACKEND_URLL>/store/carts/${cartId}/line-items`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -502,12 +502,12 @@ fetch(`<BACKEND_URLL>/store/carts/${cartId}/line-items`, {
|
|||||||
variant_id,
|
variant_id,
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ cart }) => setCart(cart))
|
.then(({ cart }) => setCart(cart))
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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,22 +529,22 @@ 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:
|
To update a line item's quantity in the cart, you can use the following code snippet:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.carts.lineItems.update(cartId, lineItemId, {
|
medusa.carts.lineItems.update(cartId, lineItemId, {
|
||||||
quantity: 3,
|
quantity: 3,
|
||||||
})
|
})
|
||||||
.then(({ cart }) => setCart(cart))
|
.then(({ cart }) => setCart(cart))
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useUpdateLineItem } from "medusa-react"
|
import { useUpdateLineItem } from "medusa-react"
|
||||||
|
|
||||||
const Cart = () => {
|
const Cart = () => {
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
const updateLineItem = useUpdateLineItem(cart_id)
|
const updateLineItem = useUpdateLineItem(cart_id)
|
||||||
@@ -557,18 +557,18 @@ const Cart = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Cart
|
export default Cart
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URLL>/store/carts/${cartId}/line-items/${lineItemId}`, {
|
fetch(`<BACKEND_URLL>/store/carts/${cartId}/line-items/${lineItemId}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -577,12 +577,12 @@ fetch(`<BACKEND_URLL>/store/carts/${cartId}/line-items/${lineItemId}`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
quantity: 3,
|
quantity: 3,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ cart }) => setCart(cart))
|
.then(({ cart }) => setCart(cart))
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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,20 +596,20 @@ It returns the updated cart.
|
|||||||
To delete a line item from the cart, you can use the following code snippet:
|
To delete a line item from the cart, you can use the following code snippet:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.carts.lineItems.delete(cartId, lineItemId)
|
medusa.carts.lineItems.delete(cartId, lineItemId)
|
||||||
.then(({ cart }) => setCart(cart))
|
.then(({ cart }) => setCart(cart))
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useDeleteLineItem } from "medusa-react"
|
import { useDeleteLineItem } from "medusa-react"
|
||||||
|
|
||||||
const Cart = () => {
|
const Cart = () => {
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
const deleteLineItem = useDeleteLineItem(cart_id)
|
const deleteLineItem = useDeleteLineItem(cart_id)
|
||||||
@@ -621,26 +621,26 @@ const Cart = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Cart
|
export default Cart
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URLL>/store/carts/${cartId}/line-items/${lineItemId}`, {
|
fetch(`<BACKEND_URLL>/store/carts/${cartId}/line-items/${lineItemId}`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ cart }) => setCart(cart))
|
.then(({ cart }) => setCart(cart))
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request accepts the ID of the cart and the ID of the line item as path parameters.
|
This request accepts the ID of the cart and the ID of the line item as path parameters.
|
||||||
|
|||||||
+178
-178
@@ -63,10 +63,10 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.carts.update(cartId, {
|
medusa.carts.update(cartId, {
|
||||||
shipping_address: {
|
shipping_address: {
|
||||||
company,
|
company,
|
||||||
first_name,
|
first_name,
|
||||||
@@ -79,19 +79,19 @@ medusa.carts.update(cartId, {
|
|||||||
postal_code,
|
postal_code,
|
||||||
phone,
|
phone,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
console.log(cart.shipping_address)
|
console.log(cart.shipping_address)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCart } from "medusa-react"
|
import { useCart } from "medusa-react"
|
||||||
|
|
||||||
const Cart = () => {
|
const Cart = () => {
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
const { updateCart } = useCart()
|
const { updateCart } = useCart()
|
||||||
@@ -115,16 +115,16 @@ const Cart = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Cart
|
export default Cart
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/carts/${cartId}`, {
|
fetch(`<BACKEND_URL>/store/carts/${cartId}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@@ -144,14 +144,14 @@ fetch(`<BACKEND_URL>/store/carts/${cartId}`, {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
console.log(cart.shipping_address)
|
console.log(cart.shipping_address)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request accepts the ID of the cart as a path parameter and the new shipping address in the request body.
|
This request accepts the ID of the cart as a path parameter and the new shipping address in the request body.
|
||||||
@@ -167,26 +167,26 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.shippingOptions.listCartOptions(cartId)
|
medusa.shippingOptions.listCartOptions(cartId)
|
||||||
.then(({ shipping_options }) => {
|
.then(({ shipping_options }) => {
|
||||||
console.log(shipping_options.length)
|
console.log(shipping_options.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCartShippingOptions } from "medusa-react"
|
import { useCartShippingOptions } from "medusa-react"
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
cartId: string
|
cartId: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const ShippingOptions = ({ cartId }: Props) => {
|
const ShippingOptions = ({ cartId }: Props) => {
|
||||||
const { shipping_options, isLoading } =
|
const { shipping_options, isLoading } =
|
||||||
useCartShippingOptions(cartId)
|
useCartShippingOptions(cartId)
|
||||||
|
|
||||||
@@ -209,25 +209,25 @@ const ShippingOptions = ({ cartId }: Props) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ShippingOptions
|
export default ShippingOptions
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/shipping-options/${cartId}`, {
|
fetch(`<BACKEND_URL>/store/shipping-options/${cartId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ shipping_options }) => {
|
.then(({ shipping_options }) => {
|
||||||
console.log(shipping_options.length)
|
console.log(shipping_options.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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,25 +237,25 @@ 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:
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.carts.addShippingMethod(cartId, {
|
medusa.carts.addShippingMethod(cartId, {
|
||||||
option_id: shippingOptionId, // the ID of the selected option
|
option_id: shippingOptionId, // the ID of the selected option
|
||||||
})
|
})
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
console.log(cart.shipping_methods)
|
console.log(cart.shipping_methods)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAddShippingMethodToCart } from "medusa-react"
|
import { useAddShippingMethodToCart } from "medusa-react"
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
const ShippingOptions = ({ cartId }: Props) => {
|
const ShippingOptions = ({ cartId }: Props) => {
|
||||||
// ...
|
// ...
|
||||||
const addShippingMethod = useAddShippingMethodToCart(cartId)
|
const addShippingMethod = useAddShippingMethodToCart(cartId)
|
||||||
|
|
||||||
@@ -266,16 +266,16 @@ const ShippingOptions = ({ cartId }: Props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ShippingOptions
|
export default ShippingOptions
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/carts/${cartId}/shipping-methods`, {
|
fetch(`<BACKEND_URL>/store/carts/${cartId}/shipping-methods`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@@ -284,14 +284,14 @@ fetch(`<BACKEND_URL>/store/carts/${cartId}/shipping-methods`, {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
console.log(cart.shipping_methods)
|
console.log(cart.shipping_methods)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
The request accepts the ID of the cart as a path parameter and its body the ID of the selected shipping option.
|
The request accepts the ID of the cart as a path parameter and its body the ID of the selected shipping option.
|
||||||
@@ -311,23 +311,23 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.carts.createPaymentSessions(cartId)
|
medusa.carts.createPaymentSessions(cartId)
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
console.log(cart.payment_sessions)
|
console.log(cart.payment_sessions)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCart } from "medusa-react"
|
import { useCart } from "medusa-react"
|
||||||
import { useEffect } from "react"
|
import { useEffect } from "react"
|
||||||
|
|
||||||
const PaymentProviders = () => {
|
const PaymentProviders = () => {
|
||||||
const { cart, startCheckout } = useCart()
|
const { cart, startCheckout } = useCart()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -350,26 +350,26 @@ const PaymentProviders = () => {
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PaymentProviders
|
export default PaymentProviders
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/carts/${cartId}/payment-sessions`, {
|
fetch(`<BACKEND_URL>/store/carts/${cartId}/payment-sessions`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
console.log(cart.payment_sessions)
|
console.log(cart.payment_sessions)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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`.
|
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,25 +379,25 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.carts.setPaymentSession(cartId, {
|
medusa.carts.setPaymentSession(cartId, {
|
||||||
// retrieved from the payment session selected by the customer
|
// retrieved from the payment session selected by the customer
|
||||||
provider_id: paymentProviderId,
|
provider_id: paymentProviderId,
|
||||||
})
|
})
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
console.log(cart.payment_session)
|
console.log(cart.payment_session)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCart } from "medusa-react"
|
import { useCart } from "medusa-react"
|
||||||
|
|
||||||
const PaymentProviders = () => {
|
const PaymentProviders = () => {
|
||||||
const { cart, startCheckout, pay } = useCart()
|
const { cart, startCheckout, pay } = useCart()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -408,16 +408,16 @@ const PaymentProviders = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PaymentProviders
|
export default PaymentProviders
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/carts/${cartId}/payment-session`, {
|
fetch(`<BACKEND_URL>/store/carts/${cartId}/payment-session`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@@ -427,14 +427,14 @@ fetch(`<BACKEND_URL>/store/carts/${cartId}/payment-session`, {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
console.log(cart.payment_session)
|
console.log(cart.payment_session)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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,29 +454,29 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.carts.updatePaymentSession(cartId, paymentProviderId, {
|
medusa.carts.updatePaymentSession(cartId, paymentProviderId, {
|
||||||
data: {
|
data: {
|
||||||
// pass any data you want to add in the `data` attribute
|
// pass any data you want to add in the `data` attribute
|
||||||
// for example:
|
// for example:
|
||||||
"test": true,
|
"test": true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
console.log(cart.payment_session.data)
|
console.log(cart.payment_session.data)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useUpdatePaymentSession, useCart } from "medusa-react"
|
import { useUpdatePaymentSession, useCart } from "medusa-react"
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
const PaymentProviders = () => {
|
const PaymentProviders = () => {
|
||||||
const { cart } = useCart()
|
const { cart } = useCart()
|
||||||
const updatePaymentSession = useUpdatePaymentSession(cart.id)
|
const updatePaymentSession = useUpdatePaymentSession(cart.id)
|
||||||
// ...
|
// ...
|
||||||
@@ -492,18 +492,18 @@ const PaymentProviders = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PaymentProviders
|
export default PaymentProviders
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/store/carts/${cartId}/payment-sessions/${paymentProviderId}`,
|
`<BACKEND_URL>/store/carts/${cartId}/payment-sessions/${paymentProviderId}`,
|
||||||
{
|
{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -519,14 +519,14 @@ fetch(
|
|||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
console.log(cart.payment_session.data)
|
console.log(cart.payment_session.data)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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,23 +540,23 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.carts.complete(cartId)
|
medusa.carts.complete(cartId)
|
||||||
.then(({ type, data }) => {
|
.then(({ type, data }) => {
|
||||||
console.log(type, data)
|
console.log(type, data)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCart } from "medusa-react"
|
import { useCart } from "medusa-react"
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
const Cart = () => {
|
const Cart = () => {
|
||||||
const { completeCheckout } = useCart()
|
const { completeCheckout } = useCart()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -565,29 +565,29 @@ const Cart = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Cart
|
export default Cart
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/carts/${cartId}/complete`, {
|
fetch(`<BACKEND_URL>/store/carts/${cartId}/complete`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ type, data }) => {
|
.then(({ type, data }) => {
|
||||||
console.log(type, data)
|
console.log(type, data)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request accepts the ID of the cart as a path parameter.
|
This request accepts the ID of the cart as a path parameter.
|
||||||
|
|||||||
@@ -51,24 +51,24 @@ You can learn more about [authenticating as an admin user in the API reference](
|
|||||||
You can create a customer group by sending a request to the Create Customer Group API Route:
|
You can create a customer group by sending a request to the Create Customer Group API Route:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.customerGroups.create({
|
medusa.admin.customerGroups.create({
|
||||||
name: "VIP",
|
name: "VIP",
|
||||||
})
|
})
|
||||||
.then(({ customer_group }) => {
|
.then(({ customer_group }) => {
|
||||||
console.log(customer_group.id)
|
console.log(customer_group.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateCustomerGroup } from "medusa-react"
|
import { useAdminCreateCustomerGroup } from "medusa-react"
|
||||||
|
|
||||||
const CreateCustomerGroup = () => {
|
const CreateCustomerGroup = () => {
|
||||||
const createCustomerGroup = useAdminCreateCustomerGroup()
|
const createCustomerGroup = useAdminCreateCustomerGroup()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -85,16 +85,16 @@ const CreateCustomerGroup = () => {
|
|||||||
{/* Render form */}
|
{/* Render form */}
|
||||||
</form>
|
</form>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateCustomerGroup
|
export default CreateCustomerGroup
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/customer-groups`, {
|
fetch(`<BACKEND_URL>/admin/customer-groups`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -103,26 +103,26 @@ fetch(`<BACKEND_URL>/admin/customer-groups`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
name: "VIP",
|
name: "VIP",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ customer_group }) => {
|
.then(({ customer_group }) => {
|
||||||
console.log(customer_group.id)
|
console.log(customer_group.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/customer-groups' \
|
curl -L -X POST '<BACKEND_URL>/admin/customer-groups' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"name": "VIP"
|
"name": "VIP"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the `name` parameter and optionally accepts the `metadata` object parameter to be passed in the body. It returns the created customer group.
|
This request requires the `name` parameter and optionally accepts the `metadata` object parameter to be passed in the body. It returns the created customer group.
|
||||||
@@ -134,23 +134,23 @@ This request requires the `name` parameter and optionally accepts the `metadata`
|
|||||||
You can get a list of all customer groups by sending a request to the List Customer Groups API Route:
|
You can get a list of all customer groups by sending a request to the List Customer Groups API Route:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.customerGroups.list()
|
medusa.admin.customerGroups.list()
|
||||||
.then(({ customer_groups, limit, offset, count }) => {
|
.then(({ customer_groups, limit, offset, count }) => {
|
||||||
console.log(customer_groups.length)
|
console.log(customer_groups.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { CustomerGroup } from "@medusajs/medusa"
|
import { CustomerGroup } from "@medusajs/medusa"
|
||||||
import { useAdminCustomerGroups } from "medusa-react"
|
import { useAdminCustomerGroups } from "medusa-react"
|
||||||
|
|
||||||
const CustomerGroups = () => {
|
const CustomerGroups = () => {
|
||||||
const {
|
const {
|
||||||
customer_groups,
|
customer_groups,
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -175,33 +175,33 @@ const CustomerGroups = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CustomerGroups
|
export default CustomerGroups
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/customer-groups`, {
|
fetch(`<BACKEND_URL>/admin/customer-groups`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ customer_groups, limit, offset, count }) => {
|
.then(({ customer_groups, limit, offset, count }) => {
|
||||||
console.log(customer_groups.length)
|
console.log(customer_groups.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/customer-groups' \
|
curl -L -X GET '<BACKEND_URL>/admin/customer-groups' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request returns an array of customer groups, as well as pagination fields.
|
This request returns an array of customer groups, as well as pagination fields.
|
||||||
@@ -215,22 +215,22 @@ You can also pass filters and other selection query parameters to the request. C
|
|||||||
You can retrieve a single customer group by sending a request to the Get a Customer Group API Route:
|
You can retrieve a single customer group by sending a request to the Get a Customer Group API Route:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.customerGroups.retrieve(customerGroupId)
|
medusa.admin.customerGroups.retrieve(customerGroupId)
|
||||||
.then(({ customer_group }) => {
|
.then(({ customer_group }) => {
|
||||||
console.log(customer_group.id)
|
console.log(customer_group.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCustomerGroup } from "medusa-react"
|
import { useAdminCustomerGroup } from "medusa-react"
|
||||||
|
|
||||||
const CustomerGroup = () => {
|
const CustomerGroup = () => {
|
||||||
const { customer_group, isLoading } = useAdminCustomerGroup(
|
const { customer_group, isLoading } = useAdminCustomerGroup(
|
||||||
customerGroupId
|
customerGroupId
|
||||||
)
|
)
|
||||||
@@ -241,36 +241,36 @@ const CustomerGroup = () => {
|
|||||||
{customer_group && <span>{customer_group.name}</span>}
|
{customer_group && <span>{customer_group.name}</span>}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CustomerGroup
|
export default CustomerGroup
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/admin/customer-groups/${customerGroupId}`,
|
`<BACKEND_URL>/admin/customer-groups/${customerGroupId}`,
|
||||||
{
|
{
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ customer_group }) => {
|
.then(({ customer_group }) => {
|
||||||
console.log(customer_group.id)
|
console.log(customer_group.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/customer-groups/<CUSTOMER_GROUP_ID>' \
|
curl -L -X GET '<BACKEND_URL>/admin/customer-groups/<CUSTOMER_GROUP_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request accepts the ID of the customer group to retrieve as a path parameter. It returns the customer group of that ID.
|
This request accepts the ID of the customer group to retrieve as a path parameter. It returns the customer group of that ID.
|
||||||
@@ -282,26 +282,26 @@ This request accepts the ID of the customer group to retrieve as a path paramete
|
|||||||
You can update a customer group’s data by sending a request to the Update Customer Group API Route:
|
You can update a customer group’s data by sending a request to the Update Customer Group API Route:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.customerGroups.update(customerGroupId, {
|
medusa.admin.customerGroups.update(customerGroupId, {
|
||||||
metadata: {
|
metadata: {
|
||||||
is_seller: true,
|
is_seller: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(({ customer_group }) => {
|
.then(({ customer_group }) => {
|
||||||
console.log(customer_group.id)
|
console.log(customer_group.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUpdateCustomerGroup } from "medusa-react"
|
import { useAdminUpdateCustomerGroup } from "medusa-react"
|
||||||
|
|
||||||
const UpdateCustomerGroup = () => {
|
const UpdateCustomerGroup = () => {
|
||||||
const updateCustomerGroup = useAdminUpdateCustomerGroup(
|
const updateCustomerGroup = useAdminUpdateCustomerGroup(
|
||||||
customerGroupId
|
customerGroupId
|
||||||
)
|
)
|
||||||
@@ -320,16 +320,16 @@ const UpdateCustomerGroup = () => {
|
|||||||
{/* Render form */}
|
{/* Render form */}
|
||||||
</form>
|
</form>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdateCustomerGroup
|
export default UpdateCustomerGroup
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/admin/customer-groups/${customerGroupId}`,
|
`<BACKEND_URL>/admin/customer-groups/${customerGroupId}`,
|
||||||
{
|
{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -343,28 +343,28 @@ fetch(
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ customer_group }) => {
|
.then(({ customer_group }) => {
|
||||||
console.log(customer_group.id)
|
console.log(customer_group.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/customer-groups/<CUSTOMER_GROUP_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/customer-groups/<CUSTOMER_GROUP_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"is_seller": true
|
"is_seller": true
|
||||||
}
|
}
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request accepts the ID of the customer group as a path parameter, and optionally accepts the `name` or `metadata` fields as body parameters. It returns the updated customer group.
|
This request accepts the ID of the customer group as a path parameter, and optionally accepts the `name` or `metadata` fields as body parameters. It returns the updated customer group.
|
||||||
@@ -376,22 +376,22 @@ This request accepts the ID of the customer group as a path parameter, and optio
|
|||||||
You can delete a customer group by sending a request to the Delete a Customer Group API Route:
|
You can delete a customer group by sending a request to the Delete a Customer Group API Route:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.customerGroups.delete(customerGroupId)
|
medusa.admin.customerGroups.delete(customerGroupId)
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDeleteCustomerGroup } from "medusa-react"
|
import { useAdminDeleteCustomerGroup } from "medusa-react"
|
||||||
|
|
||||||
const CustomerGroup = () => {
|
const CustomerGroup = () => {
|
||||||
const deleteCustomerGroup = useAdminDeleteCustomerGroup(
|
const deleteCustomerGroup = useAdminDeleteCustomerGroup(
|
||||||
customerGroupId
|
customerGroupId
|
||||||
)
|
)
|
||||||
@@ -402,37 +402,37 @@ const CustomerGroup = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CustomerGroup
|
export default CustomerGroup
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/admin/customer-groups/${customerGroupId}`,
|
`<BACKEND_URL>/admin/customer-groups/${customerGroupId}`,
|
||||||
{
|
{
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/customer-groups/<CUSTOMER_GROUP_ID>' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/customer-groups/<CUSTOMER_GROUP_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request accepts the ID of the customer group to delete as a path parameter. It returns the ID of the deleted entity.
|
This request accepts the ID of the customer group to delete as a path parameter. It returns the ID of the deleted entity.
|
||||||
@@ -446,30 +446,30 @@ This request accepts the ID of the customer group to delete as a path parameter.
|
|||||||
You can add a customer to a group by sending a request to the Customer Group’s Add Customer API Route:
|
You can add a customer to a group by sending a request to the Customer Group’s Add Customer API Route:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.customerGroups.addCustomers(customerGroupId, {
|
medusa.admin.customerGroups.addCustomers(customerGroupId, {
|
||||||
customer_ids: [
|
customer_ids: [
|
||||||
{
|
{
|
||||||
id: customerId,
|
id: customerId,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.then(({ customer_group }) => {
|
.then(({ customer_group }) => {
|
||||||
console.log(customer_group.id)
|
console.log(customer_group.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import {
|
import {
|
||||||
useAdminAddCustomersToCustomerGroup,
|
useAdminAddCustomersToCustomerGroup,
|
||||||
} from "medusa-react"
|
} from "medusa-react"
|
||||||
|
|
||||||
const CustomerGroup = () => {
|
const CustomerGroup = () => {
|
||||||
const addCustomers = useAdminAddCustomersToCustomerGroup(
|
const addCustomers = useAdminAddCustomersToCustomerGroup(
|
||||||
customerGroupId
|
customerGroupId
|
||||||
)
|
)
|
||||||
@@ -486,18 +486,18 @@ const CustomerGroup = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CustomerGroup
|
export default CustomerGroup
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/admin/customer-groups/${customerGroupId}/customers/batch`,
|
`<BACKEND_URL>/admin/customer-groups/${customerGroupId}/customers/batch`,
|
||||||
{
|
{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -513,30 +513,30 @@ fetch(
|
|||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ customer_group }) => {
|
.then(({ customer_group }) => {
|
||||||
console.log(customer_group.id)
|
console.log(customer_group.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/customer-groups/<CUSTOMER_GROUP_ID>/customers/batch' \
|
curl -L -X POST '<BACKEND_URL>/admin/customer-groups/<CUSTOMER_GROUP_ID>/customers/batch' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"customer_ids": [
|
"customer_ids": [
|
||||||
{
|
{
|
||||||
"id": "<CUSTOMER_ID>"
|
"id": "<CUSTOMER_ID>"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request accepts the ID of the customer group as a path parameter. In its body, it accepts a `customer_ids` array of objects. Each object in the array must have the `id` property with its value being the ID of the customer you want to add.
|
This request accepts the ID of the customer group as a path parameter. In its body, it accepts a `customer_ids` array of objects. Each object in the array must have the `id` property with its value being the ID of the customer you want to add.
|
||||||
@@ -546,23 +546,23 @@ This request accepts the ID of the customer group as a path parameter. In its bo
|
|||||||
You can retrieve a list of all customers in a customer group using the List Customers API Route:
|
You can retrieve a list of all customers in a customer group using the List Customers API Route:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.customerGroups.listCustomers(customerGroupId)
|
medusa.admin.customerGroups.listCustomers(customerGroupId)
|
||||||
.then(({ customers, count, offset, limit }) => {
|
.then(({ customers, count, offset, limit }) => {
|
||||||
console.log(customers.length)
|
console.log(customers.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { Customer } from "@medusajs/medusa"
|
import { Customer } from "@medusajs/medusa"
|
||||||
import { useAdminCustomerGroupCustomers } from "medusa-react"
|
import { useAdminCustomerGroupCustomers } from "medusa-react"
|
||||||
|
|
||||||
const CustomerGroup = () => {
|
const CustomerGroup = () => {
|
||||||
const {
|
const {
|
||||||
customers,
|
customers,
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -585,35 +585,35 @@ const CustomerGroup = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CustomerGroup
|
export default CustomerGroup
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/customer-groups/${customerGroupId}/customers`, {
|
fetch(`<BACKEND_URL>/admin/customer-groups/${customerGroupId}/customers`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ customers, count, offset, limit }) => {
|
.then(({ customers, count, offset, limit }) => {
|
||||||
console.log(customers.length)
|
console.log(customers.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/customer-groups/<CUSTOMER_GROUP_ID>/customers' \
|
curl -L -X GET '<BACKEND_URL>/admin/customer-groups/<CUSTOMER_GROUP_ID>/customers' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request accepts the ID of the customer group as a path parameter. It returns an array of customers along with pagination fields.
|
This request accepts the ID of the customer group as a path parameter. It returns an array of customers along with pagination fields.
|
||||||
@@ -629,10 +629,10 @@ Removing customers from a group does not remove them entirely. They’ll still b
|
|||||||
You can remove customers from a customer group by sending a request to the Remove Customers API Route:
|
You can remove customers from a customer group by sending a request to the Remove Customers API Route:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.customerGroups.removeCustomers(
|
medusa.admin.customerGroups.removeCustomers(
|
||||||
customer_group_id,
|
customer_group_id,
|
||||||
{
|
{
|
||||||
customer_ids: [
|
customer_ids: [
|
||||||
@@ -641,22 +641,22 @@ medusa.admin.customerGroups.removeCustomers(
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(({ customer_group }) => {
|
.then(({ customer_group }) => {
|
||||||
console.log(customer_group.id)
|
console.log(customer_group.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { Customer } from "@medusajs/medusa"
|
import { Customer } from "@medusajs/medusa"
|
||||||
import {
|
import {
|
||||||
useAdminRemoveCustomersFromCustomerGroup,
|
useAdminRemoveCustomersFromCustomerGroup,
|
||||||
} from "medusa-react"
|
} from "medusa-react"
|
||||||
|
|
||||||
const CustomerGroup = () => {
|
const CustomerGroup = () => {
|
||||||
const removeCustomers =
|
const removeCustomers =
|
||||||
useAdminRemoveCustomersFromCustomerGroup(
|
useAdminRemoveCustomersFromCustomerGroup(
|
||||||
customerGroupId
|
customerGroupId
|
||||||
@@ -674,18 +674,18 @@ const CustomerGroup = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CustomerGroup
|
export default CustomerGroup
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/admin/customer-groups/${customerGroupId}/customers/batch`,
|
`<BACKEND_URL>/admin/customer-groups/${customerGroupId}/customers/batch`,
|
||||||
{
|
{
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
@@ -701,30 +701,30 @@ fetch(
|
|||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ customer_group }) => {
|
.then(({ customer_group }) => {
|
||||||
console.log(customer_group.id)
|
console.log(customer_group.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/customer-groups/<CUSTOMER_GROUP_ID>/customers/batch' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/customer-groups/<CUSTOMER_GROUP_ID>/customers/batch' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"customer_ids": [
|
"customer_ids": [
|
||||||
{
|
{
|
||||||
"id": "<CUSTOMER_ID>"
|
"id": "<CUSTOMER_ID>"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request accepts as a path parameter the ID of the customer group to remove customers from. In its body, it accepts a `customer_ids` array of objects. Each object in the array must have the `id` property with the value being the ID of the customer to remove from the group.
|
This request accepts as a path parameter the ID of the customer group to remove customers from. In its body, it accepts a `customer_ids` array of objects. Each object in the array must have the `id` property with the value being the ID of the customer to remove from the group.
|
||||||
|
|||||||
@@ -55,23 +55,23 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.customers.list()
|
medusa.admin.customers.list()
|
||||||
.then(({ customers, limit, offset, count }) => {
|
.then(({ customers, limit, offset, count }) => {
|
||||||
console.log(customers.length)
|
console.log(customers.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { Customer } from "@medusajs/medusa"
|
import { Customer } from "@medusajs/medusa"
|
||||||
import { useAdminCustomers } from "medusa-react"
|
import { useAdminCustomers } from "medusa-react"
|
||||||
|
|
||||||
const Customers = () => {
|
const Customers = () => {
|
||||||
const { customers, isLoading } = useAdminCustomers()
|
const { customers, isLoading } = useAdminCustomers()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -89,33 +89,33 @@ const Customers = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Customers
|
export default Customers
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/customers`, {
|
fetch(`<BACKEND_URL>/admin/customers`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ customers, limit, offset, count }) => {
|
.then(({ customers, limit, offset, count }) => {
|
||||||
console.log(customers.length)
|
console.log(customers.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/customers' \
|
curl -L -X GET '<BACKEND_URL>/admin/customers' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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,27 +142,27 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.customers.create({
|
medusa.admin.customers.create({
|
||||||
email,
|
email,
|
||||||
password,
|
password,
|
||||||
first_name,
|
first_name,
|
||||||
last_name,
|
last_name,
|
||||||
})
|
})
|
||||||
.then(({ customer }) => {
|
.then(({ customer }) => {
|
||||||
console.log(customer.id)
|
console.log(customer.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateCustomer } from "medusa-react"
|
import { useAdminCreateCustomer } from "medusa-react"
|
||||||
|
|
||||||
const CreateCustomer = () => {
|
const CreateCustomer = () => {
|
||||||
const createCustomer = useAdminCreateCustomer()
|
const createCustomer = useAdminCreateCustomer()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -183,16 +183,16 @@ const CreateCustomer = () => {
|
|||||||
{/* Render form */}
|
{/* Render form */}
|
||||||
</form>
|
</form>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateCustomer
|
export default CreateCustomer
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/customers`, {
|
fetch(`<BACKEND_URL>/admin/customers`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -204,29 +204,29 @@ fetch(`<BACKEND_URL>/admin/customers`, {
|
|||||||
first_name,
|
first_name,
|
||||||
last_name,
|
last_name,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ customer }) => {
|
.then(({ customer }) => {
|
||||||
console.log(customer.id)
|
console.log(customer.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/customers' \
|
curl -L -X POST '<BACKEND_URL>/admin/customers' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"email": "<EMAIL>",
|
"email": "<EMAIL>",
|
||||||
"first_name": "<FIRST_NAME>",
|
"first_name": "<FIRST_NAME>",
|
||||||
"last_name": "<LAST_NAME>",
|
"last_name": "<LAST_NAME>",
|
||||||
"password": "<PASSWORD>"
|
"password": "<PASSWORD>"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the following body parameters:
|
This request requires the following body parameters:
|
||||||
@@ -249,24 +249,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.customers.update(customerId, {
|
medusa.admin.customers.update(customerId, {
|
||||||
first_name,
|
first_name,
|
||||||
})
|
})
|
||||||
.then(({ customer }) => {
|
.then(({ customer }) => {
|
||||||
console.log(customer.id)
|
console.log(customer.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUpdateCustomer } from "medusa-react"
|
import { useAdminUpdateCustomer } from "medusa-react"
|
||||||
|
|
||||||
const UpdateCustomer = () => {
|
const UpdateCustomer = () => {
|
||||||
const updateCustomer = useAdminUpdateCustomer(customerId)
|
const updateCustomer = useAdminUpdateCustomer(customerId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -287,16 +287,16 @@ const UpdateCustomer = () => {
|
|||||||
{/* Render form */}
|
{/* Render form */}
|
||||||
</form>
|
</form>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdateCustomer
|
export default UpdateCustomer
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/customers/${customerId}`, {
|
fetch(`<BACKEND_URL>/admin/customers/${customerId}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -305,26 +305,26 @@ fetch(`<BACKEND_URL>/admin/customers/${customerId}`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
first_name,
|
first_name,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ customer }) => {
|
.then(({ customer }) => {
|
||||||
console.log(customer.id)
|
console.log(customer.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/customers/<CUSTOMER_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/customers/<CUSTOMER_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"first_name": "<FIRST_NAME>"
|
"first_name": "<FIRST_NAME>"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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).
|
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).
|
||||||
|
|||||||
+194
-194
@@ -61,27 +61,27 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.customers.create({
|
medusa.customers.create({
|
||||||
email,
|
email,
|
||||||
password,
|
password,
|
||||||
first_name,
|
first_name,
|
||||||
last_name,
|
last_name,
|
||||||
})
|
})
|
||||||
.then(({ customer }) => {
|
.then(({ customer }) => {
|
||||||
console.log(customer.id)
|
console.log(customer.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCreateCustomer } from "medusa-react"
|
import { useCreateCustomer } from "medusa-react"
|
||||||
|
|
||||||
const RegisterCustomer = () => {
|
const RegisterCustomer = () => {
|
||||||
const createCustomer = useCreateCustomer()
|
const createCustomer = useCreateCustomer()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -102,16 +102,16 @@ const RegisterCustomer = () => {
|
|||||||
{/* Render form */}
|
{/* Render form */}
|
||||||
</form>
|
</form>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default RegisterCustomer
|
export default RegisterCustomer
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/customers`, {
|
fetch(`<BACKEND_URL>/store/customers`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -123,14 +123,14 @@ fetch(`<BACKEND_URL>/store/customers`, {
|
|||||||
first_name,
|
first_name,
|
||||||
last_name,
|
last_name,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ customer }) => {
|
.then(({ customer }) => {
|
||||||
console.log(customer.id)
|
console.log(customer.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the following body parameters:
|
This request requires the following body parameters:
|
||||||
@@ -153,23 +153,23 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.auth.authenticate({
|
medusa.auth.authenticate({
|
||||||
email,
|
email,
|
||||||
password,
|
password,
|
||||||
})
|
})
|
||||||
.then(({ customer }) => {
|
.then(({ customer }) => {
|
||||||
console.log(customer.id)
|
console.log(customer.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/auth`, {
|
fetch(`<BACKEND_URL>/store/auth`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -179,14 +179,14 @@ fetch(`<BACKEND_URL>/store/auth`, {
|
|||||||
email,
|
email,
|
||||||
password,
|
password,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ customer }) => {
|
.then(({ customer }) => {
|
||||||
console.log(customer.id)
|
console.log(customer.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the body parameters `email` and `password`. It returns the customer object in the response.
|
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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.auth.deleteSession()
|
medusa.auth.deleteSession()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// success
|
// success
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/auth`, {
|
fetch(`<BACKEND_URL>/store/auth`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// success
|
// success
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
If this request is successful, the customer’s session will be deleted and they’ll be logged out.
|
If this request is successful, the customer’s session will be deleted and they’ll be logged out.
|
||||||
@@ -242,25 +242,25 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.customers.generatePasswordToken({
|
medusa.customers.generatePasswordToken({
|
||||||
email,
|
email,
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// successful
|
// successful
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
// failed
|
// failed
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/customers/password-token`, {
|
fetch(`<BACKEND_URL>/store/customers/password-token`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -269,16 +269,16 @@ fetch(`<BACKEND_URL>/store/customers/password-token`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
email,
|
email,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// successful
|
// successful
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
// failed
|
// failed
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the body parameter `email`. Its value must be the email associated with the customer’s account.
|
This request requires the body parameter `email`. Its value must be the email associated with the customer’s account.
|
||||||
@@ -298,24 +298,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.customers.resetPassword({
|
medusa.customers.resetPassword({
|
||||||
email,
|
email,
|
||||||
password,
|
password,
|
||||||
token,
|
token,
|
||||||
})
|
})
|
||||||
.then(({ customer }) => {
|
.then(({ customer }) => {
|
||||||
console.log(customer.id)
|
console.log(customer.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/customers/password-reset`, {
|
fetch(`<BACKEND_URL>/store/customers/password-reset`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -326,14 +326,14 @@ fetch(`<BACKEND_URL>/store/customers/password-reset`, {
|
|||||||
password,
|
password,
|
||||||
token,
|
token,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ customer }) => {
|
.then(({ customer }) => {
|
||||||
console.log(customer.id)
|
console.log(customer.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the following body parameters:
|
This request requires the following body parameters:
|
||||||
@@ -353,24 +353,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.customers.update({
|
medusa.customers.update({
|
||||||
first_name,
|
first_name,
|
||||||
})
|
})
|
||||||
.then(({ customer }) => {
|
.then(({ customer }) => {
|
||||||
console.log(customer.id)
|
console.log(customer.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useUpdateMe } from "medusa-react"
|
import { useUpdateMe } from "medusa-react"
|
||||||
|
|
||||||
const UpdateCustomer = () => {
|
const UpdateCustomer = () => {
|
||||||
const updateCustomer = useUpdateMe()
|
const updateCustomer = useUpdateMe()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -389,16 +389,16 @@ const UpdateCustomer = () => {
|
|||||||
{/* Render form */}
|
{/* Render form */}
|
||||||
</form>
|
</form>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdateCustomer
|
export default UpdateCustomer
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/customers/me`, {
|
fetch(`<BACKEND_URL>/store/customers/me`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -407,14 +407,14 @@ fetch(`<BACKEND_URL>/store/customers/me`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
first_name,
|
first_name,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ customer }) => {
|
.then(({ customer }) => {
|
||||||
console.log(customer.id)
|
console.log(customer.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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,10 +438,10 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.customers.addresses.addAddress({
|
medusa.customers.addresses.addAddress({
|
||||||
address: {
|
address: {
|
||||||
first_name,
|
first_name,
|
||||||
last_name,
|
last_name,
|
||||||
@@ -455,17 +455,17 @@ medusa.customers.addresses.addAddress({
|
|||||||
province,
|
province,
|
||||||
metadata,
|
metadata,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(({ customer }) => {
|
.then(({ customer }) => {
|
||||||
console.log(customer.id)
|
console.log(customer.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/customers/me/addresses`, {
|
fetch(`<BACKEND_URL>/store/customers/me/addresses`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -486,14 +486,14 @@ fetch(`<BACKEND_URL>/store/customers/me/addresses`, {
|
|||||||
metadata,
|
metadata,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ customer }) => {
|
.then(({ customer }) => {
|
||||||
console.log(customer.id)
|
console.log(customer.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires an `address` object as a body parameter. The `address` object must have the following properties:
|
This request requires an `address` object as a body parameter. The `address` object must have the following properties:
|
||||||
@@ -514,22 +514,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.customers.addresses.updateAddress(addressId, {
|
medusa.customers.addresses.updateAddress(addressId, {
|
||||||
first_name,
|
first_name,
|
||||||
})
|
})
|
||||||
.then(({ customer }) => {
|
.then(({ customer }) => {
|
||||||
console.log(customer.id)
|
console.log(customer.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/customers/me/addresses/${addressId}`,
|
fetch(`<BACKEND_URL>/store/customers/me/addresses/${addressId}`,
|
||||||
{
|
{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
@@ -540,14 +540,14 @@ fetch(`<BACKEND_URL>/store/customers/me/addresses/${addressId}`,
|
|||||||
first_name,
|
first_name,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ customer }) => {
|
.then(({ customer }) => {
|
||||||
console.log(customer.id)
|
console.log(customer.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.customers.addresses.deleteAddress(addressId)
|
medusa.customers.addresses.deleteAddress(addressId)
|
||||||
.then(({ customer }) => {
|
.then(({ customer }) => {
|
||||||
console.log(customer.id)
|
console.log(customer.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/customers/me/addresses/${addressId}`,
|
fetch(`<BACKEND_URL>/store/customers/me/addresses/${addressId}`,
|
||||||
{
|
{
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ customer }) => {
|
.then(({ customer }) => {
|
||||||
console.log(customer.id)
|
console.log(customer.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the address’s ID as a path parameter. It returns in the response the updated customer object.
|
This request requires the address’s ID as a path parameter. It returns in the response the updated customer object.
|
||||||
@@ -598,23 +598,23 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.customers.listOrders()
|
medusa.customers.listOrders()
|
||||||
.then(({ orders, limit, offset, count }) => {
|
.then(({ orders, limit, offset, count }) => {
|
||||||
console.log(orders)
|
console.log(orders)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCustomerOrders } from "medusa-react"
|
import { useCustomerOrders } from "medusa-react"
|
||||||
import { Order } from "@medusajs/medusa"
|
import { Order } from "@medusajs/medusa"
|
||||||
|
|
||||||
const Orders = () => {
|
const Orders = () => {
|
||||||
// refetch a function that can be used to
|
// refetch a function that can be used to
|
||||||
// re-retrieve orders after the customer logs in
|
// re-retrieve orders after the customer logs in
|
||||||
const { orders, isLoading, refetch } = useCustomerOrders()
|
const { orders, isLoading, refetch } = useCustomerOrders()
|
||||||
@@ -631,25 +631,25 @@ const Orders = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Orders
|
export default Orders
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/customers/me/orders`, {
|
fetch(`<BACKEND_URL>/store/customers/me/orders`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ orders, limit, offset, count }) => {
|
.then(({ orders, limit, offset, count }) => {
|
||||||
console.log(orders)
|
console.log(orders)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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).
|
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).
|
||||||
|
|||||||
@@ -67,15 +67,15 @@ You can learn more about [authenticating as an admin user in the API reference](
|
|||||||
You can create a discount by sending a request to the [Create Discount API Route](https://docs.medusajs.com/api/admin#discounts_postdiscounts):
|
You can create a discount by sending a request to the [Create Discount API Route](https://docs.medusajs.com/api/admin#discounts_postdiscounts):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import {
|
import {
|
||||||
AllocationType,
|
AllocationType,
|
||||||
DiscountRuleType,
|
DiscountRuleType,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
// ...
|
// ...
|
||||||
medusa.admin.discounts.create({
|
medusa.admin.discounts.create({
|
||||||
code,
|
code,
|
||||||
rule: {
|
rule: {
|
||||||
type: DiscountRuleType.FIXED,
|
type: DiscountRuleType.FIXED,
|
||||||
@@ -87,25 +87,25 @@ medusa.admin.discounts.create({
|
|||||||
],
|
],
|
||||||
is_dynamic: false,
|
is_dynamic: false,
|
||||||
is_disabled: false,
|
is_disabled: false,
|
||||||
})
|
})
|
||||||
.then(({ discount }) => {
|
.then(({ discount }) => {
|
||||||
console.log(discount.id)
|
console.log(discount.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import {
|
import {
|
||||||
useAdminCreateDiscount,
|
useAdminCreateDiscount,
|
||||||
} from "medusa-react"
|
} from "medusa-react"
|
||||||
import {
|
import {
|
||||||
AllocationType,
|
AllocationType,
|
||||||
DiscountRuleType,
|
DiscountRuleType,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
|
|
||||||
const CreateDiscount = () => {
|
const CreateDiscount = () => {
|
||||||
const createDiscount = useAdminCreateDiscount()
|
const createDiscount = useAdminCreateDiscount()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -127,16 +127,16 @@ const CreateDiscount = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateDiscount
|
export default CreateDiscount
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/discounts`, {
|
fetch(`<BACKEND_URL>/admin/discounts`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -155,21 +155,21 @@ fetch(`<BACKEND_URL>/admin/discounts`, {
|
|||||||
is_dynamic: false,
|
is_dynamic: false,
|
||||||
is_disabled: false,
|
is_disabled: false,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ discount }) => {
|
.then(({ discount }) => {
|
||||||
console.log(discount.id)
|
console.log(discount.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/discounts' \
|
curl -L -X POST '<BACKEND_URL>/admin/discounts' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"code": "<CODE>",
|
"code": "<CODE>",
|
||||||
"rule": {
|
"rule": {
|
||||||
"type": "fixed",
|
"type": "fixed",
|
||||||
@@ -181,10 +181,10 @@ curl -L -X POST '<BACKEND_URL>/admin/discounts' \
|
|||||||
],
|
],
|
||||||
"is_dynamic": false,
|
"is_dynamic": false,
|
||||||
"is_disabled": false
|
"is_disabled": false
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request accepts [many request-body parameters](https://docs.medusajs.com/api/admin#discounts_postdiscounts) including:
|
This request accepts [many request-body parameters](https://docs.medusajs.com/api/admin#discounts_postdiscounts) including:
|
||||||
@@ -207,24 +207,24 @@ You can update any of the discount’s information, configurations, and conditio
|
|||||||
For example, you can update the discount’s description and status by sending the following request:
|
For example, you can update the discount’s description and status by sending the following request:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.discounts.update(discountId, {
|
medusa.admin.discounts.update(discountId, {
|
||||||
is_disabled: true,
|
is_disabled: true,
|
||||||
})
|
})
|
||||||
.then(({ discount }) => {
|
.then(({ discount }) => {
|
||||||
console.log(discount.id)
|
console.log(discount.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUpdateDiscount } from "medusa-react"
|
import { useAdminUpdateDiscount } from "medusa-react"
|
||||||
|
|
||||||
const UpdateDiscount = () => {
|
const UpdateDiscount = () => {
|
||||||
const updateDiscount = useAdminUpdateDiscount(discount_id)
|
const updateDiscount = useAdminUpdateDiscount(discount_id)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -236,16 +236,16 @@ const UpdateDiscount = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdateDiscount
|
export default UpdateDiscount
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/discounts/${discountId}`, {
|
fetch(`<BACKEND_URL>/admin/discounts/${discountId}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -254,26 +254,26 @@ fetch(`<BACKEND_URL>/admin/discounts/${discountId}`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
is_disabled: true,
|
is_disabled: true,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ discount }) => {
|
.then(({ discount }) => {
|
||||||
console.log(discount.id)
|
console.log(discount.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/discounts/<DISCOUNT_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/discounts/<DISCOUNT_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"is_disabled": true
|
"is_disabled": true
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request accepts the discount ID as a path parameter. You can pass the parameters you want to update in the request body. In the example above, is_disabled` parameter to update it.
|
This request accepts the discount ID as a path parameter. You can pass the parameters you want to update in the request body. In the example above, is_disabled` parameter to update it.
|
||||||
@@ -297,30 +297,30 @@ You can learn more about conditions and conditions types in the [Discount Archit
|
|||||||
You can send a request to the [Create Condition API Route](https://docs.medusajs.com/api/admin#discounts_postdiscountsdiscountconditions) to create a condition in a discount:
|
You can send a request to the [Create Condition API Route](https://docs.medusajs.com/api/admin#discounts_postdiscountsdiscountconditions) to create a condition in a discount:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { DiscountConditionOperator } from "@medusajs/medusa"
|
import { DiscountConditionOperator } from "@medusajs/medusa"
|
||||||
// ...
|
// ...
|
||||||
medusa.admin.discounts.createCondition(discount_id, {
|
medusa.admin.discounts.createCondition(discount_id, {
|
||||||
operator: DiscountConditionOperator.IN,
|
operator: DiscountConditionOperator.IN,
|
||||||
products: [
|
products: [
|
||||||
productId,
|
productId,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.then(({ discount }) => {
|
.then(({ discount }) => {
|
||||||
console.log(discount.id)
|
console.log(discount.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDiscountCreateCondition } from "medusa-react"
|
import { useAdminDiscountCreateCondition } from "medusa-react"
|
||||||
import { DiscountConditionOperator } from "@medusajs/medusa"
|
import { DiscountConditionOperator } from "@medusajs/medusa"
|
||||||
|
|
||||||
const Discount = () => {
|
const Discount = () => {
|
||||||
const createCondition = useAdminDiscountCreateCondition(
|
const createCondition = useAdminDiscountCreateCondition(
|
||||||
discount_id
|
discount_id
|
||||||
)
|
)
|
||||||
@@ -340,16 +340,16 @@ const Discount = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Discount
|
export default Discount
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/discounts/${discountId}/conditions`,
|
fetch(`<BACKEND_URL>/admin/discounts/${discountId}/conditions`,
|
||||||
{
|
{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
@@ -363,29 +363,29 @@ fetch(`<BACKEND_URL>/admin/discounts/${discountId}/conditions`,
|
|||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ discount }) => {
|
.then(({ discount }) => {
|
||||||
console.log(discount.id)
|
console.log(discount.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/discounts/<DISCOUNT_ID>/conditions' \
|
curl -L -X POST '<BACKEND_URL>/admin/discounts/<DISCOUNT_ID>/conditions' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"operator": "in",
|
"operator": "in",
|
||||||
"products": [
|
"products": [
|
||||||
"<PRODUCT_ID>"
|
"<PRODUCT_ID>"
|
||||||
]
|
]
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request accepts the discount ID as a path parameter.
|
This request accepts the discount ID as a path parameter.
|
||||||
@@ -410,32 +410,32 @@ This request returns the full `discount` object in the response which includes a
|
|||||||
You can retrieve a condition and its resources by sending a request to the [Get Condition API Route](https://docs.medusajs.com/api/admin#discounts_getdiscountsdiscountconditionscondition):
|
You can retrieve a condition and its resources by sending a request to the [Get Condition API Route](https://docs.medusajs.com/api/admin#discounts_getdiscountsdiscountconditionscondition):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.discounts.getCondition(
|
medusa.admin.discounts.getCondition(
|
||||||
discountId,
|
discountId,
|
||||||
conditionId,
|
conditionId,
|
||||||
{
|
{
|
||||||
expand: "products",
|
expand: "products",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(({ discount_condition }) => {
|
.then(({ discount_condition }) => {
|
||||||
console.log(
|
console.log(
|
||||||
discount_condition.id,
|
discount_condition.id,
|
||||||
discount_condition.products
|
discount_condition.products
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminGetDiscountCondition } from "medusa-react"
|
import { useAdminGetDiscountCondition } from "medusa-react"
|
||||||
import { Product } from "@medusajs/medusa"
|
import { Product } from "@medusajs/medusa"
|
||||||
|
|
||||||
const DiscountCondition = () => {
|
const DiscountCondition = () => {
|
||||||
const {
|
const {
|
||||||
discount_condition,
|
discount_condition,
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -462,40 +462,40 @@ const DiscountCondition = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DiscountCondition
|
export default DiscountCondition
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/admin/discounts/${discountId}` +
|
`<BACKEND_URL>/admin/discounts/${discountId}` +
|
||||||
`/conditions/${conditionId}&expand=products`,
|
`/conditions/${conditionId}&expand=products`,
|
||||||
{
|
{
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ discount_condition }) => {
|
.then(({ discount_condition }) => {
|
||||||
console.log(
|
console.log(
|
||||||
discount_condition.id,
|
discount_condition.id,
|
||||||
discount_condition.products
|
discount_condition.products
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/discounts/<DISCOUNT_ID>/conditions/<CONDITION_ID>&expand=products' \
|
curl -L -X GET '<BACKEND_URL>/admin/discounts/<DISCOUNT_ID>/conditions/<CONDITION_ID>&expand=products' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request accepts as path parameters the discount ID and the condition ID. You can optionally pass a query parameter `expand` which specifies which relations to include in the returned object.
|
This request accepts as path parameters the discount ID and the condition ID. You can optionally pass a query parameter `expand` which specifies which relations to include in the returned object.
|
||||||
@@ -511,10 +511,10 @@ You can update a condition’s resources using the [Update Condition API Route](
|
|||||||
For example, to update the products in a condition:
|
For example, to update the products in a condition:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.discounts.updateCondition(
|
medusa.admin.discounts.updateCondition(
|
||||||
discountId,
|
discountId,
|
||||||
conditionId, {
|
conditionId, {
|
||||||
products: [
|
products: [
|
||||||
@@ -522,20 +522,20 @@ medusa.admin.discounts.updateCondition(
|
|||||||
productId2,
|
productId2,
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(({ discount }) => {
|
.then(({ discount }) => {
|
||||||
console.log(discount.id)
|
console.log(discount.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDiscountUpdateCondition } from "medusa-react"
|
import { useAdminDiscountUpdateCondition } from "medusa-react"
|
||||||
import { Product } from "@medusajs/medusa"
|
import { Product } from "@medusajs/medusa"
|
||||||
|
|
||||||
const DiscountCondition = () => {
|
const DiscountCondition = () => {
|
||||||
const updateCondition = useAdminDiscountUpdateCondition(
|
const updateCondition = useAdminDiscountUpdateCondition(
|
||||||
discount_id,
|
discount_id,
|
||||||
conditionId
|
conditionId
|
||||||
@@ -549,18 +549,18 @@ const DiscountCondition = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DiscountCondition
|
export default DiscountCondition
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/admin/discounts/${discountId}/conditions/${conditionId}`,
|
`<BACKEND_URL>/admin/discounts/${discountId}/conditions/${conditionId}`,
|
||||||
{
|
{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -575,29 +575,29 @@ fetch(
|
|||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ discount }) => {
|
.then(({ discount }) => {
|
||||||
console.log(discount.id)
|
console.log(discount.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/discounts/<DISCOUNT_ID>/conditions/<CONDITION_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/discounts/<DISCOUNT_ID>/conditions/<CONDITION_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"products": [
|
"products": [
|
||||||
"<PRODUCT_ID_1>",
|
"<PRODUCT_ID_1>",
|
||||||
"<PRODUCT_ID_2>"
|
"<PRODUCT_ID_2>"
|
||||||
]
|
]
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request accepts as a path parameter the discount ID and the condition ID. In its body, it accepts the resources of the same type that were used when the condition was created.
|
This request accepts as a path parameter the discount ID and the condition ID. In its body, it accepts the resources of the same type that were used when the condition was created.
|
||||||
@@ -611,25 +611,25 @@ This request returns the full `discount` object with the updated condition in th
|
|||||||
You can delete a condition by sending a request to the [Delete Condition API Route](https://docs.medusajs.com/api/admin#discounts_deletediscountsdiscountconditionscondition):
|
You can delete a condition by sending a request to the [Delete Condition API Route](https://docs.medusajs.com/api/admin#discounts_deletediscountsdiscountconditionscondition):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.discounts.deleteCondition(
|
medusa.admin.discounts.deleteCondition(
|
||||||
discountId,
|
discountId,
|
||||||
conditionId
|
conditionId
|
||||||
)
|
)
|
||||||
.then(({ discount }) => {
|
.then(({ discount }) => {
|
||||||
console.log(discount)
|
console.log(discount)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDiscountRemoveCondition } from "medusa-react"
|
import { useAdminDiscountRemoveCondition } from "medusa-react"
|
||||||
|
|
||||||
const Discount = () => {
|
const Discount = () => {
|
||||||
const deleteCondition = useAdminDiscountRemoveCondition(
|
const deleteCondition = useAdminDiscountRemoveCondition(
|
||||||
discount_id
|
discount_id
|
||||||
)
|
)
|
||||||
@@ -640,39 +640,39 @@ const Discount = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Discount
|
export default Discount
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/admin/discounts/${discountId}/conditions/${conditionId}`,
|
`<BACKEND_URL>/admin/discounts/${discountId}/conditions/${conditionId}`,
|
||||||
{
|
{
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ discount }) => {
|
.then(({ discount }) => {
|
||||||
console.log(discount.id)
|
console.log(discount.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/discounts/<DISCOUNT_ID>/conditions/<CONDITION_ID>' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/discounts/<DISCOUNT_ID>/conditions/<CONDITION_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request accepts as a path parameter the discount ID and the condition ID.
|
This request accepts as a path parameter the discount ID and the condition ID.
|
||||||
@@ -686,22 +686,22 @@ It returns the `discount` object in the response.
|
|||||||
You can delete a discount by sending a request to the [Delete Discount API Route](https://docs.medusajs.com/api/admin#discounts_deletediscountsdiscount):
|
You can delete a discount by sending a request to the [Delete Discount API Route](https://docs.medusajs.com/api/admin#discounts_deletediscountsdiscount):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.discounts.delete(discount_id)
|
medusa.admin.discounts.delete(discount_id)
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDeleteDiscount } from "medusa-react"
|
import { useAdminDeleteDiscount } from "medusa-react"
|
||||||
|
|
||||||
const Discount = () => {
|
const Discount = () => {
|
||||||
const deleteDiscount = useAdminDeleteDiscount(discount_id)
|
const deleteDiscount = useAdminDeleteDiscount(discount_id)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -710,34 +710,34 @@ const Discount = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Discount
|
export default Discount
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/discounts/${discountId}`, {
|
fetch(`<BACKEND_URL>/admin/discounts/${discountId}`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/discounts/<DISCOUNT_ID>' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/discounts/<DISCOUNT_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request accepts the discount ID as a path parameter.
|
This request accepts the discount ID as a path parameter.
|
||||||
|
|||||||
@@ -65,32 +65,32 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.carts.update(cartId, {
|
medusa.carts.update(cartId, {
|
||||||
discounts: [
|
discounts: [
|
||||||
{
|
{
|
||||||
code,
|
code,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
console.log(cart.discounts)
|
console.log(cart.discounts)
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
// display an error to the customer
|
// display an error to the customer
|
||||||
alert("Discount is invalid")
|
alert("Discount is invalid")
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCart } from "medusa-react"
|
import { useCart } from "medusa-react"
|
||||||
|
|
||||||
const Cart = () => {
|
const Cart = () => {
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
const { updateCart } = useCart()
|
const { updateCart } = useCart()
|
||||||
@@ -106,16 +106,16 @@ const Cart = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Cart
|
export default Cart
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/carts/${cartId}`, {
|
fetch(`<BACKEND_URL>/store/carts/${cartId}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@@ -128,18 +128,18 @@ fetch(`<BACKEND_URL>/store/carts/${cartId}`, {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
console.log(cart.discounts)
|
console.log(cart.discounts)
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
// display an error to the customer
|
// display an error to the customer
|
||||||
alert("Discount is invalid")
|
alert("Discount is invalid")
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.carts.deleteDiscount(cartId, code)
|
medusa.carts.deleteDiscount(cartId, code)
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
console.log(cart.discounts)
|
console.log(cart.discounts)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/carts/${cartId}/discounts/${code}`, {
|
fetch(`<BACKEND_URL>/store/carts/${cartId}/discounts/${code}`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
console.log(cart.discounts)
|
console.log(cart.discounts)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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.
|
||||||
|
|||||||
@@ -66,32 +66,32 @@ As gift cards are, before purchase, essentially products, you’ll be using prod
|
|||||||
You can retrieve the gift card products by sending a request to the [List Products API Route](https://docs.medusajs.com/api/admin#products_getproducts), but filtering the products with the `is_giftcard` flag:
|
You can retrieve the gift card products by sending a request to the [List Products API Route](https://docs.medusajs.com/api/admin#products_getproducts), but filtering the products with the `is_giftcard` flag:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.products.list({
|
medusa.admin.products.list({
|
||||||
is_giftcard: true,
|
is_giftcard: true,
|
||||||
})
|
})
|
||||||
.then(({ products, limit, offset, count }) => {
|
.then(({ products, limit, offset, count }) => {
|
||||||
if (products.length) {
|
if (products.length) {
|
||||||
// gift card products exist
|
// gift card products exist
|
||||||
} else {
|
} else {
|
||||||
// no gift card products are created
|
// no gift card products are created
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { Product } from "@medusajs/medusa"
|
import { Product } from "@medusajs/medusa"
|
||||||
import {
|
import {
|
||||||
PricedProduct,
|
PricedProduct,
|
||||||
} from "@medusajs/medusa/dist/types/pricing"
|
} from "@medusajs/medusa/dist/types/pricing"
|
||||||
import { useAdminProducts } from "medusa-react"
|
import { useAdminProducts } from "medusa-react"
|
||||||
|
|
||||||
const GiftCard = () => {
|
const GiftCard = () => {
|
||||||
const { products, isLoading } = useAdminProducts({
|
const { products, isLoading } = useAdminProducts({
|
||||||
is_giftcard: true,
|
is_giftcard: true,
|
||||||
})
|
})
|
||||||
@@ -113,37 +113,37 @@ const GiftCard = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default GiftCard
|
export default GiftCard
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/products?is_giftcard=true`, {
|
fetch(`<BACKEND_URL>/admin/products?is_giftcard=true`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ products, limit, offset, count }) => {
|
.then(({ products, limit, offset, count }) => {
|
||||||
if (products.length) {
|
if (products.length) {
|
||||||
// gift card products exist
|
// gift card products exist
|
||||||
} else {
|
} else {
|
||||||
// no gift card products are created
|
// no gift card products are created
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/products?is_giftcard=true' \
|
curl -L -X GET '<BACKEND_URL>/admin/products?is_giftcard=true' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
The List Products API Route accepts a variety of query parameters that can be used to filter the products. One of them is `is_giftcard`. When set to `true`, it will only retrieve the gift card products.
|
The List Products API Route accepts a variety of query parameters that can be used to filter the products. One of them is `is_giftcard`. When set to `true`, it will only retrieve the gift card products.
|
||||||
@@ -155,13 +155,13 @@ The request returns the `products` array in the response which holds the gift ca
|
|||||||
You can create a gift card product by sending a request to the [Create a Product API Route](https://docs.medusajs.com/api/admin#products_postproducts):
|
You can create a gift card product by sending a request to the [Create a Product API Route](https://docs.medusajs.com/api/admin#products_postproducts):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { ProductStatus } from "@medusajs/medusa"
|
import { ProductStatus } from "@medusajs/medusa"
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
medusa.admin.products.create({
|
medusa.admin.products.create({
|
||||||
title: "My Gift Card",
|
title: "My Gift Card",
|
||||||
is_giftcard: true,
|
is_giftcard: true,
|
||||||
discountable: false,
|
discountable: false,
|
||||||
@@ -189,20 +189,20 @@ medusa.admin.products.create({
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.then(({ product }) => {
|
.then(({ product }) => {
|
||||||
console.log(product.id)
|
console.log(product.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateProduct } from "medusa-react"
|
import { useAdminCreateProduct } from "medusa-react"
|
||||||
import { ProductStatus } from "@medusajs/medusa"
|
import { ProductStatus } from "@medusajs/medusa"
|
||||||
|
|
||||||
const CreateGiftCard = () => {
|
const CreateGiftCard = () => {
|
||||||
const createGiftCard = useAdminCreateProduct()
|
const createGiftCard = useAdminCreateProduct()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -239,16 +239,16 @@ const CreateGiftCard = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateGiftCard
|
export default CreateGiftCard
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/products`, {
|
fetch(`<BACKEND_URL>/admin/products`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -283,21 +283,21 @@ fetch(`<BACKEND_URL>/admin/products`, {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ product }) => {
|
.then(({ product }) => {
|
||||||
console.log(product.id)
|
console.log(product.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/products' \
|
curl -L -X POST '<BACKEND_URL>/admin/products' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"title": "My Gift Card",
|
"title": "My Gift Card",
|
||||||
"is_giftcard": true,
|
"is_giftcard": true,
|
||||||
"discountable": false,
|
"discountable": false,
|
||||||
@@ -325,10 +325,10 @@ curl -L -X POST '<BACKEND_URL>/admin/products' \
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the `title` body parameter, which is the name given to the gift card. To add the gift card product, you need to supply the following parameters:
|
This request requires the `title` body parameter, which is the name given to the gift card. To add the gift card product, you need to supply the following parameters:
|
||||||
@@ -356,24 +356,24 @@ After creating a gift card, merchants can update it or its denomination.
|
|||||||
You can update a gift card product’s details by sending a request to the [Update a Product API Route](https://docs.medusajs.com/api/admin#products_postproductsproduct):
|
You can update a gift card product’s details by sending a request to the [Update a Product API Route](https://docs.medusajs.com/api/admin#products_postproductsproduct):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.products.update(giftCardId, {
|
medusa.admin.products.update(giftCardId, {
|
||||||
description: "The best gift card",
|
description: "The best gift card",
|
||||||
})
|
})
|
||||||
.then(({ product }) => {
|
.then(({ product }) => {
|
||||||
console.log(product.id)
|
console.log(product.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUpdateProduct } from "medusa-react"
|
import { useAdminUpdateProduct } from "medusa-react"
|
||||||
|
|
||||||
const UpdateGiftCard = () => {
|
const UpdateGiftCard = () => {
|
||||||
const createGiftCard = useAdminUpdateProduct(giftCardId)
|
const createGiftCard = useAdminUpdateProduct(giftCardId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -384,16 +384,16 @@ const UpdateGiftCard = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdateGiftCard
|
export default UpdateGiftCard
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/products/${giftCardId}`, {
|
fetch(`<BACKEND_URL>/admin/products/${giftCardId}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -402,26 +402,26 @@ fetch(`<BACKEND_URL>/admin/products/${giftCardId}`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
description: "The best gift card",
|
description: "The best gift card",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ product }) => {
|
.then(({ product }) => {
|
||||||
console.log(product.id)
|
console.log(product.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/products/<GIFT_CARD_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/products/<GIFT_CARD_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"description": "The best gift card"
|
"description": "The best gift card"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the ID of the gift card product as a path parameter. You can pass in its body parameters, any of the gift card’s properties to update.
|
This request requires the ID of the gift card product as a path parameter. You can pass in its body parameters, any of the gift card’s properties to update.
|
||||||
@@ -435,22 +435,22 @@ This request returns the updated gift card product in the response.
|
|||||||
You can delete a gift card product by sending a request to the [Delete a Product API Route](https://docs.medusajs.com/api/admin#products_deleteproductsproduct):
|
You can delete a gift card product by sending a request to the [Delete a Product API Route](https://docs.medusajs.com/api/admin#products_deleteproductsproduct):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.products.delete(giftCardId)
|
medusa.admin.products.delete(giftCardId)
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDeleteProduct } from "medusa-react"
|
import { useAdminDeleteProduct } from "medusa-react"
|
||||||
|
|
||||||
const GiftCard = () => {
|
const GiftCard = () => {
|
||||||
const deleteGiftCard = useAdminDeleteProduct(giftCardId)
|
const deleteGiftCard = useAdminDeleteProduct(giftCardId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -459,34 +459,34 @@ const GiftCard = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default GiftCard
|
export default GiftCard
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/products/${giftCardId}`, {
|
fetch(`<BACKEND_URL>/admin/products/${giftCardId}`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/products/<GIFT_CARD_ID>' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/products/<GIFT_CARD_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the ID of the gift card product as a path parameter.
|
This request requires the ID of the gift card product as a path parameter.
|
||||||
@@ -508,23 +508,23 @@ This section covers how to manage custom gift cards. You can create an unlimited
|
|||||||
You can retrieve all custom gift cards by sending a request to the [List Gift Cards API Route](https://docs.medusajs.com/api/admin#gift-cards_getgiftcards):
|
You can retrieve all custom gift cards by sending a request to the [List Gift Cards API Route](https://docs.medusajs.com/api/admin#gift-cards_getgiftcards):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.giftCards.list()
|
medusa.admin.giftCards.list()
|
||||||
.then(({ gift_cards, limit, offset, count }) => {
|
.then(({ gift_cards, limit, offset, count }) => {
|
||||||
console.log(gift_cards.length)
|
console.log(gift_cards.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { GiftCard } from "@medusajs/medusa"
|
import { GiftCard } from "@medusajs/medusa"
|
||||||
import { useAdminGiftCards } from "medusa-react"
|
import { useAdminGiftCards } from "medusa-react"
|
||||||
|
|
||||||
const CustomGiftCards = () => {
|
const CustomGiftCards = () => {
|
||||||
const { gift_cards, isLoading } = useAdminGiftCards()
|
const { gift_cards, isLoading } = useAdminGiftCards()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -542,33 +542,33 @@ const CustomGiftCards = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CustomGiftCards
|
export default CustomGiftCards
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/gift-cards`, {
|
fetch(`<BACKEND_URL>/admin/gift-cards`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ gift_cards, limit, offset, count }) => {
|
.then(({ gift_cards, limit, offset, count }) => {
|
||||||
console.log(gift_cards.length)
|
console.log(gift_cards.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/gift-cards' \
|
curl -L -X GET '<BACKEND_URL>/admin/gift-cards' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request doesn't require any parameters. It accepts parameters related to pagination, which you can check out in the [API reference](https://docs.medusajs.com/api/admin#gift-cards_getgiftcards).
|
This request doesn't require any parameters. It accepts parameters related to pagination, which you can check out in the [API reference](https://docs.medusajs.com/api/admin#gift-cards_getgiftcards).
|
||||||
@@ -582,25 +582,25 @@ Merchants can create custom gift cards to send a reward or gift to the customer.
|
|||||||
You can create a custom gift card by sending a request to the [Create a Gift Card API Route](https://docs.medusajs.com/api/admin#gift-cards_postgiftcards):
|
You can create a custom gift card by sending a request to the [Create a Gift Card API Route](https://docs.medusajs.com/api/admin#gift-cards_postgiftcards):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.giftCards.create({
|
medusa.admin.giftCards.create({
|
||||||
region_id,
|
region_id,
|
||||||
value,
|
value,
|
||||||
})
|
})
|
||||||
.then(({ gift_card }) => {
|
.then(({ gift_card }) => {
|
||||||
console.log(gift_card.id)
|
console.log(gift_card.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateGiftCard } from "medusa-react"
|
import { useAdminCreateGiftCard } from "medusa-react"
|
||||||
|
|
||||||
const CreateCustomGiftCards = () => {
|
const CreateCustomGiftCards = () => {
|
||||||
const createGiftCard = useAdminCreateGiftCard()
|
const createGiftCard = useAdminCreateGiftCard()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -612,16 +612,16 @@ const CreateCustomGiftCards = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateCustomGiftCards
|
export default CreateCustomGiftCards
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/gift-cards`, {
|
fetch(`<BACKEND_URL>/admin/gift-cards`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -631,27 +631,27 @@ fetch(`<BACKEND_URL>/admin/gift-cards`, {
|
|||||||
region_id,
|
region_id,
|
||||||
value,
|
value,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ gift_card }) => {
|
.then(({ gift_card }) => {
|
||||||
console.log(gift_card.id)
|
console.log(gift_card.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/gift-cards' \
|
curl -L -X POST '<BACKEND_URL>/admin/gift-cards' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"region_id": "<REGION_ID>",
|
"region_id": "<REGION_ID>",
|
||||||
"value": 2000
|
"value": 2000
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the `region_id` body parameter. Its value should be the ID of the region that this gift card can be used in.
|
This request requires the `region_id` body parameter. Its value should be the ID of the region that this gift card can be used in.
|
||||||
@@ -667,24 +667,24 @@ Merchants can update any of the gift card’s properties, except for the value o
|
|||||||
You can update a gift card by sending a request to the [Update a Gift Card API Route](https://docs.medusajs.com/api/admin#gift-cards_postgiftcardsgiftcard):
|
You can update a gift card by sending a request to the [Update a Gift Card API Route](https://docs.medusajs.com/api/admin#gift-cards_postgiftcardsgiftcard):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.giftCards.update(giftCardId, {
|
medusa.admin.giftCards.update(giftCardId, {
|
||||||
balance,
|
balance,
|
||||||
})
|
})
|
||||||
.then(({ gift_card }) => {
|
.then(({ gift_card }) => {
|
||||||
console.log(gift_card.id)
|
console.log(gift_card.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUpdateGiftCard } from "medusa-react"
|
import { useAdminUpdateGiftCard } from "medusa-react"
|
||||||
|
|
||||||
const UpdateCustomGiftCards = () => {
|
const UpdateCustomGiftCards = () => {
|
||||||
const updateGiftCard = useAdminUpdateGiftCard(
|
const updateGiftCard = useAdminUpdateGiftCard(
|
||||||
customGiftCardId
|
customGiftCardId
|
||||||
)
|
)
|
||||||
@@ -697,16 +697,16 @@ const UpdateCustomGiftCards = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdateCustomGiftCards
|
export default UpdateCustomGiftCards
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/gift-cards/${giftCardId}`, {
|
fetch(`<BACKEND_URL>/admin/gift-cards/${giftCardId}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -715,26 +715,26 @@ fetch(`<BACKEND_URL>/admin/gift-cards/${giftCardId}`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
balance,
|
balance,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ gift_card }) => {
|
.then(({ gift_card }) => {
|
||||||
console.log(gift_card.id)
|
console.log(gift_card.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/gift-cards/<GIFT_CARD_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/gift-cards/<GIFT_CARD_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"balance": 2000
|
"balance": 2000
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the ID of the gift card as a path parameter. It accepts in its body parameters the gift card’s properties that you want to update.
|
This request requires the ID of the gift card as a path parameter. It accepts in its body parameters the gift card’s properties that you want to update.
|
||||||
@@ -748,22 +748,22 @@ This request returns the updated gift card object in the response.
|
|||||||
You can delete a custom gift card by sending a request to the [Delete a Gift Card API Route](https://docs.medusajs.com/api/admin#gift-cards_deletegiftcardsgiftcard):
|
You can delete a custom gift card by sending a request to the [Delete a Gift Card API Route](https://docs.medusajs.com/api/admin#gift-cards_deletegiftcardsgiftcard):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.giftCards.delete(giftCardId)
|
medusa.admin.giftCards.delete(giftCardId)
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDeleteGiftCard } from "medusa-react"
|
import { useAdminDeleteGiftCard } from "medusa-react"
|
||||||
|
|
||||||
const CustomGiftCard = () => {
|
const CustomGiftCard = () => {
|
||||||
const deleteGiftCard = useAdminDeleteGiftCard(
|
const deleteGiftCard = useAdminDeleteGiftCard(
|
||||||
customGiftCardId
|
customGiftCardId
|
||||||
)
|
)
|
||||||
@@ -774,34 +774,34 @@ const CustomGiftCard = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CustomGiftCard
|
export default CustomGiftCard
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/gift-cards/${giftCardId}`, {
|
fetch(`<BACKEND_URL>/admin/gift-cards/${giftCardId}`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/gift-card/<GIFT_CARD_ID>' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/gift-card/<GIFT_CARD_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the ID of the gift card as a path parameter.
|
This request requires the ID of the gift card as a path parameter.
|
||||||
|
|||||||
@@ -61,30 +61,30 @@ 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:
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.products.list({
|
medusa.products.list({
|
||||||
is_giftcard: true,
|
is_giftcard: true,
|
||||||
})
|
})
|
||||||
.then(({ products, limit, offset, count }) => {
|
.then(({ products, limit, offset, count }) => {
|
||||||
if (products.length) {
|
if (products.length) {
|
||||||
// gift card products exist
|
// gift card products exist
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// no gift card products are created
|
// no gift card products are created
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { Product } from "@medusajs/medusa"
|
import { Product } from "@medusajs/medusa"
|
||||||
import { useProducts } from "medusa-react"
|
import { useProducts } from "medusa-react"
|
||||||
|
|
||||||
const GiftCards = () => {
|
const GiftCards = () => {
|
||||||
const { products, isLoading } = useProducts({
|
const { products, isLoading } = useProducts({
|
||||||
is_giftcard: true,
|
is_giftcard: true,
|
||||||
})
|
})
|
||||||
@@ -104,29 +104,29 @@ const GiftCards = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default GiftCards
|
export default GiftCards
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/products?is_giftcard=true`, {
|
fetch(`<BACKEND_URL>/store/products?is_giftcard=true`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ products, limit, offset, count }) => {
|
.then(({ products, limit, offset, count }) => {
|
||||||
if (products.length) {
|
if (products.length) {
|
||||||
// gift card products exist
|
// gift card products exist
|
||||||
} else {
|
} else {
|
||||||
// no gift card products are created
|
// no gift card products are created
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
The request does not require any parameters. You can pass query parameters to filter the returned products.
|
The request does not require any parameters. You can pass query parameters to filter the returned products.
|
||||||
@@ -150,25 +150,25 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.giftCards.retrieve(code)
|
medusa.giftCards.retrieve(code)
|
||||||
.then(({ gift_card }) => {
|
.then(({ gift_card }) => {
|
||||||
console.log(gift_card.id)
|
console.log(gift_card.id)
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
// gift card doesn't exist or is disabled
|
// gift card doesn't exist or is disabled
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useGiftCard } from "medusa-react"
|
import { useGiftCard } from "medusa-react"
|
||||||
|
|
||||||
const GiftCard = () => {
|
const GiftCard = () => {
|
||||||
const { gift_card, isLoading, isError } = useGiftCard("code")
|
const { gift_card, isLoading, isError } = useGiftCard("code")
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -178,28 +178,28 @@ const GiftCard = () => {
|
|||||||
{isError && <span>Gift Card does not exist</span>}
|
{isError && <span>Gift Card does not exist</span>}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default GiftCard
|
export default GiftCard
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/gift-cards/${code}`, {
|
fetch(`<BACKEND_URL>/store/gift-cards/${code}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ gift_card }) => {
|
.then(({ gift_card }) => {
|
||||||
console.log(gift_card.id)
|
console.log(gift_card.id)
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
// gift card doesn't exist or is disabled
|
// gift card doesn't exist or is disabled
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the code of the gift card passed as a path parameter.
|
This request requires the code of the gift card passed as a path parameter.
|
||||||
@@ -225,31 +225,31 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.carts.update(cartId, {
|
medusa.carts.update(cartId, {
|
||||||
gift_cards: [
|
gift_cards: [
|
||||||
{
|
{
|
||||||
code,
|
code,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
console.log(cart.gift_cards.length)
|
console.log(cart.gift_cards.length)
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
// gift card doesn't exist or is disabled
|
// gift card doesn't exist or is disabled
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCart } from "medusa-react"
|
import { useCart } from "medusa-react"
|
||||||
|
|
||||||
const Cart = () => {
|
const Cart = () => {
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
const { updateCart } = useCart()
|
const { updateCart } = useCart()
|
||||||
@@ -265,16 +265,16 @@ const Cart = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Cart
|
export default Cart
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/cart/${cartId}`, {
|
fetch(`<BACKEND_URL>/store/cart/${cartId}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -287,17 +287,17 @@ fetch(`<BACKEND_URL>/store/cart/${cartId}`, {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
console.log(cart.gift_cards.length)
|
console.log(cart.gift_cards.length)
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
// gift card doesn't exist or is disabled
|
// gift card doesn't exist or is disabled
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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.
|
||||||
|
|||||||
@@ -60,22 +60,22 @@ You can learn more about [authenticating as an admin user in the API reference](
|
|||||||
You can list inventory items by sending a request to the [List Inventory Items API Route](https://docs.medusajs.com/api/admin#inventory-items_getinventoryitems):
|
You can list inventory items by sending a request to the [List Inventory Items API Route](https://docs.medusajs.com/api/admin#inventory-items_getinventoryitems):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.inventoryItems.list()
|
medusa.admin.inventoryItems.list()
|
||||||
.then(({ inventory_items }) => {
|
.then(({ inventory_items }) => {
|
||||||
console.log(inventory_items.length)
|
console.log(inventory_items.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminInventoryItems } from "medusa-react"
|
import { useAdminInventoryItems } from "medusa-react"
|
||||||
|
|
||||||
function InventoryItems() {
|
function InventoryItems() {
|
||||||
const {
|
const {
|
||||||
inventory_items,
|
inventory_items,
|
||||||
isLoading } = useAdminInventoryItems()
|
isLoading } = useAdminInventoryItems()
|
||||||
@@ -97,33 +97,33 @@ function InventoryItems() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default InventoryItems
|
export default InventoryItems
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/inventory-items`, {
|
fetch(`<BACKEND_URL>/admin/inventory-items`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ inventory_items }) => {
|
.then(({ inventory_items }) => {
|
||||||
console.log(inventory_items.length)
|
console.log(inventory_items.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/inventory-items' \
|
curl -L -X GET '<BACKEND_URL>/admin/inventory-items' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route doesn't require any path or query parameters. You can, however, pass path parameters to search or filter inventory items. For example, you can get inventory items in a specific location by passing the `location_id` query parameter. You can learn more about available query parameters in the [API reference](https://docs.medusajs.com/api/admin#inventory-items_getinventoryitems).
|
This API Route doesn't require any path or query parameters. You can, however, pass path parameters to search or filter inventory items. For example, you can get inventory items in a specific location by passing the `location_id` query parameter. You can learn more about available query parameters in the [API reference](https://docs.medusajs.com/api/admin#inventory-items_getinventoryitems).
|
||||||
@@ -143,24 +143,24 @@ Inventory items are automatically created when a variant is created with `manage
|
|||||||
You can create an inventory item by sending a request to the [Create Inventory Item API Route](https://docs.medusajs.com/api/admin#inventory-items_postinventoryitems):
|
You can create an inventory item by sending a request to the [Create Inventory Item API Route](https://docs.medusajs.com/api/admin#inventory-items_postinventoryitems):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.inventoryItems.create({
|
medusa.admin.inventoryItems.create({
|
||||||
variant_id,
|
variant_id,
|
||||||
})
|
})
|
||||||
.then(({ inventory_item }) => {
|
.then(({ inventory_item }) => {
|
||||||
console.log(inventory_item.id)
|
console.log(inventory_item.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateInventoryItem } from "medusa-react"
|
import { useAdminCreateInventoryItem } from "medusa-react"
|
||||||
|
|
||||||
const CreateInventoryItem = () => {
|
const CreateInventoryItem = () => {
|
||||||
const createInventoryItem = useAdminCreateInventoryItem()
|
const createInventoryItem = useAdminCreateInventoryItem()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -171,16 +171,16 @@ const CreateInventoryItem = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateInventoryItem
|
export default CreateInventoryItem
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/inventory-items`, {
|
fetch(`<BACKEND_URL>/admin/inventory-items`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -189,26 +189,26 @@ fetch(`<BACKEND_URL>/admin/inventory-items`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
variant_id,
|
variant_id,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ inventory_item }) => {
|
.then(({ inventory_item }) => {
|
||||||
console.log(inventory_item.id)
|
console.log(inventory_item.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/inventory-items' \
|
curl -L -X POST '<BACKEND_URL>/admin/inventory-items' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"variant_id": "variant_123"
|
"variant_id": "variant_123"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires in the body parameter the `variant_id` parameter, which is the ID of the variant to create this inventory item for. You can also pass other inventory-related parameters, such as `sku`. You can learn more about other available parameters in the [API reference](https://docs.medusajs.com/api/admin#inventory-items_postinventoryitems).
|
This API Route requires in the body parameter the `variant_id` parameter, which is the ID of the variant to create this inventory item for. You can also pass other inventory-related parameters, such as `sku`. You can learn more about other available parameters in the [API reference](https://docs.medusajs.com/api/admin#inventory-items_postinventoryitems).
|
||||||
@@ -222,22 +222,22 @@ This request returns the created inventory item as an object.
|
|||||||
You can retrieve an inventory item by sending a request to the [Get Inventory Item API Route](https://docs.medusajs.com/api/admin#inventory-items_getinventoryitemsinventoryitem):
|
You can retrieve an inventory item by sending a request to the [Get Inventory Item API Route](https://docs.medusajs.com/api/admin#inventory-items_getinventoryitemsinventoryitem):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.inventoryItems.retrieve(inventoryItemId)
|
medusa.admin.inventoryItems.retrieve(inventoryItemId)
|
||||||
.then(({ inventory_item }) => {
|
.then(({ inventory_item }) => {
|
||||||
console.log(inventory_item.id)
|
console.log(inventory_item.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminInventoryItem } from "medusa-react"
|
import { useAdminInventoryItem } from "medusa-react"
|
||||||
|
|
||||||
function InventoryItem() {
|
function InventoryItem() {
|
||||||
const {
|
const {
|
||||||
inventory_item,
|
inventory_item,
|
||||||
isLoading } = useAdminInventoryItem(inventoryItemId)
|
isLoading } = useAdminInventoryItem(inventoryItemId)
|
||||||
@@ -250,35 +250,35 @@ function InventoryItem() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default InventoryItem
|
export default InventoryItem
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/inventory-items/${inventoryItemId}`,
|
fetch(`<BACKEND_URL>/admin/inventory-items/${inventoryItemId}`,
|
||||||
{
|
{
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ inventory_item }) => {
|
.then(({ inventory_item }) => {
|
||||||
console.log(inventory_item.id)
|
console.log(inventory_item.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/inventory-items/<ITEM_ID>' \
|
curl -L -X GET '<BACKEND_URL>/admin/inventory-items/<ITEM_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route accepts the ID of the inventory item as a path parameter. You can also path query parameters such as [expand](https://docs.medusajs.com/api/admin#expanding-fields) and [fields](https://docs.medusajs.com/api/admin#selecting-fields).
|
This API Route accepts the ID of the inventory item as a path parameter. You can also path query parameters such as [expand](https://docs.medusajs.com/api/admin#expanding-fields) and [fields](https://docs.medusajs.com/api/admin#selecting-fields).
|
||||||
@@ -292,24 +292,24 @@ The request returns the inventory item as an object.
|
|||||||
You can update an inventory item by sending a request to the [Update Inventory Item API Route](https://docs.medusajs.com/api/admin#inventory-items_postinventoryitemsinventoryitem):
|
You can update an inventory item by sending a request to the [Update Inventory Item API Route](https://docs.medusajs.com/api/admin#inventory-items_postinventoryitemsinventoryitem):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.inventoryItems.update(inventoryItemId, {
|
medusa.admin.inventoryItems.update(inventoryItemId, {
|
||||||
origin_country: "US",
|
origin_country: "US",
|
||||||
})
|
})
|
||||||
.then(({ inventory_item }) => {
|
.then(({ inventory_item }) => {
|
||||||
console.log(inventory_item.id)
|
console.log(inventory_item.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUpdateInventoryItem } from "medusa-react"
|
import { useAdminUpdateInventoryItem } from "medusa-react"
|
||||||
|
|
||||||
const UpdateInventoryItem = () => {
|
const UpdateInventoryItem = () => {
|
||||||
const updateInventoryItem = useAdminUpdateInventoryItem(
|
const updateInventoryItem = useAdminUpdateInventoryItem(
|
||||||
inventoryItemId
|
inventoryItemId
|
||||||
)
|
)
|
||||||
@@ -322,16 +322,16 @@ const UpdateInventoryItem = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdateInventoryItem
|
export default UpdateInventoryItem
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/inventory-items/${inventoryItemId}`,
|
fetch(`<BACKEND_URL>/admin/inventory-items/${inventoryItemId}`,
|
||||||
{
|
{
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -342,26 +342,26 @@ fetch(`<BACKEND_URL>/admin/inventory-items/${inventoryItemId}`,
|
|||||||
origin_country: "US",
|
origin_country: "US",
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ inventory_item }) => {
|
.then(({ inventory_item }) => {
|
||||||
console.log(inventory_item.id)
|
console.log(inventory_item.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/inventory-items/<ITEM_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/inventory-items/<ITEM_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"origin_country": "US"
|
"origin_country": "US"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the inventory item’s ID as a path parameter. You can pass any of the inventory item’s attributes that you want to update in its body parameter. The example above updates the value of the `origin_country` attribute. You can learn more about available body parameters in the [API reference](https://docs.medusajs.com/api/admin#inventory-items_postinventoryitemsinventoryitem).
|
This API Route requires the inventory item’s ID as a path parameter. You can pass any of the inventory item’s attributes that you want to update in its body parameter. The example above updates the value of the `origin_country` attribute. You can learn more about available body parameters in the [API reference](https://docs.medusajs.com/api/admin#inventory-items_postinventoryitemsinventoryitem).
|
||||||
@@ -379,24 +379,24 @@ This section shows you the different ways you can manage inventory levels. Each
|
|||||||
You can list inventory levels of an inventory item by sending a request to the [List inventory levels API Route](https://docs.medusajs.com/api/admin#inventory-items_getinventoryitemsinventoryitemlocationlevels):
|
You can list inventory levels of an inventory item by sending a request to the [List inventory levels API Route](https://docs.medusajs.com/api/admin#inventory-items_getinventoryitemsinventoryitemlocationlevels):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.inventoryItems.listLocationLevels(inventoryItemId)
|
medusa.admin.inventoryItems.listLocationLevels(inventoryItemId)
|
||||||
.then(({ inventory_item }) => {
|
.then(({ inventory_item }) => {
|
||||||
console.log(inventory_item.location_levels)
|
console.log(inventory_item.location_levels)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import {
|
import {
|
||||||
useAdminInventoryItemLocationLevels,
|
useAdminInventoryItemLocationLevels,
|
||||||
} from "medusa-react"
|
} from "medusa-react"
|
||||||
|
|
||||||
function InventoryItem() {
|
function InventoryItem() {
|
||||||
const {
|
const {
|
||||||
inventory_item,
|
inventory_item,
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -414,35 +414,35 @@ function InventoryItem() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default InventoryItem
|
export default InventoryItem
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/inventory-items/${inventoryItemId}/location-levels`, {
|
fetch(`<BACKEND_URL>/admin/inventory-items/${inventoryItemId}/location-levels`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ inventory_item }) => {
|
.then(({ inventory_item }) => {
|
||||||
console.log(inventory_item.location_levels)
|
console.log(inventory_item.location_levels)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/inventory-items/<ITEM_ID>/location-levels' \
|
curl -L -X GET '<BACKEND_URL>/admin/inventory-items/<ITEM_ID>/location-levels' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the ID of the inventory item as a path parameter. You can also pass [expand](https://docs.medusajs.com/api/admin#expanding-fields) and [fields](https://docs.medusajs.com/api/admin#selecting-fields) query parameters.
|
This API Route requires the ID of the inventory item as a path parameter. You can also pass [expand](https://docs.medusajs.com/api/admin#expanding-fields) and [fields](https://docs.medusajs.com/api/admin#selecting-fields) query parameters.
|
||||||
@@ -454,28 +454,28 @@ The request returns the inventory item as an object. In that object, the list of
|
|||||||
You can create a location level by sending a request to the [Create Inventory Level API Route](https://docs.medusajs.com/api/admin#inventory-items_postinventoryitemsinventoryitemlocationlevels):
|
You can create a location level by sending a request to the [Create Inventory Level API Route](https://docs.medusajs.com/api/admin#inventory-items_postinventoryitemsinventoryitemlocationlevels):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.inventoryItems.createLocationLevel(
|
medusa.admin.inventoryItems.createLocationLevel(
|
||||||
inventoryItemId,
|
inventoryItemId,
|
||||||
{
|
{
|
||||||
location_id,
|
location_id,
|
||||||
stocked_quantity: 10,
|
stocked_quantity: 10,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(({ inventory_item }) => {
|
.then(({ inventory_item }) => {
|
||||||
console.log(inventory_item.id)
|
console.log(inventory_item.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateLocationLevel } from "medusa-react"
|
import { useAdminCreateLocationLevel } from "medusa-react"
|
||||||
|
|
||||||
const CreateLocationLevel = () => {
|
const CreateLocationLevel = () => {
|
||||||
const createLocationLevel = useAdminCreateLocationLevel(
|
const createLocationLevel = useAdminCreateLocationLevel(
|
||||||
inventoryItemId
|
inventoryItemId
|
||||||
)
|
)
|
||||||
@@ -489,18 +489,18 @@ const CreateLocationLevel = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateLocationLevel
|
export default CreateLocationLevel
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/inventory-items/${inventoryItemId}/location-levels`, {
|
fetch(`<BACKEND_URL>/admin/inventory-items/${inventoryItemId}/location-levels`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -510,27 +510,27 @@ fetch(`<BACKEND_URL>/admin/inventory-items/${inventoryItemId}/location-levels`,
|
|||||||
location_id,
|
location_id,
|
||||||
stocked_quantity: 10,
|
stocked_quantity: 10,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ inventory_item }) => {
|
.then(({ inventory_item }) => {
|
||||||
console.log(inventory_item.id)
|
console.log(inventory_item.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/inventory-items/<ITEM_ID>/location-levels' \
|
curl -L -X POST '<BACKEND_URL>/admin/inventory-items/<ITEM_ID>/location-levels' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"location_id": "<LOCATION_ID>",
|
"location_id": "<LOCATION_ID>",
|
||||||
"stocked_quantity": 10
|
"stocked_quantity": 10
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the inventory item ID as a path parameter. In the request body, it requires the following parameters:
|
This API Route requires the inventory item ID as a path parameter. In the request body, it requires the following parameters:
|
||||||
@@ -547,28 +547,28 @@ This request returns the inventory item associated with the created location lev
|
|||||||
You can update a location level by sending a request to the [Update Location Level API Route](https://docs.medusajs.com/api/admin#inventory-items_postinventoryitemsinventoryitemlocationlevelslocationlevel):
|
You can update a location level by sending a request to the [Update Location Level API Route](https://docs.medusajs.com/api/admin#inventory-items_postinventoryitemsinventoryitemlocationlevelslocationlevel):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.inventoryItems.updateLocationLevel(
|
medusa.admin.inventoryItems.updateLocationLevel(
|
||||||
inventoryItemId,
|
inventoryItemId,
|
||||||
locationId,
|
locationId,
|
||||||
{
|
{
|
||||||
stocked_quantity: 15,
|
stocked_quantity: 15,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(({ inventory_item }) => {
|
.then(({ inventory_item }) => {
|
||||||
console.log(inventory_item.id)
|
console.log(inventory_item.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUpdateLocationLevel } from "medusa-react"
|
import { useAdminUpdateLocationLevel } from "medusa-react"
|
||||||
|
|
||||||
const UpdateLocationLevel = () => {
|
const UpdateLocationLevel = () => {
|
||||||
const updateLocationLevel = useAdminUpdateLocationLevel(
|
const updateLocationLevel = useAdminUpdateLocationLevel(
|
||||||
inventoryItemId
|
inventoryItemId
|
||||||
)
|
)
|
||||||
@@ -582,18 +582,18 @@ const UpdateLocationLevel = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdateLocationLevel
|
export default UpdateLocationLevel
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/inventory-items/${inventoryItemId}/location-levels/${locationId}`, {
|
fetch(`<BACKEND_URL>/admin/inventory-items/${inventoryItemId}/location-levels/${locationId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -602,26 +602,26 @@ fetch(`<BACKEND_URL>/admin/inventory-items/${inventoryItemId}/location-levels/${
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
stocked_quantity: 10,
|
stocked_quantity: 10,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ inventory_item }) => {
|
.then(({ inventory_item }) => {
|
||||||
console.log(inventory_item.id)
|
console.log(inventory_item.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/inventory-items/<ITEM_ID>/location-levels/<LOCATION_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/inventory-items/<ITEM_ID>/location-levels/<LOCATION_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"stocked_quantity": 10
|
"stocked_quantity": 10
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires two path parameters: the first one being the ID of the inventory item, and the second one being the ID of the location.
|
This API Route requires two path parameters: the first one being the ID of the inventory item, and the second one being the ID of the location.
|
||||||
@@ -635,25 +635,25 @@ The request returns the inventory item associated with the location level as an
|
|||||||
You can delete a location level of an inventory item by sending a request to the [Delete Location Level API Route](https://docs.medusajs.com/api/admin#inventory-items_deleteinventoryitemsinventoryitelocationlevelslocation):
|
You can delete a location level of an inventory item by sending a request to the [Delete Location Level API Route](https://docs.medusajs.com/api/admin#inventory-items_deleteinventoryitemsinventoryitelocationlevelslocation):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.inventoryItems.deleteLocationLevel(
|
medusa.admin.inventoryItems.deleteLocationLevel(
|
||||||
inventoryItemId,
|
inventoryItemId,
|
||||||
locationId
|
locationId
|
||||||
)
|
)
|
||||||
.then(({ inventory_item }) => {
|
.then(({ inventory_item }) => {
|
||||||
console.log(inventory_item.id)
|
console.log(inventory_item.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDeleteLocationLevel } from "medusa-react"
|
import { useAdminDeleteLocationLevel } from "medusa-react"
|
||||||
|
|
||||||
const DeleteLocationLevel = () => {
|
const DeleteLocationLevel = () => {
|
||||||
const deleteLocationLevel = useAdminDeleteLocationLevel(
|
const deleteLocationLevel = useAdminDeleteLocationLevel(
|
||||||
inventoryItemId
|
inventoryItemId
|
||||||
)
|
)
|
||||||
@@ -664,36 +664,36 @@ const DeleteLocationLevel = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DeleteLocationLevel
|
export default DeleteLocationLevel
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/inventory-items/${inventoryItemId}/location-levels/${locationId}`, {
|
fetch(`<BACKEND_URL>/admin/inventory-items/${inventoryItemId}/location-levels/${locationId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ inventory_item }) => {
|
.then(({ inventory_item }) => {
|
||||||
console.log(inventory_item.id)
|
console.log(inventory_item.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/inventory-items/<ITEM_ID>/location-levels/<LOC_ID>' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/inventory-items/<ITEM_ID>/location-levels/<LOC_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires two path parameters: the first one being the inventory item’s ID and the second one being the location level’s ID.
|
This API Route requires two path parameters: the first one being the inventory item’s ID and the second one being the location level’s ID.
|
||||||
@@ -707,22 +707,22 @@ The request returns the inventory item as an object.
|
|||||||
You can delete an inventory item by sending a request to the [Delete Inventory Item API Route](https://docs.medusajs.com/api/admin#inventory-items_deleteinventoryitemsinventoryitem):
|
You can delete an inventory item by sending a request to the [Delete Inventory Item API Route](https://docs.medusajs.com/api/admin#inventory-items_deleteinventoryitemsinventoryitem):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.inventoryItems.delete(inventoryItemId)
|
medusa.admin.inventoryItems.delete(inventoryItemId)
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDeleteInventoryItem } from "medusa-react"
|
import { useAdminDeleteInventoryItem } from "medusa-react"
|
||||||
|
|
||||||
const DeleteInventoryItem = () => {
|
const DeleteInventoryItem = () => {
|
||||||
const deleteInventoryItem = useAdminDeleteInventoryItem(
|
const deleteInventoryItem = useAdminDeleteInventoryItem(
|
||||||
inventoryItemId
|
inventoryItemId
|
||||||
)
|
)
|
||||||
@@ -733,36 +733,36 @@ const DeleteInventoryItem = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DeleteInventoryItem
|
export default DeleteInventoryItem
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/inventory-items/${inventoryItemId}`,
|
fetch(`<BACKEND_URL>/admin/inventory-items/${inventoryItemId}`,
|
||||||
{
|
{
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/inventory-items/<ITEM_ID>' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/inventory-items/<ITEM_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the inventory item’s ID be passed as a path parameter.
|
This API Route requires the inventory item’s ID be passed as a path parameter.
|
||||||
|
|||||||
+208
-208
@@ -79,27 +79,27 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.reservations.create({
|
medusa.admin.reservations.create({
|
||||||
line_item_id,
|
line_item_id,
|
||||||
location_id,
|
location_id,
|
||||||
inventory_item_id,
|
inventory_item_id,
|
||||||
quantity,
|
quantity,
|
||||||
})
|
})
|
||||||
.then(({ reservation }) => {
|
.then(({ reservation }) => {
|
||||||
console.log(reservation.id)
|
console.log(reservation.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateReservation } from "medusa-react"
|
import { useAdminCreateReservation } from "medusa-react"
|
||||||
|
|
||||||
const CreateReservation = () => {
|
const CreateReservation = () => {
|
||||||
const createReservation = useAdminCreateReservation()
|
const createReservation = useAdminCreateReservation()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -113,16 +113,16 @@ const CreateReservation = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateReservation
|
export default CreateReservation
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/reservations`, {
|
fetch(`<BACKEND_URL>/admin/reservations`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -134,18 +134,18 @@ fetch(`<BACKEND_URL>/admin/reservations`, {
|
|||||||
inventory_item_id,
|
inventory_item_id,
|
||||||
quantity,
|
quantity,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ reservation }) => {
|
.then(({ reservation }) => {
|
||||||
console.log(reservation.id)
|
console.log(reservation.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/reservations' \
|
curl -L -X POST '<BACKEND_URL>/admin/reservations' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
@@ -154,9 +154,9 @@ curl -L -X POST '<BACKEND_URL>/admin/reservations' \
|
|||||||
"inventory_item_id": "<INV_ITEM_ID>",
|
"inventory_item_id": "<INV_ITEM_ID>",
|
||||||
"quantity": 1
|
"quantity": 1
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the following body parameters:
|
This API Route requires the following body parameters:
|
||||||
@@ -175,24 +175,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.reservations.list({
|
medusa.admin.reservations.list({
|
||||||
line_item_id,
|
line_item_id,
|
||||||
})
|
})
|
||||||
.then(({ reservations, count, limit, offset }) => {
|
.then(({ reservations, count, limit, offset }) => {
|
||||||
console.log(reservations.length)
|
console.log(reservations.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminReservations } from "medusa-react"
|
import { useAdminReservations } from "medusa-react"
|
||||||
|
|
||||||
function Reservations() {
|
function Reservations() {
|
||||||
const { reservations, isLoading } = useAdminReservations({
|
const { reservations, isLoading } = useAdminReservations({
|
||||||
line_item_id,
|
line_item_id,
|
||||||
})
|
})
|
||||||
@@ -212,35 +212,35 @@ function Reservations() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Reservations
|
export default Reservations
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/reservations?line_item_id=${lineItemId}`, {
|
fetch(`<BACKEND_URL>/admin/reservations?line_item_id=${lineItemId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ reservations, count, limit, offset }) => {
|
.then(({ reservations, count, limit, offset }) => {
|
||||||
console.log(reservations.length)
|
console.log(reservations.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/reservations?line_item_id=<LINE_ITEM_ID>' \
|
curl -L -X GET '<BACKEND_URL>/admin/reservations?line_item_id=<LINE_ITEM_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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,22 +252,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.reservations.retrieve(reservationId)
|
medusa.admin.reservations.retrieve(reservationId)
|
||||||
.then(({ reservation }) => {
|
.then(({ reservation }) => {
|
||||||
console.log(reservation.id)
|
console.log(reservation.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminReservation } from "medusa-react"
|
import { useAdminReservation } from "medusa-react"
|
||||||
|
|
||||||
function Reservation() {
|
function Reservation() {
|
||||||
const {
|
const {
|
||||||
reservation,
|
reservation,
|
||||||
isLoading } = useAdminReservation(reservationId)
|
isLoading } = useAdminReservation(reservationId)
|
||||||
@@ -280,33 +280,33 @@ function Reservation() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Reservation
|
export default Reservation
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
|
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ reservation }) => {
|
.then(({ reservation }) => {
|
||||||
console.log(reservation.id)
|
console.log(reservation.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
|
curl -L -X GET '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the reservation’s ID as a path parameter.
|
This API Route requires the reservation’s ID as a path parameter.
|
||||||
@@ -318,24 +318,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.reservations.update(reservationId, {
|
medusa.admin.reservations.update(reservationId, {
|
||||||
quantity,
|
quantity,
|
||||||
})
|
})
|
||||||
.then(({ reservation }) => {
|
.then(({ reservation }) => {
|
||||||
console.log(reservation.id)
|
console.log(reservation.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUpdateReservation } from "medusa-react"
|
import { useAdminUpdateReservation } from "medusa-react"
|
||||||
|
|
||||||
const UpdateReservation = () => {
|
const UpdateReservation = () => {
|
||||||
const updateReservation = useAdminUpdateReservation(
|
const updateReservation = useAdminUpdateReservation(
|
||||||
reservationId
|
reservationId
|
||||||
)
|
)
|
||||||
@@ -348,16 +348,16 @@ const UpdateReservation = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdateReservation
|
export default UpdateReservation
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
|
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -366,26 +366,26 @@ fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
quantity,
|
quantity,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ reservation }) => {
|
.then(({ reservation }) => {
|
||||||
console.log(reservation.id)
|
console.log(reservation.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"quantity": 3
|
"quantity": 3
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the ID of the reservation as a path parameter.
|
This API Route requires the ID of the reservation as a path parameter.
|
||||||
@@ -405,22 +405,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.reservations.delete(reservationId)
|
medusa.admin.reservations.delete(reservationId)
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDeleteReservation } from "medusa-react"
|
import { useAdminDeleteReservation } from "medusa-react"
|
||||||
|
|
||||||
const DeleteReservation = () => {
|
const DeleteReservation = () => {
|
||||||
const deleteReservation = useAdminDeleteReservation(
|
const deleteReservation = useAdminDeleteReservation(
|
||||||
reservationId
|
reservationId
|
||||||
)
|
)
|
||||||
@@ -431,34 +431,34 @@ const DeleteReservation = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DeleteReservation
|
export default DeleteReservation
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
|
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the reservation ID to be passed as a path parameter.
|
This API Route requires the reservation ID to be passed as a path parameter.
|
||||||
@@ -476,10 +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:
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orders.createFulfillment(orderId, {
|
medusa.admin.orders.createFulfillment(orderId, {
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
item_id,
|
item_id,
|
||||||
@@ -488,19 +488,19 @@ medusa.admin.orders.createFulfillment(orderId, {
|
|||||||
],
|
],
|
||||||
// ...other parameters
|
// ...other parameters
|
||||||
location_id,
|
location_id,
|
||||||
})
|
})
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.id)
|
console.log(order.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateFulfillment } from "medusa-react"
|
import { useAdminCreateFulfillment } from "medusa-react"
|
||||||
|
|
||||||
const CreateFulfillment = () => {
|
const CreateFulfillment = () => {
|
||||||
const createFulfillment = useAdminCreateFulfillment(orderId)
|
const createFulfillment = useAdminCreateFulfillment(orderId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -518,16 +518,16 @@ const CreateFulfillment = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateFulfillment
|
export default CreateFulfillment
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/orders/${orderId}/fulfillment`, {
|
fetch(`<BACKEND_URL>/admin/orders/${orderId}/fulfillment`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -543,18 +543,18 @@ fetch(`<BACKEND_URL>/admin/orders/${orderId}/fulfillment`, {
|
|||||||
// ...other parameters
|
// ...other parameters
|
||||||
location_id,
|
location_id,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.id)
|
console.log(order.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/fulfillment' \
|
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/fulfillment' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
@@ -566,9 +566,9 @@ curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/fulfillment' \
|
|||||||
],
|
],
|
||||||
"location_id": "<LOC_ID>"
|
"location_id": "<LOC_ID>"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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,10 +582,10 @@ 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:
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orders.requestReturn(orderId, {
|
medusa.admin.orders.requestReturn(orderId, {
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
item_id,
|
item_id,
|
||||||
@@ -594,19 +594,19 @@ medusa.admin.orders.requestReturn(orderId, {
|
|||||||
],
|
],
|
||||||
// other parameters...
|
// other parameters...
|
||||||
location_id,
|
location_id,
|
||||||
})
|
})
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.id)
|
console.log(order.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminRequestReturn } from "medusa-react"
|
import { useAdminRequestReturn } from "medusa-react"
|
||||||
|
|
||||||
const RequestReturn = () => {
|
const RequestReturn = () => {
|
||||||
const requestReturn = useAdminRequestReturn(orderId)
|
const requestReturn = useAdminRequestReturn(orderId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -624,16 +624,16 @@ const RequestReturn = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default RequestReturn
|
export default RequestReturn
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/orders/${orderId}/return`, {
|
fetch(`<BACKEND_URL>/admin/orders/${orderId}/return`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -649,18 +649,18 @@ fetch(`<BACKEND_URL>/admin/orders/${orderId}/return`, {
|
|||||||
// ...other parameters
|
// ...other parameters
|
||||||
location_id,
|
location_id,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.id)
|
console.log(order.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/return' \
|
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/return' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
@@ -672,9 +672,9 @@ curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/return' \
|
|||||||
],
|
],
|
||||||
"location_id": "<LOC_ID>"
|
"location_id": "<LOC_ID>"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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,22 +72,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.reservations.list()
|
medusa.admin.reservations.list()
|
||||||
.then(({ reservations, limit, count, offset }) => {
|
.then(({ reservations, limit, count, offset }) => {
|
||||||
console.log(reservations.length)
|
console.log(reservations.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminReservations } from "medusa-react"
|
import { useAdminReservations } from "medusa-react"
|
||||||
|
|
||||||
const Reservations = () => {
|
const Reservations = () => {
|
||||||
const { reservations, isLoading } = useAdminReservations()
|
const { reservations, isLoading } = useAdminReservations()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -105,33 +105,33 @@ const Reservations = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Reservations
|
export default Reservations
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/reservations`, {
|
fetch(`<BACKEND_URL>/admin/reservations`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ reservations, limit, count, offset }) => {
|
.then(({ reservations, limit, count, offset }) => {
|
||||||
console.log(reservations.length)
|
console.log(reservations.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/reservations' \
|
curl -L -X GET '<BACKEND_URL>/admin/reservations' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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,26 +151,26 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.reservations.create({
|
medusa.admin.reservations.create({
|
||||||
location_id,
|
location_id,
|
||||||
inventory_item_id,
|
inventory_item_id,
|
||||||
quantity,
|
quantity,
|
||||||
})
|
})
|
||||||
.then(({ reservation }) => {
|
.then(({ reservation }) => {
|
||||||
console.log(reservation.id)
|
console.log(reservation.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateReservation } from "medusa-react"
|
import { useAdminCreateReservation } from "medusa-react"
|
||||||
|
|
||||||
const CreateReservation = () => {
|
const CreateReservation = () => {
|
||||||
const createReservation = useAdminCreateReservation()
|
const createReservation = useAdminCreateReservation()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -183,16 +183,16 @@ const CreateReservation = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateReservation
|
export default CreateReservation
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/reservations`, {
|
fetch(`<BACKEND_URL>/admin/reservations`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -203,18 +203,18 @@ fetch(`<BACKEND_URL>/admin/reservations`, {
|
|||||||
inventory_item_id,
|
inventory_item_id,
|
||||||
quantity,
|
quantity,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ reservation }) => {
|
.then(({ reservation }) => {
|
||||||
console.log(reservation.id)
|
console.log(reservation.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/reservations' \
|
curl -L -X POST '<BACKEND_URL>/admin/reservations' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
@@ -222,9 +222,9 @@ curl -L -X POST '<BACKEND_URL>/admin/reservations' \
|
|||||||
"inventory_item_id": "<INV_ITEM_ID>",
|
"inventory_item_id": "<INV_ITEM_ID>",
|
||||||
"quantity": 1
|
"quantity": 1
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the following body parameters:
|
This API Route requires the following body parameters:
|
||||||
@@ -242,24 +242,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.reservations.update(reservationId, {
|
medusa.admin.reservations.update(reservationId, {
|
||||||
quantity,
|
quantity,
|
||||||
})
|
})
|
||||||
.then(({ reservation }) => {
|
.then(({ reservation }) => {
|
||||||
console.log(reservation.id)
|
console.log(reservation.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUpdateReservation } from "medusa-react"
|
import { useAdminUpdateReservation } from "medusa-react"
|
||||||
|
|
||||||
const UpdateReservation = () => {
|
const UpdateReservation = () => {
|
||||||
const updateReservation = useAdminUpdateReservation(
|
const updateReservation = useAdminUpdateReservation(
|
||||||
reservationId
|
reservationId
|
||||||
)
|
)
|
||||||
@@ -272,16 +272,16 @@ const UpdateReservation = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdateReservation
|
export default UpdateReservation
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
|
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -290,26 +290,26 @@ fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
quantity,
|
quantity,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ reservation }) => {
|
.then(({ reservation }) => {
|
||||||
console.log(reservation.id)
|
console.log(reservation.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"quantity": 3
|
"quantity": 3
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the ID of the reservation as a path parameter.
|
This API Route requires the ID of the reservation as a path parameter.
|
||||||
@@ -329,22 +329,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.reservations.delete(reservationId)
|
medusa.admin.reservations.delete(reservationId)
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDeleteReservation } from "medusa-react"
|
import { useAdminDeleteReservation } from "medusa-react"
|
||||||
|
|
||||||
const DeleteReservation = () => {
|
const DeleteReservation = () => {
|
||||||
const deleteReservation = useAdminDeleteReservation(
|
const deleteReservation = useAdminDeleteReservation(
|
||||||
reservationId
|
reservationId
|
||||||
)
|
)
|
||||||
@@ -355,34 +355,34 @@ const DeleteReservation = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DeleteReservation
|
export default DeleteReservation
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
|
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the reservation ID to be passed as a path parameter.
|
This API Route requires the reservation ID to be passed as a path parameter.
|
||||||
|
|||||||
@@ -62,22 +62,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.stockLocations.list()
|
medusa.admin.stockLocations.list()
|
||||||
.then(({ stock_locations, limit, offset, count }) => {
|
.then(({ stock_locations, limit, offset, count }) => {
|
||||||
console.log(stock_locations.length)
|
console.log(stock_locations.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminStockLocations } from "medusa-react"
|
import { useAdminStockLocations } from "medusa-react"
|
||||||
|
|
||||||
function StockLocations() {
|
function StockLocations() {
|
||||||
const {
|
const {
|
||||||
stock_locations,
|
stock_locations,
|
||||||
isLoading } = useAdminStockLocations()
|
isLoading } = useAdminStockLocations()
|
||||||
@@ -99,33 +99,33 @@ function StockLocations() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default StockLocations
|
export default StockLocations
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/stock-locations`, {
|
fetch(`<BACKEND_URL>/admin/stock-locations`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ stock_locations, limit, offset, count }) => {
|
.then(({ stock_locations, limit, offset, count }) => {
|
||||||
console.log(stock_locations.length)
|
console.log(stock_locations.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/stock-locations' \
|
curl -L -X GET '<BACKEND_URL>/admin/stock-locations' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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).
|
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,24 +139,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.stockLocations.create({
|
medusa.admin.stockLocations.create({
|
||||||
name: "Main Warehouse",
|
name: "Main Warehouse",
|
||||||
})
|
})
|
||||||
.then(({ stock_location }) => {
|
.then(({ stock_location }) => {
|
||||||
console.log(stock_location.id)
|
console.log(stock_location.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateStockLocation } from "medusa-react"
|
import { useAdminCreateStockLocation } from "medusa-react"
|
||||||
|
|
||||||
const CreateStockLocation = () => {
|
const CreateStockLocation = () => {
|
||||||
const createStockLocation = useAdminCreateStockLocation()
|
const createStockLocation = useAdminCreateStockLocation()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -167,16 +167,16 @@ const CreateStockLocation = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateStockLocation
|
export default CreateStockLocation
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/stock-locations`, {
|
fetch(`<BACKEND_URL>/admin/stock-locations`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -185,26 +185,26 @@ fetch(`<BACKEND_URL>/admin/stock-locations`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
name: "Main Warehouse",
|
name: "Main Warehouse",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ stock_location }) => {
|
.then(({ stock_location }) => {
|
||||||
console.log(stock_location.id)
|
console.log(stock_location.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/stock-locations' \
|
curl -L -X POST '<BACKEND_URL>/admin/stock-locations' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"name": "Main Warehouse"
|
"name": "Main Warehouse"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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).
|
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,22 +218,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.stockLocations.retrieve(stockLocationId)
|
medusa.admin.stockLocations.retrieve(stockLocationId)
|
||||||
.then(({ stock_location }) => {
|
.then(({ stock_location }) => {
|
||||||
console.log(stock_location.id)
|
console.log(stock_location.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminStockLocation } from "medusa-react"
|
import { useAdminStockLocation } from "medusa-react"
|
||||||
|
|
||||||
function StockLocation() {
|
function StockLocation() {
|
||||||
const {
|
const {
|
||||||
stock_location,
|
stock_location,
|
||||||
isLoading } = useAdminStockLocation(stockLocationId)
|
isLoading } = useAdminStockLocation(stockLocationId)
|
||||||
@@ -246,35 +246,35 @@ function StockLocation() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default StockLocation
|
export default StockLocation
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/stock-locations/${stockLocationId}`,
|
fetch(`<BACKEND_URL>/admin/stock-locations/${stockLocationId}`,
|
||||||
{
|
{
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ stock_location }) => {
|
.then(({ stock_location }) => {
|
||||||
console.log(stock_location.id)
|
console.log(stock_location.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/stock-locations/<LOC_ID>' \
|
curl -L -X GET '<BACKEND_URL>/admin/stock-locations/<LOC_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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).
|
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,24 +288,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.salesChannels.addLocation(salesChannelId, {
|
medusa.admin.salesChannels.addLocation(salesChannelId, {
|
||||||
location_id,
|
location_id,
|
||||||
})
|
})
|
||||||
.then(({ sales_channel }) => {
|
.then(({ sales_channel }) => {
|
||||||
console.log(sales_channel.id)
|
console.log(sales_channel.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminAddLocationToSalesChannel } from "medusa-react"
|
import { useAdminAddLocationToSalesChannel } from "medusa-react"
|
||||||
|
|
||||||
function StockLocation() {
|
function StockLocation() {
|
||||||
const addLocation = useAdminAddLocationToSalesChannel()
|
const addLocation = useAdminAddLocationToSalesChannel()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -315,18 +315,18 @@ function StockLocation() {
|
|||||||
location_id,
|
location_id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default StockLocation
|
export default StockLocation
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/sales-channels/${salesChannelId}/stock-locations`, {
|
fetch(`<BACKEND_URL>/admin/sales-channels/${salesChannelId}/stock-locations`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -335,26 +335,26 @@ fetch(`<BACKEND_URL>/admin/sales-channels/${salesChannelId}/stock-locations`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
location_id,
|
location_id,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ sales_channel }) => {
|
.then(({ sales_channel }) => {
|
||||||
console.log(sales_channel.id)
|
console.log(sales_channel.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/sales-channels/<CHANNEL_ID>/stock-locations' \
|
curl -L -X POST '<BACKEND_URL>/admin/sales-channels/<CHANNEL_ID>/stock-locations' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"location_id": "<LOC_ID>"
|
"location_id": "<LOC_ID>"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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,26 +374,26 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.salesChannels.removeLocation(salesChannelId, {
|
medusa.admin.salesChannels.removeLocation(salesChannelId, {
|
||||||
location_id,
|
location_id,
|
||||||
})
|
})
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import {
|
import {
|
||||||
useAdminRemoveLocationFromSalesChannel,
|
useAdminRemoveLocationFromSalesChannel,
|
||||||
} from "medusa-react"
|
} from "medusa-react"
|
||||||
|
|
||||||
function StockLocation() {
|
function StockLocation() {
|
||||||
const removeLocation =
|
const removeLocation =
|
||||||
useAdminRemoveLocationFromSalesChannel()
|
useAdminRemoveLocationFromSalesChannel()
|
||||||
// ...
|
// ...
|
||||||
@@ -404,18 +404,18 @@ function StockLocation() {
|
|||||||
location_id,
|
location_id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default StockLocation
|
export default StockLocation
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/sales-channels/${salesChannelId}/stock-locations`, {
|
fetch(`<BACKEND_URL>/admin/sales-channels/${salesChannelId}/stock-locations`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -424,26 +424,26 @@ fetch(`<BACKEND_URL>/admin/sales-channels/${salesChannelId}/stock-locations`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
location_id,
|
location_id,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/sales-channels/<CHANNEL_ID>/stock-locations' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/sales-channels/<CHANNEL_ID>/stock-locations' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"location_id": "<LOC_ID>"
|
"location_id": "<LOC_ID>"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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,24 +467,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.stockLocations.update(stockLocationId, {
|
medusa.admin.stockLocations.update(stockLocationId, {
|
||||||
name: "Warehouse",
|
name: "Warehouse",
|
||||||
})
|
})
|
||||||
.then(({ stock_location }) => {
|
.then(({ stock_location }) => {
|
||||||
console.log(stock_location.id)
|
console.log(stock_location.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUpdateStockLocation } from "medusa-react"
|
import { useAdminUpdateStockLocation } from "medusa-react"
|
||||||
|
|
||||||
function StockLocation() {
|
function StockLocation() {
|
||||||
const updateLocation = useAdminUpdateStockLocation(
|
const updateLocation = useAdminUpdateStockLocation(
|
||||||
stockLocationId
|
stockLocationId
|
||||||
)
|
)
|
||||||
@@ -495,16 +495,16 @@ function StockLocation() {
|
|||||||
name: "Warehouse",
|
name: "Warehouse",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default StockLocation
|
export default StockLocation
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/stock-locations/${stockLocationId}`,
|
fetch(`<BACKEND_URL>/admin/stock-locations/${stockLocationId}`,
|
||||||
{
|
{
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -515,26 +515,26 @@ fetch(`<BACKEND_URL>/admin/stock-locations/${stockLocationId}`,
|
|||||||
name: "Warehouse",
|
name: "Warehouse",
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ stock_location }) => {
|
.then(({ stock_location }) => {
|
||||||
console.log(stock_location.id)
|
console.log(stock_location.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/stock-locations/<LOC_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/stock-locations/<LOC_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"name": "Main Warehouse"
|
"name": "Main Warehouse"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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).
|
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,22 +548,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.stockLocations.delete(stockLocationId)
|
medusa.admin.stockLocations.delete(stockLocationId)
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDeleteStockLocation } from "medusa-react"
|
import { useAdminDeleteStockLocation } from "medusa-react"
|
||||||
|
|
||||||
function StockLocation() {
|
function StockLocation() {
|
||||||
const deleteLocation = useAdminDeleteStockLocation(
|
const deleteLocation = useAdminDeleteStockLocation(
|
||||||
stockLocationId
|
stockLocationId
|
||||||
)
|
)
|
||||||
@@ -572,36 +572,36 @@ function StockLocation() {
|
|||||||
const handleDelete = () => {
|
const handleDelete = () => {
|
||||||
deleteLocation.mutate()
|
deleteLocation.mutate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default StockLocation
|
export default StockLocation
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/stock-locations/${stockLocationId}`,
|
fetch(`<BACKEND_URL>/admin/stock-locations/${stockLocationId}`,
|
||||||
{
|
{
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/stock-locations/<LOC_ID>' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/stock-locations/<LOC_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the ID of the stock location as a path parameter.
|
This API Route requires the ID of the stock location as a path parameter.
|
||||||
|
|||||||
@@ -83,24 +83,24 @@ Before you can start making changes to an order, you have to create a new order
|
|||||||
To do that, send a request to the [Create an OrderEdit API Route](https://docs.medusajs.com/api/admin#order-edits_postorderedits):
|
To do that, send a request to the [Create an OrderEdit API Route](https://docs.medusajs.com/api/admin#order-edits_postorderedits):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orderEdits.create({
|
medusa.admin.orderEdits.create({
|
||||||
order_id, // required
|
order_id, // required
|
||||||
})
|
})
|
||||||
.then(({ order_edit }) => {
|
.then(({ order_edit }) => {
|
||||||
console.log(order_edit.id)
|
console.log(order_edit.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateOrderEdit } from "medusa-react"
|
import { useAdminCreateOrderEdit } from "medusa-react"
|
||||||
|
|
||||||
const OrderEdit = () => {
|
const OrderEdit = () => {
|
||||||
const createOrderEdit = useAdminCreateOrderEdit()
|
const createOrderEdit = useAdminCreateOrderEdit()
|
||||||
|
|
||||||
const handleCreateOrderEdit = (orderId: string) => {
|
const handleCreateOrderEdit = (orderId: string) => {
|
||||||
@@ -110,16 +110,16 @@ const OrderEdit = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default OrderEdit
|
export default OrderEdit
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/order-edits`, {
|
fetch(`<BACKEND_URL>/admin/order-edits`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -128,26 +128,26 @@ fetch(`<BACKEND_URL>/admin/order-edits`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
order_id,
|
order_id,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order_edit }) => {
|
.then(({ order_edit }) => {
|
||||||
console.log(order_edit.id)
|
console.log(order_edit.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/order-edits' \
|
curl -L -X POST '<BACKEND_URL>/admin/order-edits' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"order_id": "<ORDER_ID>"
|
"order_id": "<ORDER_ID>"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route has one required request body parameter `order_id` which is the ID of the order this edit is being created for.
|
This API Route has one required request body parameter `order_id` which is the ID of the order this edit is being created for.
|
||||||
@@ -177,25 +177,25 @@ You can only make changes to items that have not been fulfilled yet in the order
|
|||||||
To add a new item to the original order, send a request to the [Add Line Item API Route](https://docs.medusajs.com/api/admin#order-edits_postordereditseditlineitems):
|
To add a new item to the original order, send a request to the [Add Line Item API Route](https://docs.medusajs.com/api/admin#order-edits_postordereditseditlineitems):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orderEdits.addLineItem(orderEditId, {
|
medusa.admin.orderEdits.addLineItem(orderEditId, {
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
variant_id,
|
variant_id,
|
||||||
})
|
})
|
||||||
.then(({ order_edit }) => {
|
.then(({ order_edit }) => {
|
||||||
console.log(order_edit.changes)
|
console.log(order_edit.changes)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminOrderEditAddLineItem } from "medusa-react"
|
import { useAdminOrderEditAddLineItem } from "medusa-react"
|
||||||
|
|
||||||
const OrderEdit = () => {
|
const OrderEdit = () => {
|
||||||
const addLineItem = useAdminOrderEditAddLineItem(orderEditId)
|
const addLineItem = useAdminOrderEditAddLineItem(orderEditId)
|
||||||
|
|
||||||
const handleAddLineItem =
|
const handleAddLineItem =
|
||||||
@@ -207,16 +207,16 @@ const OrderEdit = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default OrderEdit
|
export default OrderEdit
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/order-edits/${orderEditId}/items`, {
|
fetch(`<BACKEND_URL>/admin/order-edits/${orderEditId}/items`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -226,27 +226,27 @@ fetch(`<BACKEND_URL>/admin/order-edits/${orderEditId}/items`, {
|
|||||||
quantity: 1,
|
quantity: 1,
|
||||||
variant_id,
|
variant_id,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order_edit }) => {
|
.then(({ order_edit }) => {
|
||||||
console.log(order_edit.changes)
|
console.log(order_edit.changes)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/order-edits/<ORDER_EDIT_ID>/items' \
|
curl -L -X POST '<BACKEND_URL>/admin/order-edits/<ORDER_EDIT_ID>/items' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"quantity": 1,
|
"quantity": 1,
|
||||||
"variant_id": "<VARIANT_ID>"
|
"variant_id": "<VARIANT_ID>"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the ID of the order edit as a path parameter.
|
This request requires the ID of the order edit as a path parameter.
|
||||||
@@ -262,24 +262,24 @@ You can edit an item’s quantity in the original order.
|
|||||||
To update an item, send a request to the [Update Line Item API Route](https://docs.medusajs.com/api/admin#order-edits_postordereditseditlineitemslineitem):
|
To update an item, send a request to the [Update Line Item API Route](https://docs.medusajs.com/api/admin#order-edits_postordereditseditlineitemslineitem):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orderEdits.updateLineItem(orderEditId, itemId, {
|
medusa.admin.orderEdits.updateLineItem(orderEditId, itemId, {
|
||||||
quantity: 2,
|
quantity: 2,
|
||||||
})
|
})
|
||||||
.then(({ order_edit }) => {
|
.then(({ order_edit }) => {
|
||||||
console.log(order_edit.changes)
|
console.log(order_edit.changes)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminOrderEditUpdateLineItem } from "medusa-react"
|
import { useAdminOrderEditUpdateLineItem } from "medusa-react"
|
||||||
|
|
||||||
const OrderEdit = () => {
|
const OrderEdit = () => {
|
||||||
const updateLineItem = useAdminOrderEditUpdateLineItem(
|
const updateLineItem = useAdminOrderEditUpdateLineItem(
|
||||||
orderEditId,
|
orderEditId,
|
||||||
itemId
|
itemId
|
||||||
@@ -292,18 +292,18 @@ const OrderEdit = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default OrderEdit
|
export default OrderEdit
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/order-edits/${orderEditId}/items/${itemId}`, {
|
fetch(`<BACKEND_URL>/admin/order-edits/${orderEditId}/items/${itemId}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -312,26 +312,25 @@ fetch(`<BACKEND_URL>/admin/order-edits/${orderEditId}/items/${itemId}`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
quantity: 2,
|
quantity: 2,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order_edit }) => {
|
.then(({ order_edit }) => {
|
||||||
console.log(order_edit.changes)
|
console.log(order_edit.changes)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
</TabItem>
|
```bash
|
||||||
<TabItem value="curl" label="cURL">
|
curl -L -X POST '<BACKEND_URL>/admin/order-edits/<ORDER_EDIT_ID>/items/<ITEM_ID>' \
|
||||||
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
```bash
|
-H 'Content-Type: application/json' \
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/order-edits/<ORDER_EDIT_ID>/items/<ITEM_ID>' \
|
--data-raw '{
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
--data-raw '{
|
|
||||||
"quantity": 2
|
"quantity": 2
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the ID of the order edit and the ID of the item in the original order as path parameters.
|
This request requires the ID of the order edit and the ID of the item in the original order as path parameters.
|
||||||
@@ -345,22 +344,22 @@ This request returns the Order Edit object. You can access returned item changes
|
|||||||
You can remove an item from the original order by sending a request to the [Remove Line Item API Route](https://docs.medusajs.com/api/admin#order-edits_deleteordereditsordereditlineitemslineitem):
|
You can remove an item from the original order by sending a request to the [Remove Line Item API Route](https://docs.medusajs.com/api/admin#order-edits_deleteordereditsordereditlineitemslineitem):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orderEdits.removeLineItem(orderEditId, itemId)
|
medusa.admin.orderEdits.removeLineItem(orderEditId, itemId)
|
||||||
.then(({ order_edit }) => {
|
.then(({ order_edit }) => {
|
||||||
console.log(order_edit.changes)
|
console.log(order_edit.changes)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminOrderEditDeleteLineItem } from "medusa-react"
|
import { useAdminOrderEditDeleteLineItem } from "medusa-react"
|
||||||
|
|
||||||
const OrderEdit = () => {
|
const OrderEdit = () => {
|
||||||
const removeLineItem = useAdminOrderEditDeleteLineItem(
|
const removeLineItem = useAdminOrderEditDeleteLineItem(
|
||||||
orderEditId,
|
orderEditId,
|
||||||
itemId
|
itemId
|
||||||
@@ -371,36 +370,36 @@ const OrderEdit = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default OrderEdit
|
export default OrderEdit
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/order-edits/${orderEditId}/items/${itemId}`, {
|
fetch(`<BACKEND_URL>/admin/order-edits/${orderEditId}/items/${itemId}`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order_edit }) => {
|
.then(({ order_edit }) => {
|
||||||
console.log(order_edit.changes)
|
console.log(order_edit.changes)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/order-edits/<ORDER_EDIT_ID>/items/<ITEM_ID>' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/order-edits/<ORDER_EDIT_ID>/items/<ITEM_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the order edit’s ID and the ID of the item in the original order as path parameters.
|
This request requires the order edit’s ID and the ID of the item in the original order as path parameters.
|
||||||
@@ -416,22 +415,22 @@ A merchant might make a mistake while making a change to the original order’s
|
|||||||
To revert an item change, send a request to the [Delete Item Change API Route](https://docs.medusajs.com/api/admin#order-edits_deleteordereditsorderedititemchange):
|
To revert an item change, send a request to the [Delete Item Change API Route](https://docs.medusajs.com/api/admin#order-edits_deleteordereditsorderedititemchange):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orderEdits.deleteItemChange(orderEditId, changeId)
|
medusa.admin.orderEdits.deleteItemChange(orderEditId, changeId)
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDeleteOrderEditItemChange } from "medusa-react"
|
import { useAdminDeleteOrderEditItemChange } from "medusa-react"
|
||||||
|
|
||||||
const OrderEdit = () => {
|
const OrderEdit = () => {
|
||||||
const deleteItemChange = useAdminDeleteOrderEditItemChange(
|
const deleteItemChange = useAdminDeleteOrderEditItemChange(
|
||||||
orderEditId,
|
orderEditId,
|
||||||
itemChangeId
|
itemChangeId
|
||||||
@@ -442,39 +441,39 @@ const OrderEdit = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default OrderEdit
|
export default OrderEdit
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/admin/order-edits/${orderEditId}/changes/${changeId}`,
|
`<BACKEND_URL>/admin/order-edits/${orderEditId}/changes/${changeId}`,
|
||||||
{
|
{
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id, object, deleted)
|
console.log(id, object, deleted)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/order-edits/<ORDER_EDIT_ID>/changes/<CHANGE_ID>' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/order-edits/<ORDER_EDIT_ID>/changes/<CHANGE_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the order edit’s ID and the item change’s ID as path parameters.
|
This request requires the order edit’s ID and the item change’s ID as path parameters.
|
||||||
@@ -494,27 +493,27 @@ After an Order Edit is created and all the item changes are added, it must be mo
|
|||||||
To move an Order Edit into the request state, send a request to the [Request Confirmation API Route](https://docs.medusajs.com/api/admin#order-edits_postordereditsordereditrequest):
|
To move an Order Edit into the request state, send a request to the [Request Confirmation API Route](https://docs.medusajs.com/api/admin#order-edits_postordereditsordereditrequest):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orderEdits.requestConfirmation(orderEditId)
|
medusa.admin.orderEdits.requestConfirmation(orderEditId)
|
||||||
.then(({ order_edit }) => {
|
.then(({ order_edit }) => {
|
||||||
console.log(
|
console.log(
|
||||||
order_edit.requested_at,
|
order_edit.requested_at,
|
||||||
order_edit.requested_by
|
order_edit.requested_by
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import {
|
import {
|
||||||
useAdminRequestOrderEditConfirmation,
|
useAdminRequestOrderEditConfirmation,
|
||||||
} from "medusa-react"
|
} from "medusa-react"
|
||||||
|
|
||||||
const OrderEdit = () => {
|
const OrderEdit = () => {
|
||||||
const requestOrderConfirmation =
|
const requestOrderConfirmation =
|
||||||
useAdminRequestOrderEditConfirmation(
|
useAdminRequestOrderEditConfirmation(
|
||||||
orderEditId
|
orderEditId
|
||||||
@@ -525,36 +524,36 @@ const OrderEdit = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default OrderEdit
|
export default OrderEdit
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/order-edits/${orderEditId}/request`, {
|
fetch(`<BACKEND_URL>/admin/order-edits/${orderEditId}/request`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order_edit }) => {
|
.then(({ order_edit }) => {
|
||||||
console.log(order_edit.requested_at, order_edit.requested_by)
|
console.log(order_edit.requested_at, order_edit.requested_by)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/order-edits/<ORDER_EDIT_ID>/request' \
|
curl -L -X POST '<BACKEND_URL>/admin/order-edits/<ORDER_EDIT_ID>/request' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the order edit’s ID as a path parameter.
|
This request requires the order edit’s ID as a path parameter.
|
||||||
@@ -590,22 +589,22 @@ This section covers how the Admin API can be used to force-confirm the Order Edi
|
|||||||
To confirm an Order Edit, send a request to the [Confirm Order Edit API Route](https://docs.medusajs.com/api/admin#order-edits_postordereditsordereditconfirm):
|
To confirm an Order Edit, send a request to the [Confirm Order Edit API Route](https://docs.medusajs.com/api/admin#order-edits_postordereditsordereditconfirm):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orderEdits.confirm(orderEditId)
|
medusa.admin.orderEdits.confirm(orderEditId)
|
||||||
.then(({ order_edit }) => {
|
.then(({ order_edit }) => {
|
||||||
console.log(order_edit.confirmed_at, order_edit.confirmed_by)
|
console.log(order_edit.confirmed_at, order_edit.confirmed_by)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminConfirmOrderEdit } from "medusa-react"
|
import { useAdminConfirmOrderEdit } from "medusa-react"
|
||||||
|
|
||||||
const OrderEdit = () => {
|
const OrderEdit = () => {
|
||||||
const confirmOrderEdit = useAdminConfirmOrderEdit(orderEditId)
|
const confirmOrderEdit = useAdminConfirmOrderEdit(orderEditId)
|
||||||
|
|
||||||
const handleConfirmOrderEdit = () => {
|
const handleConfirmOrderEdit = () => {
|
||||||
@@ -613,36 +612,36 @@ const OrderEdit = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default OrderEdit
|
export default OrderEdit
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/order-edits/${orderEditId}/confirm`, {
|
fetch(`<BACKEND_URL>/admin/order-edits/${orderEditId}/confirm`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order_edit }) => {
|
.then(({ order_edit }) => {
|
||||||
console.log(order_edit.confirmed_at, order_edit.confirmed_by)
|
console.log(order_edit.confirmed_at, order_edit.confirmed_by)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/order-edits/<ORDER_EDIT_ID>/confirm' \
|
curl -L -X POST '<BACKEND_URL>/admin/order-edits/<ORDER_EDIT_ID>/confirm' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request accepts the order edit ID as a path parameter.
|
This request accepts the order edit ID as a path parameter.
|
||||||
@@ -673,22 +672,22 @@ You can learn how to allow customers to authorize payment on the storefront in [
|
|||||||
If the payment is authorized by the customer, it can be captured by sending a request to the [Capture Payment API Route](https://docs.medusajs.com/api/admin#payments_postpaymentspaymentcapture):
|
If the payment is authorized by the customer, it can be captured by sending a request to the [Capture Payment API Route](https://docs.medusajs.com/api/admin#payments_postpaymentspaymentcapture):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.payments.capturePayment(paymentId)
|
medusa.admin.payments.capturePayment(paymentId)
|
||||||
.then(({ payment }) => {
|
.then(({ payment }) => {
|
||||||
console.log(payment.captured_at)
|
console.log(payment.captured_at)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminPaymentsCapturePayment } from "medusa-react"
|
import { useAdminPaymentsCapturePayment } from "medusa-react"
|
||||||
|
|
||||||
const OrderEditPayment = () => {
|
const OrderEditPayment = () => {
|
||||||
const capturePayment = useAdminPaymentsCapturePayment(
|
const capturePayment = useAdminPaymentsCapturePayment(
|
||||||
paymentId
|
paymentId
|
||||||
)
|
)
|
||||||
@@ -698,34 +697,34 @@ const OrderEditPayment = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default OrderEditPayment
|
export default OrderEditPayment
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/payments/${paymentId}/capture`, {
|
fetch(`<BACKEND_URL>/admin/payments/${paymentId}/capture`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ payment }) => {
|
.then(({ payment }) => {
|
||||||
console.log(payment.captured_at)
|
console.log(payment.captured_at)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/payments/<PAYMENT_ID>/capture' \
|
curl -L -X POST '<BACKEND_URL>/admin/payments/<PAYMENT_ID>/capture' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the ID of the payment as a path parameter. The payment can be retrieved from the order by accessing the array property `order.payments`.
|
This request requires the ID of the payment as a path parameter. The payment can be retrieved from the order by accessing the array property `order.payments`.
|
||||||
@@ -739,29 +738,29 @@ When the total after the order edit is less than the original order total, the m
|
|||||||
To refund the difference to the customer, send a request to the [Refund Payment API Route](https://docs.medusajs.com/api/admin#payments_postpaymentspaymentrefunds):
|
To refund the difference to the customer, send a request to the [Refund Payment API Route](https://docs.medusajs.com/api/admin#payments_postpaymentspaymentrefunds):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { RefundReason } from "@medusajs/medusa"
|
import { RefundReason } from "@medusajs/medusa"
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
medusa.admin.payments.refundPayment(paymentId, {
|
medusa.admin.payments.refundPayment(paymentId, {
|
||||||
amount,
|
amount,
|
||||||
reason: RefundReason.DISCOUNT, // for example
|
reason: RefundReason.DISCOUNT, // for example
|
||||||
})
|
})
|
||||||
.then(({ refund }) => {
|
.then(({ refund }) => {
|
||||||
console.log(refund.id)
|
console.log(refund.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminPaymentsRefundPayment } from "medusa-react"
|
import { useAdminPaymentsRefundPayment } from "medusa-react"
|
||||||
import { RefundReason } from "@medusajs/medusa"
|
import { RefundReason } from "@medusajs/medusa"
|
||||||
|
|
||||||
const OrderEditPayment = () => {
|
const OrderEditPayment = () => {
|
||||||
const refundPayment = useAdminPaymentsRefundPayment(paymentId)
|
const refundPayment = useAdminPaymentsRefundPayment(paymentId)
|
||||||
|
|
||||||
const handleRefundPayment =
|
const handleRefundPayment =
|
||||||
@@ -773,16 +772,16 @@ const OrderEditPayment = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default OrderEditPayment
|
export default OrderEditPayment
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/payments/${paymentId}/refund`, {
|
fetch(`<BACKEND_URL>/admin/payments/${paymentId}/refund`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -792,27 +791,27 @@ fetch(`<BACKEND_URL>/admin/payments/${paymentId}/refund`, {
|
|||||||
amount,
|
amount,
|
||||||
reason: "discount",
|
reason: "discount",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ refund }) => {
|
.then(({ refund }) => {
|
||||||
console.log(refund.id)
|
console.log(refund.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/payments/<PAYMENT_ID>/refund' \
|
curl -L -X POST '<BACKEND_URL>/admin/payments/<PAYMENT_ID>/refund' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"amount": 1000,
|
"amount": 1000,
|
||||||
"reason": "discount"
|
"reason": "discount"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the ID of the payment as a path parameter. The payment can be retrieved from the order by accessing the array property `order.payments`.
|
This request requires the ID of the payment as a path parameter. The payment can be retrieved from the order by accessing the array property `order.payments`.
|
||||||
|
|||||||
@@ -61,22 +61,22 @@ 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:
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orders.retrieve(orderId)
|
medusa.admin.orders.retrieve(orderId)
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.claims)
|
console.log(order.claims)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminOrder } from "medusa-react"
|
import { useAdminOrder } from "medusa-react"
|
||||||
|
|
||||||
const Order = () => {
|
const Order = () => {
|
||||||
const {
|
const {
|
||||||
order,
|
order,
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -100,33 +100,33 @@ const Order = () => {
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Order
|
export default Order
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/orders/${orderId}`, {
|
fetch(`<BACKEND_URL>/admin/orders/${orderId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.claims)
|
console.log(order.claims)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/orders/<ORDER_ID>' \
|
curl -L -X GET '<BACKEND_URL>/admin/orders/<ORDER_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the order’s ID as a path parameter.
|
This request requires the order’s ID as a path parameter.
|
||||||
@@ -140,10 +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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orders.createClaim(orderId, {
|
medusa.admin.orders.createClaim(orderId, {
|
||||||
type: "refund",
|
type: "refund",
|
||||||
claim_items: [
|
claim_items: [
|
||||||
{
|
{
|
||||||
@@ -151,19 +151,19 @@ medusa.admin.orders.createClaim(orderId, {
|
|||||||
quantity: 1,
|
quantity: 1,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.claims)
|
console.log(order.claims)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateClaim } from "medusa-react"
|
import { useAdminCreateClaim } from "medusa-react"
|
||||||
|
|
||||||
const CreateClaim = () => {
|
const CreateClaim = () => {
|
||||||
const createClaim = useAdminCreateClaim(orderId)
|
const createClaim = useAdminCreateClaim(orderId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -180,16 +180,16 @@ const CreateClaim = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateClaim
|
export default CreateClaim
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/orders/${orderId}/claims`, {
|
fetch(`<BACKEND_URL>/admin/orders/${orderId}/claims`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -204,21 +204,21 @@ fetch(`<BACKEND_URL>/admin/orders/${orderId}/claims`, {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.claims)
|
console.log(order.claims)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims' \
|
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"type": "refund",
|
"type": "refund",
|
||||||
"claim_items": [
|
"claim_items": [
|
||||||
{
|
{
|
||||||
@@ -226,10 +226,10 @@ curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims' \
|
|||||||
"quantity": 1
|
"quantity": 1
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the order ID to be passed as a path parameter.
|
This API Route requires the order ID to be passed as a path parameter.
|
||||||
@@ -258,24 +258,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orders.updateClaim(orderId, claimId, {
|
medusa.admin.orders.updateClaim(orderId, claimId, {
|
||||||
no_notification: true,
|
no_notification: true,
|
||||||
})
|
})
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.claims)
|
console.log(order.claims)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUpdateClaim } from "medusa-react"
|
import { useAdminUpdateClaim } from "medusa-react"
|
||||||
|
|
||||||
const UpdateClaim = () => {
|
const UpdateClaim = () => {
|
||||||
const updateClaim = useAdminUpdateClaim(orderId)
|
const updateClaim = useAdminUpdateClaim(orderId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -287,16 +287,16 @@ const UpdateClaim = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdateClaim
|
export default UpdateClaim
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/admin/orders/${orderId}/claims/${claimId}`,
|
`<BACKEND_URL>/admin/orders/${orderId}/claims/${claimId}`,
|
||||||
{
|
{
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
@@ -308,26 +308,26 @@ fetch(
|
|||||||
no_notification: true,
|
no_notification: true,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.claims)
|
console.log(order.claims)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"no_notification": true
|
"no_notification": true
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the ID of the order and the claim to be passed as path parameters.
|
This API Route requires the ID of the order and the claim to be passed as path parameters.
|
||||||
@@ -349,23 +349,23 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orders.fulfillClaim(orderId, claimId, {
|
medusa.admin.orders.fulfillClaim(orderId, claimId, {
|
||||||
})
|
})
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.claims)
|
console.log(order.claims)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminFulfillClaim } from "medusa-react"
|
import { useAdminFulfillClaim } from "medusa-react"
|
||||||
|
|
||||||
const FulfillClaim = () => {
|
const FulfillClaim = () => {
|
||||||
const fulfillClaim = useAdminFulfillClaim(orderId)
|
const fulfillClaim = useAdminFulfillClaim(orderId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -376,36 +376,36 @@ const FulfillClaim = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default FulfillClaim
|
export default FulfillClaim
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/orders/${orderId}/claims/${claimId}/fulfillments`, {
|
fetch(`<BACKEND_URL>/admin/orders/${orderId}/claims/${claimId}/fulfillments`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.claims)
|
console.log(order.claims)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>/fulfillments' \
|
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>/fulfillments' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the order and claim IDs as path parameters.
|
This API Route requires the order and claim IDs as path parameters.
|
||||||
@@ -419,24 +419,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orders.createClaimShipment(orderId, claimId, {
|
medusa.admin.orders.createClaimShipment(orderId, claimId, {
|
||||||
fulfillment_id,
|
fulfillment_id,
|
||||||
})
|
})
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.claims)
|
console.log(order.claims)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateClaimShipment } from "medusa-react"
|
import { useAdminCreateClaimShipment } from "medusa-react"
|
||||||
|
|
||||||
const CreateShipment = () => {
|
const CreateShipment = () => {
|
||||||
const createShipment = useAdminCreateClaimShipment(orderId)
|
const createShipment = useAdminCreateClaimShipment(orderId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -448,18 +448,18 @@ const CreateShipment = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateShipment
|
export default CreateShipment
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/orders/${orderId}/claims/${claimId}/shipments`, {
|
fetch(`<BACKEND_URL>/admin/orders/${orderId}/claims/${claimId}/shipments`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -468,26 +468,26 @@ fetch(`<BACKEND_URL>/admin/orders/${orderId}/claims/${claimId}/shipments`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
fulfillment_id,
|
fulfillment_id,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.claims)
|
console.log(order.claims)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>/shipments' \
|
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>/shipments' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"fulfillment_id": "<FUL_ID>"
|
"fulfillment_id": "<FUL_ID>"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the order and claim IDs as path parameters.
|
This API Route requires the order and claim IDs as path parameters.
|
||||||
@@ -511,26 +511,26 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orders.cancelClaimFulfillment(
|
medusa.admin.orders.cancelClaimFulfillment(
|
||||||
orderId,
|
orderId,
|
||||||
claimId,
|
claimId,
|
||||||
fulfillmentId
|
fulfillmentId
|
||||||
)
|
)
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.claims)
|
console.log(order.claims)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCancelClaimFulfillment } from "medusa-react"
|
import { useAdminCancelClaimFulfillment } from "medusa-react"
|
||||||
|
|
||||||
const CancelFulfillment = () => {
|
const CancelFulfillment = () => {
|
||||||
const cancelFulfillment = useAdminCancelClaimFulfillment(
|
const cancelFulfillment = useAdminCancelClaimFulfillment(
|
||||||
orderId
|
orderId
|
||||||
)
|
)
|
||||||
@@ -544,36 +544,36 @@ const CancelFulfillment = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CancelFulfillment
|
export default CancelFulfillment
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/orders/${orderId}/claims/${claimId}/fulfillments/${fulfillmentId}/cancel`, {
|
fetch(`<BACKEND_URL>/admin/orders/${orderId}/claims/${claimId}/fulfillments/${fulfillmentId}/cancel`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.claims)
|
console.log(order.claims)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>/fulfillments/<FUL_ID>/cancel' \
|
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>/fulfillments/<FUL_ID>/cancel' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the order, claim, and fulfillment IDs to be passed as path parameters.
|
This API Route requires the order, claim, and fulfillment IDs to be passed as path parameters.
|
||||||
@@ -595,22 +595,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orders.cancelClaim(orderId, claimId)
|
medusa.admin.orders.cancelClaim(orderId, claimId)
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.claims)
|
console.log(order.claims)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCancelClaim } from "medusa-react"
|
import { useAdminCancelClaim } from "medusa-react"
|
||||||
|
|
||||||
const CancelClaim = () => {
|
const CancelClaim = () => {
|
||||||
const cancelClaim = useAdminCancelClaim(orderId)
|
const cancelClaim = useAdminCancelClaim(orderId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -619,36 +619,36 @@ const CancelClaim = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CancelClaim
|
export default CancelClaim
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/orders/${orderId}/claims/${claimId}/cancel`, {
|
fetch(`<BACKEND_URL>/admin/orders/${orderId}/claims/${claimId}/cancel`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.claims)
|
console.log(order.claims)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>/cancel' \
|
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>/cancel' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the order and claim IDs as path parameters.
|
This API Route requires the order and claim IDs as path parameters.
|
||||||
|
|||||||
@@ -55,22 +55,22 @@ You can learn more about [authenticating as an admin user in the API reference](
|
|||||||
You can list draft orders by sending a request to the [List Draft Orders API Route](https://docs.medusajs.com/api/admin#draft-orders_getdraftorders):
|
You can list draft orders by sending a request to the [List Draft Orders API Route](https://docs.medusajs.com/api/admin#draft-orders_getdraftorders):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.draftOrders.list()
|
medusa.admin.draftOrders.list()
|
||||||
.then(({ draft_orders, limit, offset, count }) => {
|
.then(({ draft_orders, limit, offset, count }) => {
|
||||||
console.log(draft_orders.length)
|
console.log(draft_orders.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDraftOrders } from "medusa-react"
|
import { useAdminDraftOrders } from "medusa-react"
|
||||||
|
|
||||||
const DraftOrders = () => {
|
const DraftOrders = () => {
|
||||||
const { draft_orders, isLoading } = useAdminDraftOrders()
|
const { draft_orders, isLoading } = useAdminDraftOrders()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -88,33 +88,33 @@ const DraftOrders = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DraftOrders
|
export default DraftOrders
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/draft-orders`, {
|
fetch(`<BACKEND_URL>/admin/draft-orders`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ draft_orders, limit, offset, count }) => {
|
.then(({ draft_orders, limit, offset, count }) => {
|
||||||
console.log(draft_orders.length)
|
console.log(draft_orders.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/draft-orders' \
|
curl -L -X GET '<BACKEND_URL>/admin/draft-orders' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route doesn't require any path or query parameters. You can pass search or pagination query parameters as explained in the [API reference](https://docs.medusajs.com/api/admin#draft-orders_getdraftorders).
|
This API Route doesn't require any path or query parameters. You can pass search or pagination query parameters as explained in the [API reference](https://docs.medusajs.com/api/admin#draft-orders_getdraftorders).
|
||||||
@@ -128,10 +128,10 @@ The request returns an array of draft order objects along with [pagination param
|
|||||||
You can create a draft order by sending a request to the [Create Draft Order API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftorders):
|
You can create a draft order by sending a request to the [Create Draft Order API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftorders):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.draftOrders.create({
|
medusa.admin.draftOrders.create({
|
||||||
email,
|
email,
|
||||||
region_id,
|
region_id,
|
||||||
items: [
|
items: [
|
||||||
@@ -154,19 +154,19 @@ medusa.admin.draftOrders.create({
|
|||||||
price,
|
price,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.then(({ draft_order }) => {
|
.then(({ draft_order }) => {
|
||||||
console.log(draft_order.id)
|
console.log(draft_order.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateDraftOrder } from "medusa-react"
|
import { useAdminCreateDraftOrder } from "medusa-react"
|
||||||
|
|
||||||
const CreateDraftOrder = () => {
|
const CreateDraftOrder = () => {
|
||||||
const createDraftOrder = useAdminCreateDraftOrder()
|
const createDraftOrder = useAdminCreateDraftOrder()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -198,16 +198,16 @@ const CreateDraftOrder = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateDraftOrder
|
export default CreateDraftOrder
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/draft-orders`, {
|
fetch(`<BACKEND_URL>/admin/draft-orders`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -237,21 +237,21 @@ fetch(`<BACKEND_URL>/admin/draft-orders`, {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ draft_order }) => {
|
.then(({ draft_order }) => {
|
||||||
console.log(draft_order.id)
|
console.log(draft_order.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/draft-orders' \
|
curl -L -X POST '<BACKEND_URL>/admin/draft-orders' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"email": "<EMAIL>",
|
"email": "<EMAIL>",
|
||||||
"region_id": "<REGION_ID>",
|
"region_id": "<REGION_ID>",
|
||||||
"items": [
|
"items": [
|
||||||
@@ -271,10 +271,10 @@ curl -L -X POST '<BACKEND_URL>/admin/draft-orders' \
|
|||||||
"price": 1000
|
"price": 1000
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the following request body parameters:
|
This API Route requires the following request body parameters:
|
||||||
@@ -301,22 +301,22 @@ The request returns the created draft order as an object.
|
|||||||
You can retrieve a draft order by sending a request to the [Get Draft Order API Route](https://docs.medusajs.com/api/admin#draft-orders_getdraftordersdraftorder):
|
You can retrieve a draft order by sending a request to the [Get Draft Order API Route](https://docs.medusajs.com/api/admin#draft-orders_getdraftordersdraftorder):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.draftOrders.retrieve(draftOrderId)
|
medusa.admin.draftOrders.retrieve(draftOrderId)
|
||||||
.then(({ draft_order }) => {
|
.then(({ draft_order }) => {
|
||||||
console.log(draft_order.id)
|
console.log(draft_order.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDraftOrder } from "medusa-react"
|
import { useAdminDraftOrder } from "medusa-react"
|
||||||
|
|
||||||
const DraftOrder = () => {
|
const DraftOrder = () => {
|
||||||
const {
|
const {
|
||||||
draft_order,
|
draft_order,
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -329,33 +329,33 @@ const DraftOrder = () => {
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DraftOrder
|
export default DraftOrder
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/draft-orders/${draftOrderId}`, {
|
fetch(`<BACKEND_URL>/admin/draft-orders/${draftOrderId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ draft_order }) => {
|
.then(({ draft_order }) => {
|
||||||
console.log(draft_order.id)
|
console.log(draft_order.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/draft-orders/<DRAFT_ORDER_ID>' \
|
curl -L -X GET '<BACKEND_URL>/admin/draft-orders/<DRAFT_ORDER_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the draft order’s ID as a path parameter.
|
This API Route requires the draft order’s ID as a path parameter.
|
||||||
@@ -369,24 +369,24 @@ The request returns the draft order as an object.
|
|||||||
You can update a draft order by sending a request to the [Update Draft Order API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersdraftorder):
|
You can update a draft order by sending a request to the [Update Draft Order API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersdraftorder):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.draftOrders.update(draftOrderId, {
|
medusa.admin.draftOrders.update(draftOrderId, {
|
||||||
email: "user@example.com",
|
email: "user@example.com",
|
||||||
})
|
})
|
||||||
.then(({ draft_order }) => {
|
.then(({ draft_order }) => {
|
||||||
console.log(draft_order.id)
|
console.log(draft_order.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUpdateDraftOrder } from "medusa-react"
|
import { useAdminUpdateDraftOrder } from "medusa-react"
|
||||||
|
|
||||||
const UpdateDraftOrder = () => {
|
const UpdateDraftOrder = () => {
|
||||||
const updateDraftOrder = useAdminUpdateDraftOrder(
|
const updateDraftOrder = useAdminUpdateDraftOrder(
|
||||||
draftOrderId
|
draftOrderId
|
||||||
)
|
)
|
||||||
@@ -399,16 +399,16 @@ const UpdateDraftOrder = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdateDraftOrder
|
export default UpdateDraftOrder
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/draft-orders/${draftOrderId}`, {
|
fetch(`<BACKEND_URL>/admin/draft-orders/${draftOrderId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -417,26 +417,26 @@ fetch(`<BACKEND_URL>/admin/draft-orders/${draftOrderId}`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
email: "user@example.com",
|
email: "user@example.com",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ draft_order }) => {
|
.then(({ draft_order }) => {
|
||||||
console.log(draft_order.id)
|
console.log(draft_order.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/draft-orders/<DRAFT_ORDER_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/draft-orders/<DRAFT_ORDER_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"email": "user@example.com"
|
"email": "user@example.com"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the draft order’s ID as a path parameter.
|
This API Route requires the draft order’s ID as a path parameter.
|
||||||
@@ -454,24 +454,24 @@ The request returns the updated draft order as an object.
|
|||||||
You can add line items to a draft order by sending a request to the [Create Line Items API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersdraftorderlineitems):
|
You can add line items to a draft order by sending a request to the [Create Line Items API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersdraftorderlineitems):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.draftOrders.addLineItem(draftOrderId, {
|
medusa.admin.draftOrders.addLineItem(draftOrderId, {
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
})
|
})
|
||||||
.then(({ draft_order }) => {
|
.then(({ draft_order }) => {
|
||||||
console.log(draft_order.cart.items)
|
console.log(draft_order.cart.items)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDraftOrderAddLineItem } from "medusa-react"
|
import { useAdminDraftOrderAddLineItem } from "medusa-react"
|
||||||
|
|
||||||
const AddLineItem = () => {
|
const AddLineItem = () => {
|
||||||
const addLineItem = useAdminDraftOrderAddLineItem(
|
const addLineItem = useAdminDraftOrderAddLineItem(
|
||||||
draftOrderId
|
draftOrderId
|
||||||
)
|
)
|
||||||
@@ -484,18 +484,18 @@ const AddLineItem = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AddLineItem
|
export default AddLineItem
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/draft-orders/${draftOrderId}/line-items`, {
|
fetch(`<BACKEND_URL>/admin/draft-orders/${draftOrderId}/line-items`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -509,21 +509,21 @@ fetch(`<BACKEND_URL>/admin/draft-orders/${draftOrderId}/line-items`, {
|
|||||||
.then(({ draft_order }) => {
|
.then(({ draft_order }) => {
|
||||||
console.log(draft_order.cart.items)
|
console.log(draft_order.cart.items)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/draft-orders/<DRAFT_ORDER_ID>/line-items' \
|
curl -L -X POST '<BACKEND_URL>/admin/draft-orders/<DRAFT_ORDER_ID>/line-items' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"quantity": 1
|
"quantity": 1
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the ID of the draft order as a path parameter.
|
This API Route requires the ID of the draft order as a path parameter.
|
||||||
@@ -544,24 +544,24 @@ The request returns the updated draft order as an object. You can access the dra
|
|||||||
You can update a line item by sending a request to the [Update Line Item API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersdraftorderlineitemsitem):
|
You can update a line item by sending a request to the [Update Line Item API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersdraftorderlineitemsitem):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.draftOrders.updateLineItem(draftOrderId, itemId, {
|
medusa.admin.draftOrders.updateLineItem(draftOrderId, itemId, {
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
})
|
})
|
||||||
.then(({ draft_order }) => {
|
.then(({ draft_order }) => {
|
||||||
console.log(draft_order.cart.items)
|
console.log(draft_order.cart.items)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDraftOrderUpdateLineItem } from "medusa-react"
|
import { useAdminDraftOrderUpdateLineItem } from "medusa-react"
|
||||||
|
|
||||||
const UpdateLineItem = () => {
|
const UpdateLineItem = () => {
|
||||||
const updateLineItem = useAdminDraftOrderUpdateLineItem(
|
const updateLineItem = useAdminDraftOrderUpdateLineItem(
|
||||||
draftOrderId
|
draftOrderId
|
||||||
)
|
)
|
||||||
@@ -575,18 +575,18 @@ const UpdateLineItem = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdateLineItem
|
export default UpdateLineItem
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/draft-orders/${draftOrderId}/line-items/${itemId}`, {
|
fetch(`<BACKEND_URL>/admin/draft-orders/${draftOrderId}/line-items/${itemId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -595,26 +595,26 @@ fetch(`<BACKEND_URL>/admin/draft-orders/${draftOrderId}/line-items/${itemId}`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ draft_order }) => {
|
.then(({ draft_order }) => {
|
||||||
console.log(draft_order.cart.items)
|
console.log(draft_order.cart.items)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/draft-orders/<DRAFT_ORDER_ID>/line-items/<ITEM_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/draft-orders/<DRAFT_ORDER_ID>/line-items/<ITEM_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"quantity": 1
|
"quantity": 1
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the draft order and line item’s IDs as path parameters.
|
This API Route requires the draft order and line item’s IDs as path parameters.
|
||||||
@@ -628,22 +628,22 @@ The request returns the updated draft order as an object. You can access the dra
|
|||||||
You can delete a line item by sending a request to the [Delete Line Item API Route](https://docs.medusajs.com/api/admin#draft-orders_deletedraftordersdraftorderlineitemsitem):
|
You can delete a line item by sending a request to the [Delete Line Item API Route](https://docs.medusajs.com/api/admin#draft-orders_deletedraftordersdraftorderlineitemsitem):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.draftOrders.removeLineItem(draftOrderId, itemId)
|
medusa.admin.draftOrders.removeLineItem(draftOrderId, itemId)
|
||||||
.then(({ draft_order }) => {
|
.then(({ draft_order }) => {
|
||||||
console.log(draft_order.cart.items)
|
console.log(draft_order.cart.items)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDraftOrderRemoveLineItem } from "medusa-react"
|
import { useAdminDraftOrderRemoveLineItem } from "medusa-react"
|
||||||
|
|
||||||
const DeleteLineItem = () => {
|
const DeleteLineItem = () => {
|
||||||
const deleteLineItem = useAdminDraftOrderRemoveLineItem(
|
const deleteLineItem = useAdminDraftOrderRemoveLineItem(
|
||||||
draftOrderId
|
draftOrderId
|
||||||
)
|
)
|
||||||
@@ -654,36 +654,36 @@ const DeleteLineItem = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DeleteLineItem
|
export default DeleteLineItem
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/draft-orders/${draftOrderId}/line-items/${itemId}`, {
|
fetch(`<BACKEND_URL>/admin/draft-orders/${draftOrderId}/line-items/${itemId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ draft_order }) => {
|
.then(({ draft_order }) => {
|
||||||
console.log(draft_order.cart.items)
|
console.log(draft_order.cart.items)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/draft-orders/<DRAFT_ORDER_ID>/line-items/<ITEM_ID>' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/draft-orders/<DRAFT_ORDER_ID>/line-items/<ITEM_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the draft order and line item’s IDs as path parameters.
|
This API Route requires the draft order and line item’s IDs as path parameters.
|
||||||
@@ -699,22 +699,22 @@ Registering the draft order’s payment leads to authorizing and capturing the p
|
|||||||
You can register the draft order payment by sending a request to the [Register Draft Order Payment API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersdraftorderregisterpayment):
|
You can register the draft order payment by sending a request to the [Register Draft Order Payment API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersdraftorderregisterpayment):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.draftOrders.markPaid(draftOrderId)
|
medusa.admin.draftOrders.markPaid(draftOrderId)
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.id)
|
console.log(order.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDraftOrderRegisterPayment } from "medusa-react"
|
import { useAdminDraftOrderRegisterPayment } from "medusa-react"
|
||||||
|
|
||||||
const RegisterPayment = () => {
|
const RegisterPayment = () => {
|
||||||
const registerPayment = useAdminDraftOrderRegisterPayment(
|
const registerPayment = useAdminDraftOrderRegisterPayment(
|
||||||
draftOrderId
|
draftOrderId
|
||||||
)
|
)
|
||||||
@@ -725,34 +725,34 @@ const RegisterPayment = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default RegisterPayment
|
export default RegisterPayment
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/draft-orders/${draftOrderId}/pay`, {
|
fetch(`<BACKEND_URL>/admin/draft-orders/${draftOrderId}/pay`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.id)
|
console.log(order.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/draft-orders/<DRAFT_ORDER_ID>/pay' \
|
curl -L -X POST '<BACKEND_URL>/admin/draft-orders/<DRAFT_ORDER_ID>/pay' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the draft order’s ID as a path parameter.
|
This API Route requires the draft order’s ID as a path parameter.
|
||||||
@@ -766,22 +766,22 @@ The request returns the order created from the draft order as an object.
|
|||||||
You can delete a draft order by sending a request to the [Delete Draft Order API Route](https://docs.medusajs.com/api/admin#draft-orders_deletedraftordersdraftorder):
|
You can delete a draft order by sending a request to the [Delete Draft Order API Route](https://docs.medusajs.com/api/admin#draft-orders_deletedraftordersdraftorder):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.draftOrders.delete(draftOrderId)
|
medusa.admin.draftOrders.delete(draftOrderId)
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDeleteDraftOrder } from "medusa-react"
|
import { useAdminDeleteDraftOrder } from "medusa-react"
|
||||||
|
|
||||||
const DeleteDraftOrder = () => {
|
const DeleteDraftOrder = () => {
|
||||||
const deleteDraftOrder = useAdminDeleteDraftOrder(
|
const deleteDraftOrder = useAdminDeleteDraftOrder(
|
||||||
draftOrderId
|
draftOrderId
|
||||||
)
|
)
|
||||||
@@ -792,34 +792,34 @@ const DeleteDraftOrder = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DeleteDraftOrder
|
export default DeleteDraftOrder
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/draft-orders/${draftOrderId}`, {
|
fetch(`<BACKEND_URL>/admin/draft-orders/${draftOrderId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/draft-orders/<DRAFT_ORDER_ID>' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/draft-orders/<DRAFT_ORDER_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the draft order’s ID as a path parameter.
|
This API Route requires the draft order’s ID as a path parameter.
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -60,22 +60,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.returnReasons.list()
|
medusa.admin.returnReasons.list()
|
||||||
.then(({ return_reasons }) => {
|
.then(({ return_reasons }) => {
|
||||||
console.log(return_reasons.length)
|
console.log(return_reasons.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminReturnReasons } from "medusa-react"
|
import { useAdminReturnReasons } from "medusa-react"
|
||||||
|
|
||||||
const ReturnReasons = () => {
|
const ReturnReasons = () => {
|
||||||
const { return_reasons, isLoading } = useAdminReturnReasons()
|
const { return_reasons, isLoading } = useAdminReturnReasons()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -95,33 +95,33 @@ const ReturnReasons = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ReturnReasons
|
export default ReturnReasons
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/return-reasons`, {
|
fetch(`<BACKEND_URL>/admin/return-reasons`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ return_reasons }) => {
|
.then(({ return_reasons }) => {
|
||||||
console.log(return_reasons.length)
|
console.log(return_reasons.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/return-reasons' \
|
curl -L -X GET '<BACKEND_URL>/admin/return-reasons' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route doesn't require or accept any path or query parameters.
|
This API Route doesn't require or accept any path or query parameters.
|
||||||
@@ -133,25 +133,25 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.returnReasons.create({
|
medusa.admin.returnReasons.create({
|
||||||
label: "Damaged",
|
label: "Damaged",
|
||||||
value: "damaged",
|
value: "damaged",
|
||||||
})
|
})
|
||||||
.then(({ return_reason }) => {
|
.then(({ return_reason }) => {
|
||||||
console.log(return_reason.id)
|
console.log(return_reason.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateReturnReason } from "medusa-react"
|
import { useAdminCreateReturnReason } from "medusa-react"
|
||||||
|
|
||||||
const CreateReturnReason = () => {
|
const CreateReturnReason = () => {
|
||||||
const createReturnReason = useAdminCreateReturnReason()
|
const createReturnReason = useAdminCreateReturnReason()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -163,16 +163,16 @@ const CreateReturnReason = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateReturnReason
|
export default CreateReturnReason
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/return-reasons`, {
|
fetch(`<BACKEND_URL>/admin/return-reasons`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -182,27 +182,27 @@ fetch(`<BACKEND_URL>/admin/return-reasons`, {
|
|||||||
label: "Damaged",
|
label: "Damaged",
|
||||||
value: "damaged",
|
value: "damaged",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ return_reason }) => {
|
.then(({ return_reason }) => {
|
||||||
console.log(return_reason.id)
|
console.log(return_reason.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/return-reasons' \
|
curl -L -X POST '<BACKEND_URL>/admin/return-reasons' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"label": "Damaged",
|
"label": "Damaged",
|
||||||
"value": "damaged"
|
"value": "damaged"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the following request body parameters:
|
This API Route requires the following request body parameters:
|
||||||
@@ -219,24 +219,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.returnReasons.update(returnReasonId, {
|
medusa.admin.returnReasons.update(returnReasonId, {
|
||||||
label: "Damaged",
|
label: "Damaged",
|
||||||
})
|
})
|
||||||
.then(({ return_reason }) => {
|
.then(({ return_reason }) => {
|
||||||
console.log(return_reason.id)
|
console.log(return_reason.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUpdateReturnReason } from "medusa-react"
|
import { useAdminUpdateReturnReason } from "medusa-react"
|
||||||
|
|
||||||
const UpdateReturnReason = () => {
|
const UpdateReturnReason = () => {
|
||||||
const updateReturnReason = useAdminUpdateReturnReason(
|
const updateReturnReason = useAdminUpdateReturnReason(
|
||||||
returnReasonId
|
returnReasonId
|
||||||
)
|
)
|
||||||
@@ -249,16 +249,16 @@ const UpdateReturnReason = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdateReturnReason
|
export default UpdateReturnReason
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/return-reasons/${returnReasonId}`, {
|
fetch(`<BACKEND_URL>/admin/return-reasons/${returnReasonId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -267,26 +267,26 @@ fetch(`<BACKEND_URL>/admin/return-reasons/${returnReasonId}`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
label: "Damaged",
|
label: "Damaged",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ return_reason }) => {
|
.then(({ return_reason }) => {
|
||||||
console.log(return_reason.id)
|
console.log(return_reason.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/return-reasons/<REASON_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/return-reasons/<REASON_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"label": "Damaged"
|
"label": "Damaged"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the return reason ID to be passed as a path parameter.
|
This API Route requires the return reason ID to be passed as a path parameter.
|
||||||
@@ -300,22 +300,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.returnReasons.delete(returnReasonId)
|
medusa.admin.returnReasons.delete(returnReasonId)
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDeleteReturnReason } from "medusa-react"
|
import { useAdminDeleteReturnReason } from "medusa-react"
|
||||||
|
|
||||||
const DeleteReturnReason = () => {
|
const DeleteReturnReason = () => {
|
||||||
const deleteReturnReason = useAdminDeleteReturnReason(
|
const deleteReturnReason = useAdminDeleteReturnReason(
|
||||||
returnReasonId
|
returnReasonId
|
||||||
)
|
)
|
||||||
@@ -326,34 +326,34 @@ const DeleteReturnReason = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DeleteReturnReason
|
export default DeleteReturnReason
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/return-reasons/${returnReasonId}`, {
|
fetch(`<BACKEND_URL>/admin/return-reasons/${returnReasonId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/return-reasons/<REASON_ID>' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/return-reasons/<REASON_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the return reason ID as a path parameter.
|
This API Route requires the return reason ID as a path parameter.
|
||||||
@@ -377,22 +377,22 @@ 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:
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orders.retrieve(orderId)
|
medusa.admin.orders.retrieve(orderId)
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.returns)
|
console.log(order.returns)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminOrder } from "medusa-react"
|
import { useAdminOrder } from "medusa-react"
|
||||||
|
|
||||||
const Order = () => {
|
const Order = () => {
|
||||||
const {
|
const {
|
||||||
order,
|
order,
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -416,33 +416,33 @@ const Order = () => {
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Order
|
export default Order
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/orders/${orderId}`, {
|
fetch(`<BACKEND_URL>/admin/orders/${orderId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.returns)
|
console.log(order.returns)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/orders/<ORDER_ID>' \
|
curl -L -X GET '<BACKEND_URL>/admin/orders/<ORDER_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the order ID as a path parameter.
|
This API Route requires the order ID as a path parameter.
|
||||||
@@ -470,29 +470,29 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.returns.receive(return_id, {
|
medusa.admin.returns.receive(return_id, {
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
item_id,
|
item_id,
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
console.log(data.return.id)
|
console.log(data.return.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminReceiveReturn } from "medusa-react"
|
import { useAdminReceiveReturn } from "medusa-react"
|
||||||
|
|
||||||
const ReceiveReturn = () => {
|
const ReceiveReturn = () => {
|
||||||
const receiveReturn = useAdminReceiveReturn(
|
const receiveReturn = useAdminReceiveReturn(
|
||||||
returnId
|
returnId
|
||||||
)
|
)
|
||||||
@@ -505,16 +505,16 @@ const ReceiveReturn = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ReceiveReturn
|
export default ReceiveReturn
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/returns/${returnId}/receive`, {
|
fetch(`<BACKEND_URL>/admin/returns/${returnId}/receive`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -528,31 +528,31 @@ fetch(`<BACKEND_URL>/admin/returns/${returnId}/receive`, {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
console.log(data.return.id)
|
console.log(data.return.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/returns/<RETURN_ID>/receive' \
|
curl -L -X POST '<BACKEND_URL>/admin/returns/<RETURN_ID>/receive' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"item_id": "<ITEM_ID>",
|
"item_id": "<ITEM_ID>",
|
||||||
"quantity": 1
|
"quantity": 1
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the ID of the return as a path parameter.
|
This API Route requires the ID of the return as a path parameter.
|
||||||
@@ -579,22 +579,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.returns.cancel(returnId)
|
medusa.admin.returns.cancel(returnId)
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.returns)
|
console.log(order.returns)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCancelReturn } from "medusa-react"
|
import { useAdminCancelReturn } from "medusa-react"
|
||||||
|
|
||||||
const CancelReturn = () => {
|
const CancelReturn = () => {
|
||||||
const cancelReturn = useAdminCancelReturn(
|
const cancelReturn = useAdminCancelReturn(
|
||||||
returnId
|
returnId
|
||||||
)
|
)
|
||||||
@@ -605,34 +605,34 @@ const CancelReturn = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CancelReturn
|
export default CancelReturn
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/returns/${returnId}/cancel`, {
|
fetch(`<BACKEND_URL>/admin/returns/${returnId}/cancel`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.returns)
|
console.log(order.returns)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/returns/<RETURN_ID>/cancel' \
|
curl -L -X POST '<BACKEND_URL>/admin/returns/<RETURN_ID>/cancel' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the return ID to be passed as a path parameter.
|
This API Route requires the return ID to be passed as a path parameter.
|
||||||
|
|||||||
@@ -68,22 +68,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orders.retrieve(orderId)
|
medusa.admin.orders.retrieve(orderId)
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.swaps)
|
console.log(order.swaps)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminOrder } from "medusa-react"
|
import { useAdminOrder } from "medusa-react"
|
||||||
|
|
||||||
const Order = () => {
|
const Order = () => {
|
||||||
const {
|
const {
|
||||||
order,
|
order,
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -106,33 +106,33 @@ const Order = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Order
|
export default Order
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/orders/${orderId}`, {
|
fetch(`<BACKEND_URL>/admin/orders/${orderId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.swaps)
|
console.log(order.swaps)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/orders/<ORDER_ID>' \
|
curl -L -X GET '<BACKEND_URL>/admin/orders/<ORDER_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the order ID to be passed as a path parameter.
|
This API Route requires the order ID to be passed as a path parameter.
|
||||||
@@ -148,22 +148,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orders.processSwapPayment(orderId, swapId)
|
medusa.admin.orders.processSwapPayment(orderId, swapId)
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.swaps)
|
console.log(order.swaps)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminProcessSwapPayment } from "medusa-react"
|
import { useAdminProcessSwapPayment } from "medusa-react"
|
||||||
|
|
||||||
const ProcessPayment = () => {
|
const ProcessPayment = () => {
|
||||||
const processPayment = useAdminProcessSwapPayment(
|
const processPayment = useAdminProcessSwapPayment(
|
||||||
orderId
|
orderId
|
||||||
)
|
)
|
||||||
@@ -174,36 +174,36 @@ const ProcessPayment = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ProcessPayment
|
export default ProcessPayment
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/orders/${orderId}/swaps/${swapId}/process-payment`, {
|
fetch(`<BACKEND_URL>/admin/orders/${orderId}/swaps/${swapId}/process-payment`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.swaps)
|
console.log(order.swaps)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/swaps/<SWAP_ID>/process-payment' \
|
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/swaps/<SWAP_ID>/process-payment' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the order ID and the swap ID as path parameters.
|
This API Route requires the order ID and the swap ID as path parameters.
|
||||||
@@ -223,23 +223,23 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orders.fulfillSwap(orderId, swapId, {
|
medusa.admin.orders.fulfillSwap(orderId, swapId, {
|
||||||
})
|
})
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.swaps)
|
console.log(order.swaps)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminFulfillSwap } from "medusa-react"
|
import { useAdminFulfillSwap } from "medusa-react"
|
||||||
|
|
||||||
const FulfillSwap = () => {
|
const FulfillSwap = () => {
|
||||||
const fulfillSwap = useAdminFulfillSwap(
|
const fulfillSwap = useAdminFulfillSwap(
|
||||||
orderId
|
orderId
|
||||||
)
|
)
|
||||||
@@ -252,36 +252,36 @@ const FulfillSwap = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default FulfillSwap
|
export default FulfillSwap
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/orders/${orderId}/swaps/${swapId}/fulfillments`, {
|
fetch(`<BACKEND_URL>/admin/orders/${orderId}/swaps/${swapId}/fulfillments`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.swaps)
|
console.log(order.swaps)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/swaps/<SWAP_ID>/fulfillments' \
|
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/swaps/<SWAP_ID>/fulfillments' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the order ID and swap ID as path parameters.
|
This API Route requires the order ID and swap ID as path parameters.
|
||||||
@@ -295,24 +295,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orders.createSwapShipment(orderId, swapId, {
|
medusa.admin.orders.createSwapShipment(orderId, swapId, {
|
||||||
fulfillment_id,
|
fulfillment_id,
|
||||||
})
|
})
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.swaps)
|
console.log(order.swaps)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateSwapShipment } from "medusa-react"
|
import { useAdminCreateSwapShipment } from "medusa-react"
|
||||||
|
|
||||||
const CreateShipment = () => {
|
const CreateShipment = () => {
|
||||||
const createShipment = useAdminCreateSwapShipment(
|
const createShipment = useAdminCreateSwapShipment(
|
||||||
orderId
|
orderId
|
||||||
)
|
)
|
||||||
@@ -326,18 +326,18 @@ const CreateShipment = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateShipment
|
export default CreateShipment
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/orders/${orderId}/swaps/${swapId}/shipments`, {
|
fetch(`<BACKEND_URL>/admin/orders/${orderId}/swaps/${swapId}/shipments`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -346,26 +346,26 @@ fetch(`<BACKEND_URL>/admin/orders/${orderId}/swaps/${swapId}/shipments`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
fulfillment_id,
|
fulfillment_id,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.swaps)
|
console.log(order.swaps)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/swaps/<SWAP_ID>/shipments' \
|
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/swaps/<SWAP_ID>/shipments' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'\
|
-H 'Authorization: Bearer <API_TOKEN>'\
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"fulfillment_id": "<FUL_ID>"
|
"fulfillment_id": "<FUL_ID>"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route expects the order and swap IDs to be passed as path parameters.
|
This API Route expects the order and swap IDs to be passed as path parameters.
|
||||||
@@ -389,26 +389,26 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orders.cancelSwapFulfillment(
|
medusa.admin.orders.cancelSwapFulfillment(
|
||||||
orderId,
|
orderId,
|
||||||
swapId,
|
swapId,
|
||||||
fulfillmentId
|
fulfillmentId
|
||||||
)
|
)
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.swaps)
|
console.log(order.swaps)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCancelSwapFulfillment } from "medusa-react"
|
import { useAdminCancelSwapFulfillment } from "medusa-react"
|
||||||
|
|
||||||
const CancelFulfillment = () => {
|
const CancelFulfillment = () => {
|
||||||
const cancelFulfillment = useAdminCancelSwapFulfillment(
|
const cancelFulfillment = useAdminCancelSwapFulfillment(
|
||||||
orderId
|
orderId
|
||||||
)
|
)
|
||||||
@@ -422,36 +422,36 @@ const CancelFulfillment = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CancelFulfillment
|
export default CancelFulfillment
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/orders/${orderId}/swaps/${swapId}/shipments/${fulfillmentId}/cancel`, {
|
fetch(`<BACKEND_URL>/admin/orders/${orderId}/swaps/${swapId}/shipments/${fulfillmentId}/cancel`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.swaps)
|
console.log(order.swaps)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/swaps/<SWAP_ID>/fulfillments/<FUL_ID>/cancel' \
|
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/swaps/<SWAP_ID>/fulfillments/<FUL_ID>/cancel' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the order, swap, and fulfillment IDs to be passed as path parameters.
|
This API Route requires the order, swap, and fulfillment IDs to be passed as path parameters.
|
||||||
@@ -473,22 +473,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orders.cancelSwap(orderId, swapId)
|
medusa.admin.orders.cancelSwap(orderId, swapId)
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.swaps)
|
console.log(order.swaps)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCancelSwap } from "medusa-react"
|
import { useAdminCancelSwap } from "medusa-react"
|
||||||
|
|
||||||
const CancelSwap = () => {
|
const CancelSwap = () => {
|
||||||
const cancelSwap = useAdminCancelSwap(
|
const cancelSwap = useAdminCancelSwap(
|
||||||
orderId
|
orderId
|
||||||
)
|
)
|
||||||
@@ -499,18 +499,18 @@ const CancelSwap = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CancelSwap
|
export default CancelSwap
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/orders/${orderId}/swaps/${swapId}/cancel`, {
|
fetch(`<BACKEND_URL>/admin/orders/${orderId}/swaps/${swapId}/cancel`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
})
|
})
|
||||||
@@ -518,17 +518,17 @@ fetch(`<BACKEND_URL>/admin/orders/${orderId}/swaps/${swapId}/cancel`, {
|
|||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.swaps)
|
console.log(order.swaps)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/swaps/<SWAP_ID>/cancel' \
|
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/swaps/<SWAP_ID>/cancel' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the order and swap IDs as path parameters.
|
This API Route requires the order and swap IDs as path parameters.
|
||||||
|
|||||||
@@ -60,24 +60,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.shippingOptions.list({
|
medusa.shippingOptions.list({
|
||||||
is_return: "true",
|
is_return: "true",
|
||||||
})
|
})
|
||||||
.then(({ shipping_options }) => {
|
.then(({ shipping_options }) => {
|
||||||
console.log(shipping_options.length)
|
console.log(shipping_options.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useShippingOptions } from "medusa-react"
|
import { useShippingOptions } from "medusa-react"
|
||||||
|
|
||||||
const ReturnShippingOptions = () => {
|
const ReturnShippingOptions = () => {
|
||||||
const {
|
const {
|
||||||
shipping_options,
|
shipping_options,
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -100,25 +100,25 @@ const ReturnShippingOptions = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ReturnShippingOptions
|
export default ReturnShippingOptions
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/shipping-options?is_return=true`, {
|
fetch(`<BACKEND_URL>/store/shipping-options?is_return=true`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ shipping_options }) => {
|
.then(({ shipping_options }) => {
|
||||||
console.log(shipping_options.length)
|
console.log(shipping_options.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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).
|
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,10 +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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.returns.create({
|
medusa.returns.create({
|
||||||
order_id,
|
order_id,
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
@@ -146,19 +146,19 @@ medusa.returns.create({
|
|||||||
return_shipping: {
|
return_shipping: {
|
||||||
option_id,
|
option_id,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
console.log(data.return.id)
|
console.log(data.return.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCreateReturn } from "medusa-react"
|
import { useCreateReturn } from "medusa-react"
|
||||||
|
|
||||||
const CreateReturn = () => {
|
const CreateReturn = () => {
|
||||||
const createReturn = useCreateReturn()
|
const createReturn = useCreateReturn()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -178,16 +178,16 @@ const CreateReturn = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateReturn
|
export default CreateReturn
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/returns`, {
|
fetch(`<BACKEND_URL>/store/returns`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -205,14 +205,14 @@ fetch(`<BACKEND_URL>/store/returns`, {
|
|||||||
option_id,
|
option_id,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
console.log(data.return.id)
|
console.log(data.return.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the following request body parameters:
|
This API Route requires the following request body parameters:
|
||||||
|
|||||||
@@ -63,10 +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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.swaps.create({
|
medusa.swaps.create({
|
||||||
order_id,
|
order_id,
|
||||||
return_items: [
|
return_items: [
|
||||||
{
|
{
|
||||||
@@ -81,19 +81,19 @@ medusa.swaps.create({
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
return_shipping_option,
|
return_shipping_option,
|
||||||
})
|
})
|
||||||
.then(({ swap }) => {
|
.then(({ swap }) => {
|
||||||
console.log(swap.id)
|
console.log(swap.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCreateSwap } from "medusa-react"
|
import { useCreateSwap } from "medusa-react"
|
||||||
|
|
||||||
const CreateSwap = () => {
|
const CreateSwap = () => {
|
||||||
const createSwap = useCreateSwap()
|
const createSwap = useCreateSwap()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -117,16 +117,16 @@ const CreateSwap = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateSwap
|
export default CreateSwap
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/swaps`, {
|
fetch(`<BACKEND_URL>/store/swaps`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -148,14 +148,14 @@ fetch(`<BACKEND_URL>/store/swaps`, {
|
|||||||
],
|
],
|
||||||
return_shipping_option,
|
return_shipping_option,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ swap }) => {
|
.then(({ swap }) => {
|
||||||
console.log(swap.id)
|
console.log(swap.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the following request body parameters:
|
This API Route requires the following request body parameters:
|
||||||
@@ -191,22 +191,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.swaps.retrieveByCartId(cartId)
|
medusa.swaps.retrieveByCartId(cartId)
|
||||||
.then(({ swap }) => {
|
.then(({ swap }) => {
|
||||||
console.log(swap.id)
|
console.log(swap.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCartSwap } from "medusa-react"
|
import { useCartSwap } from "medusa-react"
|
||||||
|
|
||||||
const Swap = () => {
|
const Swap = () => {
|
||||||
const {
|
const {
|
||||||
swap,
|
swap,
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -219,25 +219,25 @@ const Swap = () => {
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Swap
|
export default Swap
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/swaps/${cartId}`, {
|
fetch(`<BACKEND_URL>/store/swaps/${cartId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ swap }) => {
|
.then(({ swap }) => {
|
||||||
console.log(swap.id)
|
console.log(swap.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the ID of the cart as a path parameter.
|
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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.orderEdits.retrieve(orderEditId)
|
medusa.orderEdits.retrieve(orderEditId)
|
||||||
.then(({ order_edit }) => {
|
.then(({ order_edit }) => {
|
||||||
console.log(order_edit.changes)
|
console.log(order_edit.changes)
|
||||||
// show changed items to the customer
|
// show changed items to the customer
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useOrderEdit } from "medusa-react"
|
import { useOrderEdit } from "medusa-react"
|
||||||
|
|
||||||
const OrderEdit = () => {
|
const OrderEdit = () => {
|
||||||
const { order_edit, isLoading } = useOrderEdit(orderEditId)
|
const { order_edit, isLoading } = useOrderEdit(orderEditId)
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default OrderEdit
|
export default OrderEdit
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/order-edits/${orderEditId}`)
|
fetch(`<BACKEND_URL>/store/order-edits/${orderEditId}`)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order_edit }) => {
|
.then(({ order_edit }) => {
|
||||||
console.log(order_edit.changes)
|
console.log(order_edit.changes)
|
||||||
// show changed items to the customer
|
// show changed items to the customer
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
The request requires the order edit’s ID as a path parameter.
|
The request requires the order edit’s ID as a path parameter.
|
||||||
@@ -201,26 +201,26 @@ 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:
|
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}>
|
<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 -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.paymentCollections.managePaymentSession(paymentCollectionId, {
|
medusa.paymentCollections.managePaymentSession(paymentCollectionId, {
|
||||||
provider_id,
|
provider_id,
|
||||||
})
|
})
|
||||||
.then(({ payment_collection }) => {
|
.then(({ payment_collection }) => {
|
||||||
console.log(payment_collection.payment_sessions)
|
console.log(payment_collection.payment_sessions)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useManagePaymentSession } from "medusa-react"
|
import { useManagePaymentSession } from "medusa-react"
|
||||||
|
|
||||||
const OrderEditPayment = () => {
|
const OrderEditPayment = () => {
|
||||||
const managePaymentSession = useManagePaymentSession(
|
const managePaymentSession = useManagePaymentSession(
|
||||||
paymentCollectionId
|
paymentCollectionId
|
||||||
)
|
)
|
||||||
@@ -233,18 +233,18 @@ const OrderEditPayment = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default OrderEditPayment
|
export default OrderEditPayment
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/store/payment-collections/${paymentCollectionId}/sessions`,
|
`<BACKEND_URL>/store/payment-collections/${paymentCollectionId}/sessions`,
|
||||||
{
|
{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -256,41 +256,41 @@ fetch(
|
|||||||
provider_id,
|
provider_id,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ payment_collection }) => {
|
.then(({ payment_collection }) => {
|
||||||
console.log(payment_collection.payment_sessions)
|
console.log(payment_collection.payment_sessions)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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:
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa
|
medusa
|
||||||
.paymentCollection
|
.paymentCollection
|
||||||
.authorizePaymentSession(
|
.authorizePaymentSession(
|
||||||
paymentCollectionId,
|
paymentCollectionId,
|
||||||
paymentSessionId
|
paymentSessionId
|
||||||
)
|
)
|
||||||
.then(({ payment_session }) => {
|
.then(({ payment_session }) => {
|
||||||
console.log(payment_session.id)
|
console.log(payment_session.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAuthorizePaymentSession } from "medusa-react"
|
import { useAuthorizePaymentSession } from "medusa-react"
|
||||||
|
|
||||||
const OrderEditPayment = () => {
|
const OrderEditPayment = () => {
|
||||||
const authorizePaymentSession = useAuthorizePaymentSession(
|
const authorizePaymentSession = useAuthorizePaymentSession(
|
||||||
paymentCollectionId
|
paymentCollectionId
|
||||||
)
|
)
|
||||||
@@ -301,32 +301,32 @@ const OrderEditPayment = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default OrderEditPayment
|
export default OrderEditPayment
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/store/payment-collection/${paymentCollectionId}` +
|
`<BACKEND_URL>/store/payment-collection/${paymentCollectionId}` +
|
||||||
`/sessions/${paymentSessionId}/authorize`,
|
`/sessions/${paymentSessionId}/authorize`,
|
||||||
{
|
{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ payment_session }) => {
|
.then(({ payment_session }) => {
|
||||||
console.log(payment_session.id)
|
console.log(payment_session.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
After performing the above steps, you can [complete the Order Edit](#complete-the-order-edit).
|
After performing the above steps, you can [complete the Order Edit](#complete-the-order-edit).
|
||||||
@@ -338,22 +338,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.orderEdits.complete(orderEditId)
|
medusa.orderEdits.complete(orderEditId)
|
||||||
.then(({ order_edit }) => {
|
.then(({ order_edit }) => {
|
||||||
console.log(order_edit.confirmed_at)
|
console.log(order_edit.confirmed_at)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCompleteOrderEdit } from "medusa-react"
|
import { useCompleteOrderEdit } from "medusa-react"
|
||||||
|
|
||||||
const OrderEdit = () => {
|
const OrderEdit = () => {
|
||||||
const completeOrderEdit = useCompleteOrderEdit(orderEditId)
|
const completeOrderEdit = useCompleteOrderEdit(orderEditId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -362,28 +362,28 @@ const OrderEdit = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default OrderEdit
|
export default OrderEdit
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/order-edits/${orderEditId}/complete`, {
|
fetch(`<BACKEND_URL>/store/order-edits/${orderEditId}/complete`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order_edit }) => {
|
.then(({ order_edit }) => {
|
||||||
console.log(order_edit.confirmed_at)
|
console.log(order_edit.confirmed_at)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request accepts the order edit’s ID as a path parameter.
|
This request accepts the order edit’s ID as a path parameter.
|
||||||
@@ -405,24 +405,24 @@ 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:
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.orderEdits.decline(orderEditId, {
|
medusa.orderEdits.decline(orderEditId, {
|
||||||
decline_reason: "I am not satisfied",
|
decline_reason: "I am not satisfied",
|
||||||
})
|
})
|
||||||
.then(({ order_edit }) => {
|
.then(({ order_edit }) => {
|
||||||
console.log(order_edit.declined_at)
|
console.log(order_edit.declined_at)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useDeclineOrderEdit } from "medusa-react"
|
import { useDeclineOrderEdit } from "medusa-react"
|
||||||
|
|
||||||
const OrderEdit = () => {
|
const OrderEdit = () => {
|
||||||
const declineOrderEdit = useDeclineOrderEdit(orderEditId)
|
const declineOrderEdit = useDeclineOrderEdit(orderEditId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -433,16 +433,16 @@ const OrderEdit = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default OrderEdit
|
export default OrderEdit
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/store/order-edits/${orderEditId}/decline`,
|
`<BACKEND_URL>/store/order-edits/${orderEditId}/decline`,
|
||||||
{
|
{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -454,14 +454,14 @@ fetch(
|
|||||||
decline_reason: "I am not satisfied",
|
decline_reason: "I am not satisfied",
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order_edit }) => {
|
.then(({ order_edit }) => {
|
||||||
console.log(order_edit.declined_at)
|
console.log(order_edit.declined_at)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
The request requires passing the order edit’s ID as a path parameter.
|
The request requires passing the order edit’s ID as a path parameter.
|
||||||
|
|||||||
@@ -80,27 +80,27 @@ 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:
|
To allow the customer to claim an order, send a request to the Claim an Order API Route:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.orders.requestCustomerOrders({
|
medusa.orders.requestCustomerOrders({
|
||||||
order_ids: [
|
order_ids: [
|
||||||
order_id,
|
order_id,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// successful
|
// successful
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
// an error occurred
|
// an error occurred
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/orders/batch/customer/token`, {
|
fetch(`<BACKEND_URL>/store/orders/batch/customer/token`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@@ -111,16 +111,16 @@ fetch(`<BACKEND_URL>/store/orders/batch/customer/token`, {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// successful
|
// successful
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
// display an error to the customer
|
// display an error to the customer
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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,27 +138,27 @@ 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:
|
Then, you send a request to the Verify Claim Order API Route:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.orders.confirmRequest({
|
medusa.orders.confirmRequest({
|
||||||
token,
|
token,
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// successful
|
// successful
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
// an error occurred
|
// an error occurred
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useGrantOrderAccess } from "medusa-react"
|
import { useGrantOrderAccess } from "medusa-react"
|
||||||
|
|
||||||
const ClaimOrder = () => {
|
const ClaimOrder = () => {
|
||||||
const grantOrderAccess = useGrantOrderAccess()
|
const grantOrderAccess = useGrantOrderAccess()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -169,16 +169,16 @@ const ClaimOrder = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ClaimOrder
|
export default ClaimOrder
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/orders/customer/confirm`, {
|
fetch(`<BACKEND_URL>/store/orders/customer/confirm`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@@ -187,16 +187,16 @@ fetch(`<BACKEND_URL>/store/orders/customer/confirm`, {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// successful
|
// successful
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
// display an error to the customer
|
// display an error to the customer
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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,22 +39,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.orders.retrieve(orderId)
|
medusa.orders.retrieve(orderId)
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.id)
|
console.log(order.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useOrder } from "medusa-react"
|
import { useOrder } from "medusa-react"
|
||||||
|
|
||||||
const Order = () => {
|
const Order = () => {
|
||||||
const {
|
const {
|
||||||
order,
|
order,
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -67,25 +67,25 @@ const Order = () => {
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Order
|
export default Order
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/orders/${orderId}`, {
|
fetch(`<BACKEND_URL>/store/orders/${orderId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.id)
|
console.log(order.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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,25 +101,25 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.orders.lookupOrder({
|
medusa.orders.lookupOrder({
|
||||||
display_id: 1,
|
display_id: 1,
|
||||||
email: "user@example.com",
|
email: "user@example.com",
|
||||||
})
|
})
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.id)
|
console.log(order.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useOrders } from "medusa-react"
|
import { useOrders } from "medusa-react"
|
||||||
|
|
||||||
const Order = () => {
|
const Order = () => {
|
||||||
const {
|
const {
|
||||||
order,
|
order,
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -135,27 +135,27 @@ const Order = () => {
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Order
|
export default Order
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/orders?display_id=1&email=user@example.com`, {
|
fetch(`<BACKEND_URL>/store/orders?display_id=1&email=user@example.com`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.id)
|
console.log(order.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires two query parameters:
|
This API Route requires two query parameters:
|
||||||
@@ -176,22 +176,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.orders.retrieveByCartId(cartId)
|
medusa.orders.retrieveByCartId(cartId)
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.id)
|
console.log(order.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCartOrder } from "medusa-react"
|
import { useCartOrder } from "medusa-react"
|
||||||
|
|
||||||
const Order = () => {
|
const Order = () => {
|
||||||
const {
|
const {
|
||||||
order,
|
order,
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -204,25 +204,25 @@ const Order = () => {
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Order
|
export default Order
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/orders/cart/${cartId}`, {
|
fetch(`<BACKEND_URL>/store/orders/cart/${cartId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ order }) => {
|
.then(({ order }) => {
|
||||||
console.log(order.id)
|
console.log(order.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the ID of the cart as a path parameter.
|
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
|
addHowToData: true
|
||||||
---
|
---
|
||||||
|
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs'
|
||||||
import TabItem from '@theme/TabItem';
|
import TabItem from '@theme/TabItem'
|
||||||
|
import Details from "@site/src/theme/MDXProvider/Details"
|
||||||
|
|
||||||
# How to Bulk Import Prices
|
# 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.
|
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>
|
<Details>
|
||||||
<summary>
|
<Summary>Expected columns</Summary>
|
||||||
Expected columns
|
|
||||||
</summary>
|
|
||||||
|
|
||||||
<table class="reference-table">
|
<table class="reference-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
Column Name
|
Column Name
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
Description
|
Description
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
Is required?
|
Is required?
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
Product Variant ID
|
Product Variant ID
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
The ID of the product variant this price belongs to.
|
The ID of the product variant this price belongs to.
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
Either this or the SKU column are required.
|
Either this or the SKU column are required.
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
SKU
|
SKU
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
The SKU of the product variant this price belongs to.
|
The SKU of the product variant this price belongs to.
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
Either this or the Product Variant ID column are required.
|
Either this or the Product Variant ID column are required.
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
Price (region name)
|
Price (region name)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
The price amount in a region, where (region name) is the name of the region.
|
The price amount in a region, where (region name) is the name of the region.
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
No
|
No
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
Price (currency code)
|
Price (currency code)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
The price amount for a currency, where (currency code) is the 3 character iso code of the currency. For example, "Price USD".
|
The price amount for a currency, where (currency code) is the 3 character iso code of the currency. For example, "Price USD".
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
No
|
No
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
</details>
|
</Details>
|
||||||
|
|
||||||
### JS Client
|
### JS Client
|
||||||
|
|
||||||
@@ -148,22 +147,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.uploads.create(file) // file is an instance of File
|
medusa.admin.uploads.create(file) // file is an instance of File
|
||||||
.then(({ uploads }) => {
|
.then(({ uploads }) => {
|
||||||
const key = uploads[0].key
|
const key = uploads[0].key
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUploadFile } from "medusa-react"
|
import { useAdminUploadFile } from "medusa-react"
|
||||||
|
|
||||||
const ImportPrices = () => {
|
const ImportPrices = () => {
|
||||||
const uploadFile = useAdminUploadFile()
|
const uploadFile = useAdminUploadFile()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -172,43 +171,43 @@ const ImportPrices = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ImportPrices
|
export default ImportPrices
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.append("files", file) // file is an instance of File
|
formData.append("files", file) // file is an instance of File
|
||||||
|
|
||||||
fetch(`<BACKEND_URL>/admin/uploads`, {
|
fetch(`<BACKEND_URL>/admin/uploads`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "multipart/form-data",
|
"Content-Type": "multipart/form-data",
|
||||||
},
|
},
|
||||||
body: formData,
|
body: formData,
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ uploads }) => {
|
.then(({ uploads }) => {
|
||||||
const key = uploads[0].key
|
const key = uploads[0].key
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/uploads' \
|
curl -L -X POST '<BACKEND_URL>/admin/uploads' \
|
||||||
-H 'Authorization: Bearer {api_token}' \
|
-H 'Authorization: Bearer {api_token}' \
|
||||||
-H 'Content-Type: text/csv' \
|
-H 'Content-Type: text/csv' \
|
||||||
-F 'files=@"<FILE_PATH_1>"'
|
-F 'files=@"<FILE_PATH_1>"'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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,29 +221,29 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.batchJobs.create({
|
medusa.admin.batchJobs.create({
|
||||||
type: "price-list-import",
|
type: "price-list-import",
|
||||||
context: {
|
context: {
|
||||||
fileKey: key, // obtained from previous step
|
fileKey: key, // obtained from previous step
|
||||||
price_list_id,
|
price_list_id,
|
||||||
},
|
},
|
||||||
dry_run: true,
|
dry_run: true,
|
||||||
})
|
})
|
||||||
.then(( batch_job ) => {
|
.then(( batch_job ) => {
|
||||||
console.log(batch_job.status)
|
console.log(batch_job.status)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateBatchJob } from "medusa-react"
|
import { useAdminCreateBatchJob } from "medusa-react"
|
||||||
|
|
||||||
const ImportPrices = () => {
|
const ImportPrices = () => {
|
||||||
const createBatchJob = useAdminCreateBatchJob()
|
const createBatchJob = useAdminCreateBatchJob()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -259,16 +258,16 @@ const ImportPrices = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ImportPrices
|
export default ImportPrices
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/batch-jobs`, {
|
fetch(`<BACKEND_URL>/admin/batch-jobs`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -282,33 +281,33 @@ fetch(`<BACKEND_URL>/admin/batch-jobs`, {
|
|||||||
},
|
},
|
||||||
dry_run: true,
|
dry_run: true,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ batch_job }) => {
|
.then(({ batch_job }) => {
|
||||||
console.log(batch_job.status)
|
console.log(batch_job.status)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/batch-jobs' \
|
curl -L -X POST '<BACKEND_URL>/admin/batch-jobs' \
|
||||||
-H 'Authorization: Bearer {api_token}' \
|
-H 'Authorization: Bearer {api_token}' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"type": "price-list-import",
|
"type": "price-list-import",
|
||||||
"context": {
|
"context": {
|
||||||
"fileKey": "<KEY>",
|
"fileKey": "<KEY>",
|
||||||
"price_list_id": "<PRICE_LIST_ID>"
|
"price_list_id": "<PRICE_LIST_ID>"
|
||||||
},
|
},
|
||||||
"dry_run": true
|
"dry_run": true
|
||||||
}'
|
}'
|
||||||
# <KEY> is the key you obtained from the previous step
|
# <KEY> is the key you obtained from the previous step
|
||||||
# <PRICE_LIST_ID> is the ID of the price list to import prices into
|
# <PRICE_LIST_ID> is the ID of the price list to import prices into
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
In the body of the request, you must pass the following parameters:
|
In the body of the request, you must pass the following parameters:
|
||||||
@@ -336,22 +335,22 @@ 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:
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.batchJobs.retrieve(batchJobId)
|
medusa.admin.batchJobs.retrieve(batchJobId)
|
||||||
.then(( batch_job ) => {
|
.then(( batch_job ) => {
|
||||||
console.log(batch_job.status, batch_job.result)
|
console.log(batch_job.status, batch_job.result)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminBatchJob } from "medusa-react"
|
import { useAdminBatchJob } from "medusa-react"
|
||||||
|
|
||||||
const ImportPrices = () => {
|
const ImportPrices = () => {
|
||||||
const { batch_job, isLoading } = useAdminBatchJob(batchJobId)
|
const { batch_job, isLoading } = useAdminBatchJob(batchJobId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -367,34 +366,34 @@ const ImportPrices = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ImportPrices
|
export default ImportPrices
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/batch-jobs/${batchJobId}`, {
|
fetch(`<BACKEND_URL>/admin/batch-jobs/${batchJobId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ batch_job }) => {
|
.then(({ batch_job }) => {
|
||||||
console.log(batch_job.status, batch_job.result)
|
console.log(batch_job.status, batch_job.result)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/batch-jobs/<BATCH_JOB_ID>' \
|
curl -L -X GET '<BACKEND_URL>/admin/batch-jobs/<BATCH_JOB_ID>' \
|
||||||
-H 'Authorization: Bearer {api_token}'
|
-H 'Authorization: Bearer {api_token}'
|
||||||
# <BATCH_JOB_ID> is the ID of the batch job
|
# <BATCH_JOB_ID> is the ID of the batch job
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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,22 +425,22 @@ 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:
|
To confirm a batch job send the following request:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.batchJobs.confirm(batchJobId)
|
medusa.admin.batchJobs.confirm(batchJobId)
|
||||||
.then(( batch_job ) => {
|
.then(( batch_job ) => {
|
||||||
console.log(batch_job.status)
|
console.log(batch_job.status)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminConfirmBatchJob } from "medusa-react"
|
import { useAdminConfirmBatchJob } from "medusa-react"
|
||||||
|
|
||||||
const ImportPrices = () => {
|
const ImportPrices = () => {
|
||||||
const confirmBatchJob = useAdminConfirmBatchJob(batchJobId)
|
const confirmBatchJob = useAdminConfirmBatchJob(batchJobId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -450,35 +449,35 @@ const ImportPrices = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ImportPrices
|
export default ImportPrices
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/batch-jobs/${batchJobId}/confirm`, {
|
fetch(`<BACKEND_URL>/admin/batch-jobs/${batchJobId}/confirm`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ batch_job }) => {
|
.then(({ batch_job }) => {
|
||||||
console.log(batch_job.status)
|
console.log(batch_job.status)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/batch-jobs/<BATCH_JOB_ID>/confirm' \
|
curl -L -X POST '<BACKEND_URL>/admin/batch-jobs/<BATCH_JOB_ID>/confirm' \
|
||||||
-H 'Authorization: Bearer {api_token}'
|
-H 'Authorization: Bearer {api_token}'
|
||||||
# <BATCH_JOB_ID> is the ID of the batch job
|
# <BATCH_JOB_ID> is the ID of the batch job
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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.
|
||||||
|
|||||||
@@ -77,15 +77,15 @@ You can learn more about what the conditions you can apply on a price list and i
|
|||||||
For example, sending the following request creates a price list with two prices: one that is applied when the maximum quantity of the product variant in the cart is 3; another is applied when the minimum quantity of the same variant in the cart is 4:
|
For example, sending the following request creates a price list with two prices: one that is applied when the maximum quantity of the product variant in the cart is 3; another is applied when the minimum quantity of the same variant in the cart is 4:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
import {
|
import {
|
||||||
PriceListStatus,
|
PriceListStatus,
|
||||||
PriceListType,
|
PriceListType,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
|
|
||||||
medusa.admin.priceLists.create({
|
medusa.admin.priceLists.create({
|
||||||
name: "New Price List",
|
name: "New Price List",
|
||||||
description: "A new price list",
|
description: "A new price list",
|
||||||
type: PriceListType.SALE,
|
type: PriceListType.SALE,
|
||||||
@@ -104,23 +104,23 @@ medusa.admin.priceLists.create({
|
|||||||
min_quantity: 4,
|
min_quantity: 4,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.then(({ price_list }) => {
|
.then(({ price_list }) => {
|
||||||
console.log(price_list.id)
|
console.log(price_list.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import {
|
import {
|
||||||
PriceListStatus,
|
PriceListStatus,
|
||||||
PriceListType,
|
PriceListType,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
import { useAdminCreatePriceList } from "medusa-react"
|
import { useAdminCreatePriceList } from "medusa-react"
|
||||||
|
|
||||||
const CreatePriceList = () => {
|
const CreatePriceList = () => {
|
||||||
const createPriceList = useAdminCreatePriceList()
|
const createPriceList = useAdminCreatePriceList()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -148,16 +148,16 @@ const CreatePriceList = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreatePriceList
|
export default CreatePriceList
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
fetch(`<BACKEND_URL>/admin/price-lists`, {
|
fetch(`<BACKEND_URL>/admin/price-lists`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -183,21 +183,21 @@ fetch(`<BACKEND_URL>/admin/price-lists`, {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ price_list }) => {
|
.then(({ price_list }) => {
|
||||||
console.log(price_list.id)
|
console.log(price_list.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<YOUR_BACKEND_URL>/admin/price-lists' \
|
curl -L -X POST '<YOUR_BACKEND_URL>/admin/price-lists' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"name": "New Price List",
|
"name": "New Price List",
|
||||||
"description": "A new price list",
|
"description": "A new price list",
|
||||||
"type": "sale",
|
"type": "sale",
|
||||||
@@ -216,10 +216,10 @@ curl -L -X POST '<YOUR_BACKEND_URL>/admin/price-lists' \
|
|||||||
"min_quantity": 4
|
"min_quantity": 4
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request returns the created price list.
|
This request returns the created price list.
|
||||||
@@ -233,23 +233,23 @@ You can check the full list of request body parameters in the [API reference](ht
|
|||||||
You can retrieve all of a price list’s details using the Get a Price List API Route:
|
You can retrieve all of a price list’s details using the Get a Price List API Route:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
medusa.admin.priceLists.retrieve(priceListId)
|
medusa.admin.priceLists.retrieve(priceListId)
|
||||||
.then(({ price_list }) => {
|
.then(({ price_list }) => {
|
||||||
console.log(price_list.id)
|
console.log(price_list.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { CustomerGroup } from "@medusajs/medusa"
|
import { CustomerGroup } from "@medusajs/medusa"
|
||||||
import { useAdminPriceList } from "medusa-react"
|
import { useAdminPriceList } from "medusa-react"
|
||||||
|
|
||||||
const PriceList = () => {
|
const PriceList = () => {
|
||||||
const {
|
const {
|
||||||
price_list,
|
price_list,
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -261,33 +261,33 @@ const PriceList = () => {
|
|||||||
{price_list && <span>{price_list.name}</span>}
|
{price_list && <span>{price_list.name}</span>}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PriceList
|
export default PriceList
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
fetch(`<BACKEND_URL>/admin/price-lists/${priceListId}`, {
|
fetch(`<BACKEND_URL>/admin/price-lists/${priceListId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ price_list }) => {
|
.then(({ price_list }) => {
|
||||||
console.log(price_list.id)
|
console.log(price_list.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/price-lists/{id}' \
|
curl -L -X GET '<BACKEND_URL>/admin/price-lists/{id}' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -299,28 +299,28 @@ After creating a price list, you can update all of its fields including its stat
|
|||||||
For example, by sending the following request the end date of the price list will be updated:
|
For example, by sending the following request the end date of the price list will be updated:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
medusa.admin.priceLists.update(priceListId, {
|
medusa.admin.priceLists.update(priceListId, {
|
||||||
ends_at: "2022-10-11",
|
ends_at: "2022-10-11",
|
||||||
})
|
})
|
||||||
.then(({ price_list }) => {
|
.then(({ price_list }) => {
|
||||||
console.log(price_list.id)
|
console.log(price_list.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import {
|
import {
|
||||||
PriceListStatus,
|
PriceListStatus,
|
||||||
PriceListType,
|
PriceListType,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
import { useAdminUpdatePriceList } from "medusa-react"
|
import { useAdminUpdatePriceList } from "medusa-react"
|
||||||
|
|
||||||
const CreatePriceList = () => {
|
const CreatePriceList = () => {
|
||||||
const updatePriceList = useAdminUpdatePriceList(priceListId)
|
const updatePriceList = useAdminUpdatePriceList(priceListId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -331,16 +331,16 @@ const CreatePriceList = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreatePriceList
|
export default CreatePriceList
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
fetch(`<BACKEND_URL>/admin/price-lists/${priceListId}`, {
|
fetch(`<BACKEND_URL>/admin/price-lists/${priceListId}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -349,26 +349,26 @@ fetch(`<BACKEND_URL>/admin/price-lists/${priceListId}`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
ends_at: "2022-10-11",
|
ends_at: "2022-10-11",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ price_list }) => {
|
.then(({ price_list }) => {
|
||||||
console.log(price_list.id)
|
console.log(price_list.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/price-lists/<PRICE_LIST_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/price-lists/<PRICE_LIST_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"ends_at": "2022-10-11"
|
"ends_at": "2022-10-11"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request returns the updated price list.
|
This request returns the updated price list.
|
||||||
@@ -388,10 +388,10 @@ You can also set the `override` request body parameter to `true` to replace the
|
|||||||
For example, sending the following request adds a new price to the price list:
|
For example, sending the following request adds a new price to the price list:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
medusa.admin.priceLists.addPrices(priceListId, {
|
medusa.admin.priceLists.addPrices(priceListId, {
|
||||||
prices: [
|
prices: [
|
||||||
{
|
{
|
||||||
amount: 1200,
|
amount: 1200,
|
||||||
@@ -399,19 +399,19 @@ medusa.admin.priceLists.addPrices(priceListId, {
|
|||||||
currency_code: "eur",
|
currency_code: "eur",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.then(({ price_list }) => {
|
.then(({ price_list }) => {
|
||||||
console.log(price_list.id)
|
console.log(price_list.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreatePriceListPrices } from "medusa-react"
|
import { useAdminCreatePriceListPrices } from "medusa-react"
|
||||||
|
|
||||||
const PriceList = () => {
|
const PriceList = () => {
|
||||||
const addPrice = useAdminCreatePriceListPrices(priceListId)
|
const addPrice = useAdminCreatePriceListPrices(priceListId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -428,18 +428,18 @@ const PriceList = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PriceList
|
export default PriceList
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
fetch(`<BACKEND_URL>/admin/price-lists/${priceListId}/prices/batch`, {
|
fetch(`<BACKEND_URL>/admin/price-lists/${priceListId}/prices/batch`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -454,21 +454,21 @@ fetch(`<BACKEND_URL>/admin/price-lists/${priceListId}/prices/batch`, {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ price_list }) => {
|
.then(({ price_list }) => {
|
||||||
console.log(price_list.id)
|
console.log(price_list.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/price-lists/<PRICE_LIST_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/price-lists/<PRICE_LIST_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"prices": [
|
"prices": [
|
||||||
{
|
{
|
||||||
"amount": 1200,
|
"amount": 1200,
|
||||||
@@ -476,10 +476,10 @@ curl -L -X POST '<BACKEND_URL>/admin/price-lists/<PRICE_LIST_ID>' \
|
|||||||
"currency_code": "eur"
|
"currency_code": "eur"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request returns the price list with the updated prices.
|
This request returns the price list with the updated prices.
|
||||||
@@ -491,27 +491,27 @@ For a full list of request body parameters, check out the [API reference](https:
|
|||||||
You can delete all the prices of a product’s variants using the [Delete Product Prices API Route](https://docs.medusajs.com/api/admin#price-lists_deletepricelistspricelistpricesbatch):
|
You can delete all the prices of a product’s variants using the [Delete Product Prices API Route](https://docs.medusajs.com/api/admin#price-lists_deletepricelistspricelistpricesbatch):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
medusa
|
medusa
|
||||||
.admin
|
.admin
|
||||||
.priceLists
|
.priceLists
|
||||||
.deleteProductPrices(priceListId, productId)
|
.deleteProductPrices(priceListId, productId)
|
||||||
.then(({ ids, object, deleted }) => {
|
.then(({ ids, object, deleted }) => {
|
||||||
console.log(ids.length)
|
console.log(ids.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import {
|
import {
|
||||||
useAdminDeletePriceListProductPrices,
|
useAdminDeletePriceListProductPrices,
|
||||||
} from "medusa-react"
|
} from "medusa-react"
|
||||||
|
|
||||||
const PriceList = () => {
|
const PriceList = () => {
|
||||||
const deletePrices = useAdminDeletePriceListProductPrices(
|
const deletePrices = useAdminDeletePriceListProductPrices(
|
||||||
priceListId,
|
priceListId,
|
||||||
productId
|
productId
|
||||||
@@ -523,39 +523,39 @@ const PriceList = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PriceList
|
export default PriceList
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/admin/price-lists/${priceListId}/products/${productId}/prices`,
|
`<BACKEND_URL>/admin/price-lists/${priceListId}/products/${productId}/prices`,
|
||||||
{
|
{
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ ids, object, deleted }) => {
|
.then(({ ids, object, deleted }) => {
|
||||||
console.log(ids.length)
|
console.log(ids.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/price-lists/<PRICE_LIST_ID>/products/<PRODUCT_ID>/prices' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/price-lists/<PRICE_LIST_ID>/products/<PRODUCT_ID>/prices' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request returns the IDs of the deleted prices.
|
This request returns the IDs of the deleted prices.
|
||||||
@@ -565,27 +565,27 @@ This request returns the IDs of the deleted prices.
|
|||||||
You can delete all the prices of a variant using the [Delete Variant Prices API Route](https://docs.medusajs.com/api/admin#price-lists_deletepricelistspricelistvariantsvariantprices):
|
You can delete all the prices of a variant using the [Delete Variant Prices API Route](https://docs.medusajs.com/api/admin#price-lists_deletepricelistspricelistvariantsvariantprices):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
medusa
|
medusa
|
||||||
.admin
|
.admin
|
||||||
.priceLists
|
.priceLists
|
||||||
.deleteVariantPrices(priceListId, variantId)
|
.deleteVariantPrices(priceListId, variantId)
|
||||||
.then(({ ids, object, deleted }) => {
|
.then(({ ids, object, deleted }) => {
|
||||||
console.log(ids)
|
console.log(ids)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import {
|
import {
|
||||||
useAdminDeletePriceListVariantPrices,
|
useAdminDeletePriceListVariantPrices,
|
||||||
} from "medusa-react"
|
} from "medusa-react"
|
||||||
|
|
||||||
const PriceList = () => {
|
const PriceList = () => {
|
||||||
const deleteVariantPrices =
|
const deleteVariantPrices =
|
||||||
useAdminDeletePriceListVariantPrices(
|
useAdminDeletePriceListVariantPrices(
|
||||||
priceListId,
|
priceListId,
|
||||||
@@ -598,39 +598,39 @@ const PriceList = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PriceList
|
export default PriceList
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/admin/price-lists/${priceListId}/variants/${variantId}/prices`,
|
`<BACKEND_URL>/admin/price-lists/${priceListId}/variants/${variantId}/prices`,
|
||||||
{
|
{
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ ids, object, deleted }) => {
|
.then(({ ids, object, deleted }) => {
|
||||||
console.log(ids.length)
|
console.log(ids.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/price-lists/<PRICE_LIST_ID>/variants/<VARIANT_ID>/prices' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/price-lists/<PRICE_LIST_ID>/variants/<VARIANT_ID>/prices' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request returns the IDs of the deleted prices.
|
This request returns the IDs of the deleted prices.
|
||||||
@@ -642,22 +642,22 @@ This request returns the IDs of the deleted prices.
|
|||||||
You can delete a price list, and subsequently all prices defined in it, using the [Delete Price List API Route](https://docs.medusajs.com/api/admin#price-lists_deletepricelistspricelist):
|
You can delete a price list, and subsequently all prices defined in it, using the [Delete Price List API Route](https://docs.medusajs.com/api/admin#price-lists_deletepricelistspricelist):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
medusa.admin.priceLists.delete(priceListId)
|
medusa.admin.priceLists.delete(priceListId)
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDeletePriceList } from "medusa-react"
|
import { useAdminDeletePriceList } from "medusa-react"
|
||||||
|
|
||||||
const PriceList = () => {
|
const PriceList = () => {
|
||||||
const deletePriceList = useAdminDeletePriceList(priceListId)
|
const deletePriceList = useAdminDeletePriceList(priceListId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -666,34 +666,34 @@ const PriceList = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PriceList
|
export default PriceList
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
fetch(`<BACKEND_URL>/admin/price-lists/${priceListId}`, {
|
fetch(`<BACKEND_URL>/admin/price-lists/${priceListId}`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/price-lists/<PRICE_LIST_ID>' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/price-lists/<PRICE_LIST_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request returns the ID of the deleted price list.
|
This request returns the ID of the deleted price list.
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -54,24 +54,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.productCategories.list()
|
medusa.admin.productCategories.list()
|
||||||
.then(({ product_categories, limit, offset, count }) => {
|
.then(({ product_categories, limit, offset, count }) => {
|
||||||
console.log(product_categories.length)
|
console.log(product_categories.length)
|
||||||
// display categories
|
// display categories
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminProductCategories } from "medusa-react"
|
import { useAdminProductCategories } from "medusa-react"
|
||||||
import { ProductCategory } from "@medusajs/medusa"
|
import { ProductCategory } from "@medusajs/medusa"
|
||||||
|
|
||||||
function Categories() {
|
function Categories() {
|
||||||
const {
|
const {
|
||||||
product_categories,
|
product_categories,
|
||||||
isLoading } = useAdminProductCategories()
|
isLoading } = useAdminProductCategories()
|
||||||
@@ -93,34 +93,34 @@ function Categories() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Categories
|
export default Categories
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/product-categories`, {
|
fetch(`<BACKEND_URL>/admin/product-categories`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ product_categories, limit, offset, count }) => {
|
.then(({ product_categories, limit, offset, count }) => {
|
||||||
console.log(product_categories.length)
|
console.log(product_categories.length)
|
||||||
// display product categories
|
// display product categories
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/product-categories' \
|
curl -L -X GET '<BACKEND_URL>/admin/product-categories' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request returns an array of product categories, as well as [pagination fields](https://docs.medusajs.com/api/admin#pagination).
|
This request returns an array of product categories, as well as [pagination fields](https://docs.medusajs.com/api/admin#pagination).
|
||||||
@@ -134,24 +134,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.productCategories.create({
|
medusa.admin.productCategories.create({
|
||||||
name: "Skinny Jeans",
|
name: "Skinny Jeans",
|
||||||
})
|
})
|
||||||
.then(({ product_category }) => {
|
.then(({ product_category }) => {
|
||||||
console.log(product_category.id)
|
console.log(product_category.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateProductCategory } from "medusa-react"
|
import { useAdminCreateProductCategory } from "medusa-react"
|
||||||
|
|
||||||
const CreateCategory = () => {
|
const CreateCategory = () => {
|
||||||
const createCategory = useAdminCreateProductCategory()
|
const createCategory = useAdminCreateProductCategory()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -162,16 +162,16 @@ const CreateCategory = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateCategory
|
export default CreateCategory
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/product-categories`, {
|
fetch(`<BACKEND_URL>/admin/product-categories`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -180,26 +180,26 @@ fetch(`<BACKEND_URL>/admin/product-categories`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
name: "Skinny Jeans",
|
name: "Skinny Jeans",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ product_category }) => {
|
.then(({ product_category }) => {
|
||||||
console.log(product_category.id)
|
console.log(product_category.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/product-categories' \
|
curl -L -X POST '<BACKEND_URL>/admin/product-categories' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"name": "Skinny Jeans"
|
"name": "Skinny Jeans"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires one body parameter `name`, which is the name of the category. The request also accepts the following optional body parameters:
|
This request requires one body parameter `name`, which is the name of the category. The request also accepts the following optional body parameters:
|
||||||
@@ -218,22 +218,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.productCategories.retrieve(productCategoryId)
|
medusa.admin.productCategories.retrieve(productCategoryId)
|
||||||
.then(({ product_category }) => {
|
.then(({ product_category }) => {
|
||||||
console.log(product_category.id)
|
console.log(product_category.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminProductCategory } from "medusa-react"
|
import { useAdminProductCategory } from "medusa-react"
|
||||||
|
|
||||||
const Category = () => {
|
const Category = () => {
|
||||||
const {
|
const {
|
||||||
product_category,
|
product_category,
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -246,35 +246,35 @@ const Category = () => {
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Category
|
export default Category
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}`, {
|
fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ product_category }) => {
|
.then(({ product_category }) => {
|
||||||
console.log(product_category.id)
|
console.log(product_category.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/product-categories/<CAT_ID>' \
|
curl -L -X GET '<BACKEND_URL>/admin/product-categories/<CAT_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the ID of the category to be passed as a path parameter.
|
This request requires the ID of the category to be passed as a path parameter.
|
||||||
@@ -288,24 +288,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.productCategories.update(productCategoryId, {
|
medusa.admin.productCategories.update(productCategoryId, {
|
||||||
name: "Skinny Jeans",
|
name: "Skinny Jeans",
|
||||||
})
|
})
|
||||||
.then(({ product_category }) => {
|
.then(({ product_category }) => {
|
||||||
console.log(product_category.id)
|
console.log(product_category.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUpdateProductCategory } from "medusa-react"
|
import { useAdminUpdateProductCategory } from "medusa-react"
|
||||||
|
|
||||||
const UpdateCategory = () => {
|
const UpdateCategory = () => {
|
||||||
const updateCategory = useAdminUpdateProductCategory(
|
const updateCategory = useAdminUpdateProductCategory(
|
||||||
productCategoryId
|
productCategoryId
|
||||||
)
|
)
|
||||||
@@ -318,18 +318,18 @@ const UpdateCategory = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdateCategory
|
export default UpdateCategory
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}`, {
|
fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -343,21 +343,21 @@ fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}`, {
|
|||||||
.then(({ product_category }) => {
|
.then(({ product_category }) => {
|
||||||
console.log(product_category.id)
|
console.log(product_category.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/product-categories/<CAT_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/product-categories/<CAT_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"name": "Skinny Jeans",
|
"name": "Skinny Jeans",
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the ID of the category to be passed as a path parameter.
|
This request requires the ID of the category to be passed as a path parameter.
|
||||||
@@ -383,10 +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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.productCategories.addProducts(productCategoryId, {
|
medusa.admin.productCategories.addProducts(productCategoryId, {
|
||||||
product_ids: [
|
product_ids: [
|
||||||
{
|
{
|
||||||
id: productId1,
|
id: productId1,
|
||||||
@@ -395,19 +395,19 @@ medusa.admin.productCategories.addProducts(productCategoryId, {
|
|||||||
id: productId2,
|
id: productId2,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.then(({ product_category }) => {
|
.then(({ product_category }) => {
|
||||||
console.log(product_category.id)
|
console.log(product_category.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminAddProductsToCategory } from "medusa-react"
|
import { useAdminAddProductsToCategory } from "medusa-react"
|
||||||
|
|
||||||
const UpdateProductsInCategory = () => {
|
const UpdateProductsInCategory = () => {
|
||||||
const addProductsToCategory = useAdminAddProductsToCategory(
|
const addProductsToCategory = useAdminAddProductsToCategory(
|
||||||
productCategoryId
|
productCategoryId
|
||||||
)
|
)
|
||||||
@@ -427,18 +427,18 @@ const UpdateProductsInCategory = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdateProductsInCategory
|
export default UpdateProductsInCategory
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}/products/batch`, {
|
fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}/products/batch`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -454,21 +454,21 @@ fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}/products/batc
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ product_category }) => {
|
.then(({ product_category }) => {
|
||||||
console.log(product_category.id)
|
console.log(product_category.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/product-categories/<CAT_ID>/products/batch' \
|
curl -L -X POST '<BACKEND_URL>/admin/product-categories/<CAT_ID>/products/batch' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"product_ids": [
|
"product_ids": [
|
||||||
{
|
{
|
||||||
"id": "productId1"
|
"id": "productId1"
|
||||||
@@ -477,10 +477,10 @@ curl -L -X POST '<BACKEND_URL>/admin/product-categories/<CAT_ID>/products/batch'
|
|||||||
"id": "productId2"
|
"id": "productId2"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the ID of the category to be passed as a path parameter.
|
This request requires the ID of the category to be passed as a path parameter.
|
||||||
@@ -494,10 +494,10 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.productCategories.removeProducts(
|
medusa.admin.productCategories.removeProducts(
|
||||||
productCategoryId,
|
productCategoryId,
|
||||||
{
|
{
|
||||||
product_ids: [
|
product_ids: [
|
||||||
@@ -509,21 +509,21 @@ medusa.admin.productCategories.removeProducts(
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(({ product_category }) => {
|
.then(({ product_category }) => {
|
||||||
console.log(product_category.id)
|
console.log(product_category.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import {
|
import {
|
||||||
useAdminDeleteProductsFromCategory,
|
useAdminDeleteProductsFromCategory,
|
||||||
} from "medusa-react"
|
} from "medusa-react"
|
||||||
|
|
||||||
const DeleteProductsFromCategory = () => {
|
const DeleteProductsFromCategory = () => {
|
||||||
const deleteProductsFromCategory =
|
const deleteProductsFromCategory =
|
||||||
useAdminDeleteProductsFromCategory(productCategoryId)
|
useAdminDeleteProductsFromCategory(productCategoryId)
|
||||||
// ...
|
// ...
|
||||||
@@ -542,18 +542,18 @@ const DeleteProductsFromCategory = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DeleteProductsFromCategory
|
export default DeleteProductsFromCategory
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}/products/batch`, {
|
fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}/products/batch`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -569,21 +569,21 @@ fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}/products/batc
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ product_category }) => {
|
.then(({ product_category }) => {
|
||||||
console.log(product_category.id)
|
console.log(product_category.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/product-categories/<CAT_ID>/products/batch' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/product-categories/<CAT_ID>/products/batch' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"product_ids": [
|
"product_ids": [
|
||||||
{
|
{
|
||||||
"id": "productId1"
|
"id": "productId1"
|
||||||
@@ -592,10 +592,10 @@ curl -L -X DELETE '<BACKEND_URL>/admin/product-categories/<CAT_ID>/products/batc
|
|||||||
"id": "productId2"
|
"id": "productId2"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the ID of the category to be passed as a path parameter.
|
This request requires the ID of the category to be passed as a path parameter.
|
||||||
@@ -611,22 +611,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.productCategories.delete(productCategoryId)
|
medusa.admin.productCategories.delete(productCategoryId)
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDeleteProductCategory } from "medusa-react"
|
import { useAdminDeleteProductCategory } from "medusa-react"
|
||||||
|
|
||||||
const Category = () => {
|
const Category = () => {
|
||||||
const deleteCategory = useAdminDeleteProductCategory(
|
const deleteCategory = useAdminDeleteProductCategory(
|
||||||
productCategoryId
|
productCategoryId
|
||||||
)
|
)
|
||||||
@@ -637,36 +637,35 @@ const Category = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Category
|
export default Category
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}`, {
|
fetch(`<BACKEND_URL>/admin/product-categories/${productCategoryId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
</TabItem>
|
```bash
|
||||||
<TabItem value="curl" label="cURL">
|
curl -L -X DELETE '<BACKEND_URL>/admin/product-categories/<CAT_ID>' \
|
||||||
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
|
```
|
||||||
|
|
||||||
```bash
|
</TabItem>
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/product-categories/<CAT_ID>' \
|
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
|
||||||
```
|
|
||||||
|
|
||||||
</TabItem>
|
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the ID of the category to be passed as a path parameter.
|
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
+3
-3
@@ -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`.
|
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>
|
<Details>
|
||||||
<summary>Zero-decimal Currencies</summary>
|
<Summary>Zero-decimal Currencies</Summary>
|
||||||
|
|
||||||
- BIF
|
- BIF
|
||||||
- CLP
|
- CLP
|
||||||
@@ -131,7 +131,7 @@ For zero-decimal currencies, the amount is still stored as an integer without mu
|
|||||||
- XOF
|
- XOF
|
||||||
- XPF
|
- 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.
|
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.
|
||||||
|
|
||||||
+3
-3
@@ -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:
|
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>
|
<Details>
|
||||||
<summary>Seed file</summary>
|
<Summary>Seed file</Summary>
|
||||||
|
|
||||||
```js title=seed-data.js
|
```js title=seed-data.js
|
||||||
const productCategoriesData = [
|
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:
|
Then run the first and optionally second commands to migrate the database schema:
|
||||||
|
|
||||||
@@ -50,7 +50,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.
|
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.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -59,22 +59,22 @@ If you follow the `@medusajs/product` code blocks, it's assumed you already have
|
|||||||
You can list available products using the [List Products API Route](https://docs.medusajs.com/api/store#products_getproducts):
|
You can list available products using the [List Products API Route](https://docs.medusajs.com/api/store#products_getproducts):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.products.list()
|
medusa.products.list()
|
||||||
.then(({ products, limit, offset, count }) => {
|
.then(({ products, limit, offset, count }) => {
|
||||||
console.log(products.length)
|
console.log(products.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useProducts } from "medusa-react"
|
import { useProducts } from "medusa-react"
|
||||||
|
|
||||||
const Products = () => {
|
const Products = () => {
|
||||||
const { products, isLoading } = useProducts()
|
const { products, isLoading } = useProducts()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -90,57 +90,57 @@ const Products = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Products
|
export default Products
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="module" label={(
|
<TabItem value="module" label={(
|
||||||
<>
|
<>
|
||||||
@medusajs/product
|
@medusajs/product
|
||||||
<Badge variant="orange">beta</Badge>
|
<Badge variant="orange">beta</Badge>
|
||||||
</>
|
</>
|
||||||
)} attributes={{
|
)} attributes={{
|
||||||
badge: true
|
badge: true
|
||||||
}}>
|
}}>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import {
|
import {
|
||||||
initialize as initializeProductModule,
|
initialize as initializeProductModule,
|
||||||
} from "@medusajs/product"
|
} from "@medusajs/product"
|
||||||
|
|
||||||
// in an async function, or you can use promises
|
// in an async function, or you can use promises
|
||||||
async () => {
|
async () => {
|
||||||
// ...
|
// ...
|
||||||
const productService = await initializeProductModule()
|
const productService = await initializeProductModule()
|
||||||
const products = await productService.list()
|
const products = await productService.list()
|
||||||
|
|
||||||
console.log(products.length)
|
console.log(products.length)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/products`, {
|
fetch(`<BACKEND_URL>/store/products`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ products, limit, offset, count }) => {
|
.then(({ products, limit, offset, count }) => {
|
||||||
console.log(products.length)
|
console.log(products.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/store/products'
|
curl -L -X GET '<BACKEND_URL>/store/products'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route doesn't require any parameters. You can pass it parameters related to pagination, filtering, and more as explained in the [API reference](https://docs.medusajs.com/api/store#tag/Products/operation/GetProducts).
|
This API Route doesn't require any parameters. You can pass it parameters related to pagination, filtering, and more as explained in the [API reference](https://docs.medusajs.com/api/store#tag/Products/operation/GetProducts).
|
||||||
@@ -154,25 +154,25 @@ The List Products API Route accepts different query parameters that allow you to
|
|||||||
For example, you can filter products by a category ID:
|
For example, you can filter products by a category ID:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.products.list({
|
medusa.products.list({
|
||||||
category_id: ["cat_123"],
|
category_id: ["cat_123"],
|
||||||
})
|
})
|
||||||
.then(({ products, limit, offset, count }) => {
|
.then(({ products, limit, offset, count }) => {
|
||||||
console.log(products.length)
|
console.log(products.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useProducts } from "medusa-react"
|
import { useProducts } from "medusa-react"
|
||||||
import { Product } from "@medusajs/medusa"
|
import { Product } from "@medusajs/medusa"
|
||||||
|
|
||||||
const Products = () => {
|
const Products = () => {
|
||||||
const { products, isLoading } = useProducts({
|
const { products, isLoading } = useProducts({
|
||||||
category_id: ["cat_123"],
|
category_id: ["cat_123"],
|
||||||
})
|
})
|
||||||
@@ -190,28 +190,28 @@ const Products = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Products
|
export default Products
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="module" label={(
|
<TabItem value="module" label={(
|
||||||
<>
|
<>
|
||||||
@medusajs/product
|
@medusajs/product
|
||||||
<Badge variant="orange">beta</Badge>
|
<Badge variant="orange">beta</Badge>
|
||||||
</>
|
</>
|
||||||
)} attributes={{
|
)} attributes={{
|
||||||
badge: true
|
badge: true
|
||||||
}}>
|
}}>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import {
|
import {
|
||||||
initialize as initializeProductModule,
|
initialize as initializeProductModule,
|
||||||
} from "@medusajs/product"
|
} from "@medusajs/product"
|
||||||
|
|
||||||
// in an async function, or you can use promises
|
// in an async function, or you can use promises
|
||||||
async () => {
|
async () => {
|
||||||
// ...
|
// ...
|
||||||
const productService = await initializeProductModule()
|
const productService = await initializeProductModule()
|
||||||
const products = await productService.list({
|
const products = await productService.list({
|
||||||
@@ -219,30 +219,30 @@ async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
console.log(products)
|
console.log(products)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/products?category_id[]=cat_123`, {
|
fetch(`<BACKEND_URL>/store/products?category_id[]=cat_123`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ products, limit, offset, count }) => {
|
.then(({ products, limit, offset, count }) => {
|
||||||
console.log(products.length)
|
console.log(products.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/store/products?category_id[]=cat_123'
|
curl -L -X GET '<BACKEND_URL>/store/products?category_id[]=cat_123'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This will retrieve only products that belong to that category.
|
This will retrieve only products that belong to that category.
|
||||||
@@ -252,25 +252,25 @@ This will retrieve only products that belong to that category.
|
|||||||
To expand the categories of each product, you can pass `categories` to the `expand` query parameter:
|
To expand the categories of each product, you can pass `categories` to the `expand` query parameter:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.products.list({
|
medusa.products.list({
|
||||||
expand: "categories",
|
expand: "categories",
|
||||||
})
|
})
|
||||||
.then(({ products, limit, offset, count }) => {
|
.then(({ products, limit, offset, count }) => {
|
||||||
console.log(products.length)
|
console.log(products.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useProducts } from "medusa-react"
|
import { useProducts } from "medusa-react"
|
||||||
import { Product } from "@medusajs/medusa"
|
import { Product } from "@medusajs/medusa"
|
||||||
|
|
||||||
const Products = () => {
|
const Products = () => {
|
||||||
const { products, isLoading } = useProducts({
|
const { products, isLoading } = useProducts({
|
||||||
expand: "categories",
|
expand: "categories",
|
||||||
})
|
})
|
||||||
@@ -288,28 +288,28 @@ const Products = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Products
|
export default Products
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="module" label={(
|
<TabItem value="module" label={(
|
||||||
<>
|
<>
|
||||||
@medusajs/product
|
@medusajs/product
|
||||||
<Badge variant="orange">beta</Badge>
|
<Badge variant="orange">beta</Badge>
|
||||||
</>
|
</>
|
||||||
)} attributes={{
|
)} attributes={{
|
||||||
badge: true
|
badge: true
|
||||||
}}>
|
}}>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import {
|
import {
|
||||||
initialize as initializeProductModule,
|
initialize as initializeProductModule,
|
||||||
} from "@medusajs/product"
|
} from "@medusajs/product"
|
||||||
|
|
||||||
// in an async function, or you can use promises
|
// in an async function, or you can use promises
|
||||||
async () => {
|
async () => {
|
||||||
// ...
|
// ...
|
||||||
const productService = await initializeProductModule()
|
const productService = await initializeProductModule()
|
||||||
const products = await productService.list({}, {
|
const products = await productService.list({}, {
|
||||||
@@ -317,30 +317,30 @@ async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
console.log(products)
|
console.log(products)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/products?expand=categories`, {
|
fetch(`<BACKEND_URL>/store/products?expand=categories`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ products, limit, offset, count }) => {
|
.then(({ products, limit, offset, count }) => {
|
||||||
console.log(products.length)
|
console.log(products.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/store/products?expand=categories'
|
curl -L -X GET '<BACKEND_URL>/store/products?expand=categories'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
You can learn more about the [expand parameter in the API reference](https://docs.medusajs.com/api/store#section/Expanding-Fields)
|
You can learn more about the [expand parameter in the API reference](https://docs.medusajs.com/api/store#section/Expanding-Fields)
|
||||||
@@ -358,26 +358,26 @@ It’s recommended to always include the cart and region’s IDs when you’re l
|
|||||||
For example:
|
For example:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.products.list({
|
medusa.products.list({
|
||||||
cart_id,
|
cart_id,
|
||||||
region_id,
|
region_id,
|
||||||
})
|
})
|
||||||
.then(({ products, limit, offset, count }) => {
|
.then(({ products, limit, offset, count }) => {
|
||||||
console.log(products.length)
|
console.log(products.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useProducts } from "medusa-react"
|
import { useProducts } from "medusa-react"
|
||||||
import { Product } from "@medusajs/medusa"
|
import { Product } from "@medusajs/medusa"
|
||||||
|
|
||||||
const Products = () => {
|
const Products = () => {
|
||||||
const { products, isLoading } = useProducts({
|
const { products, isLoading } = useProducts({
|
||||||
cart_id,
|
cart_id,
|
||||||
region_id,
|
region_id,
|
||||||
@@ -396,34 +396,34 @@ const Products = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Products
|
export default Products
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/products?cart_id=${cartId}®ion_id=${regionId}`, {
|
fetch(`<BACKEND_URL>/store/products?cart_id=${cartId}®ion_id=${regionId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ products, limit, offset, count }) => {
|
.then(({ products, limit, offset, count }) => {
|
||||||
console.log(products.length)
|
console.log(products.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/store/products?cart_id=<CART_ID>®ion_id=<REGION_ID>'
|
curl -L -X GET '<BACKEND_URL>/store/products?cart_id=<CART_ID>®ion_id=<REGION_ID>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
### Display Product Price
|
### Display Product Price
|
||||||
@@ -447,7 +447,7 @@ You must pass one of the [pricing parameters](#product-pricing-parameters) to th
|
|||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
Prices in Medusa are stored as the currency's smallest unit. So, for currencies that are not zero-decimal, the amount is stored multiplied by a `100`. You can learn more about this in the [Product conceptual guide](../products.md#storing-the-product-variants-price).
|
Prices in Medusa are stored as the currency's smallest unit. So, for currencies that are not zero-decimal, the amount is stored multiplied by a `100`. You can learn more about this in the [Product conceptual guide](../products.mdx#storing-the-product-variants-price).
|
||||||
|
|
||||||
So, to show the correct price, you would need to convert it to its actual price with a method like this:
|
So, to show the correct price, you would need to convert it to its actual price with a method like this:
|
||||||
|
|
||||||
@@ -477,18 +477,18 @@ Medusa React provides utility methods such as `formatVariantPrice` that handles
|
|||||||
Here’s an example of how you can calculate the price with and without Medusa React:
|
Here’s an example of how you can calculate the price with and without Medusa React:
|
||||||
|
|
||||||
<Tabs groupId="client-preference" isCodeTabs={true}>
|
<Tabs groupId="client-preference" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Without Medusa Client" default>
|
<TabItem value="client" label="Without Medusa Client" default>
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import React, { useEffect, useState } from "react"
|
import React, { useEffect, useState } from "react"
|
||||||
import Medusa from "@medusajs/medusa-js"
|
import Medusa from "@medusajs/medusa-js"
|
||||||
|
|
||||||
const medusa = new Medusa({
|
const medusa = new Medusa({
|
||||||
baseUrl: "<YOUR_BACKEND_URL>",
|
baseUrl: "<YOUR_BACKEND_URL>",
|
||||||
maxRetries: 3,
|
maxRetries: 3,
|
||||||
})
|
})
|
||||||
|
|
||||||
function Products() {
|
function Products() {
|
||||||
const [products, setProducts] = useState([])
|
const [products, setProducts] = useState([])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -527,19 +527,19 @@ function Products() {
|
|||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Products
|
export default Products
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="With Medusa React">
|
<TabItem value="medusa-react" label="With Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { formatVariantPrice, useProducts } from "medusa-react"
|
import { formatVariantPrice, useProducts } from "medusa-react"
|
||||||
import { Product, ProductVariant } from "@medusajs/medusa"
|
import { Product, ProductVariant } from "@medusajs/medusa"
|
||||||
|
|
||||||
const Products = () => {
|
const Products = () => {
|
||||||
const { products, isLoading } = useProducts({
|
const { products, isLoading } = useProducts({
|
||||||
region_id: region.id, // assuming already defined somewhere
|
region_id: region.id, // assuming already defined somewhere
|
||||||
})
|
})
|
||||||
@@ -570,12 +570,12 @@ const Products = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Products
|
export default Products
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -591,22 +591,22 @@ The Search functionality requires either installing a [search plugin](../../../p
|
|||||||
You can search products using the [Search Products API Route](https://docs.medusajs.com/api/store#tag/Products/operation/PostProductsSearch):
|
You can search products using the [Search Products API Route](https://docs.medusajs.com/api/store#tag/Products/operation/PostProductsSearch):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.products.search({
|
medusa.products.search({
|
||||||
q: "Shirt",
|
q: "Shirt",
|
||||||
})
|
})
|
||||||
.then(({ hits }) => {
|
.then(({ hits }) => {
|
||||||
console.log(hits.length)
|
console.log(hits.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/products/search`, {
|
fetch(`<BACKEND_URL>/store/products/search`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -615,25 +615,25 @@ fetch(`<BACKEND_URL>/store/products/search`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
q: "Shirt",
|
q: "Shirt",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ hits }) => {
|
.then(({ hits }) => {
|
||||||
console.log(hits.length)
|
console.log(hits.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/store/products/search?q=Shirt' \
|
curl -L -X POST '<BACKEND_URL>/store/products/search?q=Shirt' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"q": "Shirt"
|
"q": "Shirt"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the query parameter `q` being the term to search products for. The search plugin or service you’re using determine how `q` will be used to search the products. It also accepts pagination parameters as explained in the [API reference](https://docs.medusajs.com/api/store#products_postproductssearch).
|
This API Route requires the query parameter `q` being the term to search products for. The search plugin or service you’re using determine how `q` will be used to search the products. It also accepts pagination parameters as explained in the [API reference](https://docs.medusajs.com/api/store#products_postproductssearch).
|
||||||
@@ -647,22 +647,22 @@ The request returns a `hits` array holding the result items. The structure of th
|
|||||||
You can retrieve the details of a single product by its ID using the [Get a Product API Route](https://docs.medusajs.com/api/store#products_getproductsproduct):
|
You can retrieve the details of a single product by its ID using the [Get a Product API Route](https://docs.medusajs.com/api/store#products_getproductsproduct):
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.products.retrieve(productId)
|
medusa.products.retrieve(productId)
|
||||||
.then(({ product }) => {
|
.then(({ product }) => {
|
||||||
console.log(product.id)
|
console.log(product.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useProduct } from "medusa-react"
|
import { useProduct } from "medusa-react"
|
||||||
|
|
||||||
const Products = () => {
|
const Products = () => {
|
||||||
const { product, isLoading } = useProduct(productId)
|
const { product, isLoading } = useProduct(productId)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -671,28 +671,28 @@ const Products = () => {
|
|||||||
{product && <span>{product.title}</span>}
|
{product && <span>{product.title}</span>}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Products
|
export default Products
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="module" label={(
|
<TabItem value="module" label={(
|
||||||
<>
|
<>
|
||||||
@medusajs/product
|
@medusajs/product
|
||||||
<Badge variant="orange">beta</Badge>
|
<Badge variant="orange">beta</Badge>
|
||||||
</>
|
</>
|
||||||
)} attributes={{
|
)} attributes={{
|
||||||
badge: true
|
badge: true
|
||||||
}}>
|
}}>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import {
|
import {
|
||||||
initialize as initializeProductModule,
|
initialize as initializeProductModule,
|
||||||
} from "@medusajs/product"
|
} from "@medusajs/product"
|
||||||
|
|
||||||
// in an async function, or you can use promises
|
// in an async function, or you can use promises
|
||||||
async () => {
|
async () => {
|
||||||
// ...
|
// ...
|
||||||
const productService = await initializeProductModule()
|
const productService = await initializeProductModule()
|
||||||
const products = await productService.list({
|
const products = await productService.list({
|
||||||
@@ -700,30 +700,30 @@ async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
console.log(products[0])
|
console.log(products[0])
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/products/${productId}`, {
|
fetch(`<BACKEND_URL>/store/products/${productId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ product }) => {
|
.then(({ product }) => {
|
||||||
console.log(product.id)
|
console.log(product.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/store/products/<PRODUCT_ID>'
|
curl -L -X GET '<BACKEND_URL>/store/products/<PRODUCT_ID>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the product’s ID to be passed as a path parameter. You can also pass query parameters such as `cart_id` and `region_id` which are relevant for pricing as explained in the [Product Pricing Parameters section](#product-pricing-parameters). You can check the full list of accepted parameters in the [API reference](https://docs.medusajs.com/api/store#products_getproductsproduct).
|
This API Route requires the product’s ID to be passed as a path parameter. You can also pass query parameters such as `cart_id` and `region_id` which are relevant for pricing as explained in the [Product Pricing Parameters section](#product-pricing-parameters). You can check the full list of accepted parameters in the [API reference](https://docs.medusajs.com/api/store#products_getproductsproduct).
|
||||||
@@ -741,27 +741,27 @@ On the storefront, you may use the handle of a product as its page’s path. For
|
|||||||
You can retrieve the details of a product by its handle by sending a request to the List Products API Route, passing the `handle` as a filter:
|
You can retrieve the details of a product by its handle by sending a request to the List Products API Route, passing the `handle` as a filter:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.products.list({
|
medusa.products.list({
|
||||||
handle,
|
handle,
|
||||||
})
|
})
|
||||||
.then(({ products }) => {
|
.then(({ products }) => {
|
||||||
if (!products.length) {
|
if (!products.length) {
|
||||||
// product does not exist
|
// product does not exist
|
||||||
}
|
}
|
||||||
const product = products[0]
|
const product = products[0]
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useProducts } from "medusa-react"
|
import { useProducts } from "medusa-react"
|
||||||
|
|
||||||
const Products = () => {
|
const Products = () => {
|
||||||
const { products, isLoading } = useProducts({
|
const { products, isLoading } = useProducts({
|
||||||
handle,
|
handle,
|
||||||
})
|
})
|
||||||
@@ -775,28 +775,28 @@ const Products = () => {
|
|||||||
{products && products.length > 0 && products[0].title}
|
{products && products.length > 0 && products[0].title}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Products
|
export default Products
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="module" label={(
|
<TabItem value="module" label={(
|
||||||
<>
|
<>
|
||||||
@medusajs/product
|
@medusajs/product
|
||||||
<Badge variant="orange">beta</Badge>
|
<Badge variant="orange">beta</Badge>
|
||||||
</>
|
</>
|
||||||
)} attributes={{
|
)} attributes={{
|
||||||
badge: true
|
badge: true
|
||||||
}}>
|
}}>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import {
|
import {
|
||||||
initialize as initializeProductModule,
|
initialize as initializeProductModule,
|
||||||
} from "@medusajs/product"
|
} from "@medusajs/product"
|
||||||
|
|
||||||
// in an async function, or you can use promises
|
// in an async function, or you can use promises
|
||||||
async () => {
|
async () => {
|
||||||
// ...
|
// ...
|
||||||
const productService = await initializeProductModule()
|
const productService = await initializeProductModule()
|
||||||
const products = await productService.list({
|
const products = await productService.list({
|
||||||
@@ -804,33 +804,33 @@ async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
console.log(products[0])
|
console.log(products[0])
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/products?handle=${handle}`, {
|
fetch(`<BACKEND_URL>/store/products?handle=${handle}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ products }) => {
|
.then(({ products }) => {
|
||||||
if (!products.length) {
|
if (!products.length) {
|
||||||
// product does not exist
|
// product does not exist
|
||||||
}
|
}
|
||||||
const product = products[0]
|
const product = products[0]
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/store/products?handle=<HANDLE>'
|
curl -L -X GET '<BACKEND_URL>/store/products?handle=<HANDLE>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
As the `handle` of each product is unique, when you pass the handle as a filter you’ll either:
|
As the `handle` of each product is unique, when you pass the handle as a filter you’ll either:
|
||||||
|
|||||||
@@ -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.
|
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,23 +57,23 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.productCategories.list()
|
medusa.productCategories.list()
|
||||||
.then(({ product_categories, limit, offset, count }) => {
|
.then(({ product_categories, limit, offset, count }) => {
|
||||||
console.log(product_categories.length)
|
console.log(product_categories.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useProductCategories } from "medusa-react"
|
import { useProductCategories } from "medusa-react"
|
||||||
import { ProductCategory } from "@medusajs/medusa"
|
import { ProductCategory } from "@medusajs/medusa"
|
||||||
|
|
||||||
function Categories() {
|
function Categories() {
|
||||||
const {
|
const {
|
||||||
product_categories,
|
product_categories,
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -96,56 +96,56 @@ function Categories() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Categories
|
export default Categories
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="module" label={(
|
<TabItem value="module" label={(
|
||||||
<>
|
<>
|
||||||
@medusajs/product
|
@medusajs/product
|
||||||
<Badge variant="orange" className="ml-0.5">beta</Badge>
|
<Badge variant="orange" className="ml-0.5">beta</Badge>
|
||||||
</>
|
</>
|
||||||
)}>
|
)}>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import {
|
import {
|
||||||
initialize as initializeProductModule,
|
initialize as initializeProductModule,
|
||||||
} from "@medusajs/product"
|
} from "@medusajs/product"
|
||||||
|
|
||||||
// in an async function, or you can use promises
|
// in an async function, or you can use promises
|
||||||
async () => {
|
async () => {
|
||||||
// ...
|
// ...
|
||||||
const productService = await initializeProductModule()
|
const productService = await initializeProductModule()
|
||||||
const categories = await productService.listCategories()
|
const categories = await productService.listCategories()
|
||||||
|
|
||||||
console.log(categories)
|
console.log(categories)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/product-categories`, {
|
fetch(`<BACKEND_URL>/store/product-categories`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ product_categories, limit, offset, count }) => {
|
.then(({ product_categories, limit, offset, count }) => {
|
||||||
console.log(product_categories.length)
|
console.log(product_categories.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/store/product-categories' \
|
curl -L -X GET '<BACKEND_URL>/store/product-categories' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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).
|
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,22 +163,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.productCategories.retrieve(productCategoryId)
|
medusa.productCategories.retrieve(productCategoryId)
|
||||||
.then(({ product_category }) => {
|
.then(({ product_category }) => {
|
||||||
console.log(product_category.name)
|
console.log(product_category.name)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useProductCategory } from "medusa-react"
|
import { useProductCategory } from "medusa-react"
|
||||||
|
|
||||||
function Category() {
|
function Category() {
|
||||||
const { product_category, isLoading } = useProductCategory()
|
const { product_category, isLoading } = useProductCategory()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -187,26 +187,26 @@ function Category() {
|
|||||||
{product_category && <span>{product_category.name}</span>}
|
{product_category && <span>{product_category.name}</span>}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Category
|
export default Category
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="module" label={(
|
<TabItem value="module" label={(
|
||||||
<>
|
<>
|
||||||
@medusajs/product
|
@medusajs/product
|
||||||
<Badge variant="orange">beta</Badge>
|
<Badge variant="orange">beta</Badge>
|
||||||
</>
|
</>
|
||||||
)}>
|
)}>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import {
|
import {
|
||||||
initialize as initializeProductModule,
|
initialize as initializeProductModule,
|
||||||
} from "@medusajs/product"
|
} from "@medusajs/product"
|
||||||
|
|
||||||
// in an async function, or you can use promises
|
// in an async function, or you can use promises
|
||||||
async () => {
|
async () => {
|
||||||
// ...
|
// ...
|
||||||
const productService = await initializeProductModule()
|
const productService = await initializeProductModule()
|
||||||
const categories = await productService.listCategories({
|
const categories = await productService.listCategories({
|
||||||
@@ -214,33 +214,33 @@ async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
console.log(categories[0])
|
console.log(categories[0])
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/product-categories/${productCategoryId}`, {
|
fetch(`<BACKEND_URL>/store/product-categories/${productCategoryId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ product_category }) => {
|
.then(({ product_category }) => {
|
||||||
console.log(product_category.name)
|
console.log(product_category.name)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/store/product-categories/<CAT_ID>' \
|
curl -L -X GET '<BACKEND_URL>/store/product-categories/<CAT_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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).
|
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,28 +256,28 @@ 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:
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.productCategories.list({
|
medusa.productCategories.list({
|
||||||
handle: "women",
|
handle: "women",
|
||||||
})
|
})
|
||||||
.then(({ product_categories, limit, offset, count }) => {
|
.then(({ product_categories, limit, offset, count }) => {
|
||||||
if (!product_categories.length) {
|
if (!product_categories.length) {
|
||||||
// category does not exist
|
// category does not exist
|
||||||
}
|
}
|
||||||
const category = product_categories[0]
|
const category = product_categories[0]
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useProductCategories } from "medusa-react"
|
import { useProductCategories } from "medusa-react"
|
||||||
import { ProductCategory } from "@medusajs/medusa"
|
import { ProductCategory } from "@medusajs/medusa"
|
||||||
|
|
||||||
function Categories() {
|
function Categories() {
|
||||||
const {
|
const {
|
||||||
product_categories,
|
product_categories,
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -302,26 +302,26 @@ function Categories() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Categories
|
export default Categories
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="module" label={(
|
<TabItem value="module" label={(
|
||||||
<>
|
<>
|
||||||
@medusajs/product
|
@medusajs/product
|
||||||
<Badge variant="orange">beta</Badge>
|
<Badge variant="orange">beta</Badge>
|
||||||
</>
|
</>
|
||||||
)}>
|
)}>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import {
|
import {
|
||||||
initialize as initializeProductModule,
|
initialize as initializeProductModule,
|
||||||
} from "@medusajs/product"
|
} from "@medusajs/product"
|
||||||
|
|
||||||
// in an async function, or you can use promises
|
// in an async function, or you can use promises
|
||||||
async () => {
|
async () => {
|
||||||
// ...
|
// ...
|
||||||
const productService = await initializeProductModule()
|
const productService = await initializeProductModule()
|
||||||
const categories = await productService.listCategories({
|
const categories = await productService.listCategories({
|
||||||
@@ -329,34 +329,34 @@ async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
console.log(categories[0])
|
console.log(categories[0])
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/product-categories?handle=women`, {
|
fetch(`<BACKEND_URL>/store/product-categories?handle=women`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ product_categories, limit, offset, count }) => {
|
.then(({ product_categories, limit, offset, count }) => {
|
||||||
if (!product_categories.length) {
|
if (!product_categories.length) {
|
||||||
// category does not exist
|
// category does not exist
|
||||||
}
|
}
|
||||||
const category = product_categories[0]
|
const category = product_categories[0]
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/store/product-categories?handle=women' \
|
curl -L -X GET '<BACKEND_URL>/store/product-categories?handle=women' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
As the `handle` of each category is unique, when you pass the handle as a filter you’ll either:
|
As the `handle` of each category is unique, when you pass the handle as a filter you’ll either:
|
||||||
|
|||||||
+152
-152
@@ -63,23 +63,23 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.currencies.list()
|
medusa.admin.currencies.list()
|
||||||
.then(({ currencies, count, offset, limit }) => {
|
.then(({ currencies, count, offset, limit }) => {
|
||||||
console.log(currencies.length)
|
console.log(currencies.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { Currency } from "@medusajs/medusa"
|
import { Currency } from "@medusajs/medusa"
|
||||||
import { useAdminCurrencies } from "medusa-react"
|
import { useAdminCurrencies } from "medusa-react"
|
||||||
|
|
||||||
const Currencies = () => {
|
const Currencies = () => {
|
||||||
const { currencies, isLoading } = useAdminCurrencies()
|
const { currencies, isLoading } = useAdminCurrencies()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -97,33 +97,33 @@ const Currencies = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Currencies
|
export default Currencies
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/currencies`, {
|
fetch(`<BACKEND_URL>/admin/currencies`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ currencies, count, offset, limit }) => {
|
.then(({ currencies, count, offset, limit }) => {
|
||||||
console.log(currencies.length)
|
console.log(currencies.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/currencies' \
|
curl -L -X GET '<BACKEND_URL>/admin/currencies' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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).
|
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,24 +137,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.currencies.update(code, {
|
medusa.admin.currencies.update(code, {
|
||||||
includes_tax: true,
|
includes_tax: true,
|
||||||
})
|
})
|
||||||
.then(({ currency }) => {
|
.then(({ currency }) => {
|
||||||
console.log(currency.code)
|
console.log(currency.code)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUpdateCurrency } from "medusa-react"
|
import { useAdminUpdateCurrency } from "medusa-react"
|
||||||
|
|
||||||
const UpdateCode = () => {
|
const UpdateCode = () => {
|
||||||
const updateCode = useAdminUpdateCurrency(code)
|
const updateCode = useAdminUpdateCurrency(code)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -165,16 +165,16 @@ const UpdateCode = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdateCode
|
export default UpdateCode
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/currencies/${code}`, {
|
fetch(`<BACKEND_URL>/admin/currencies/${code}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -188,21 +188,21 @@ fetch(`<BACKEND_URL>/admin/currencies/${code}`, {
|
|||||||
.then(({ currency }) => {
|
.then(({ currency }) => {
|
||||||
console.log(currency.code)
|
console.log(currency.code)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/currencies/<CODE>' \
|
curl -L -X GET '<BACKEND_URL>/admin/currencies/<CODE>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"includes_tax": true
|
"includes_tax": true
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the currency code as a path parameter.
|
This API Route requires the currency code as a path parameter.
|
||||||
@@ -228,23 +228,23 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.store.retrieve()
|
medusa.admin.store.retrieve()
|
||||||
.then(({ store }) => {
|
.then(({ store }) => {
|
||||||
console.log(store.currencies, store.default_currency)
|
console.log(store.currencies, store.default_currency)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { Currency } from "@medusajs/medusa"
|
import { Currency } from "@medusajs/medusa"
|
||||||
import { useAdminStore } from "medusa-react"
|
import { useAdminStore } from "medusa-react"
|
||||||
|
|
||||||
const StoreCurrencies = () => {
|
const StoreCurrencies = () => {
|
||||||
const { store, isLoading } = useAdminStore()
|
const { store, isLoading } = useAdminStore()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -267,33 +267,33 @@ const StoreCurrencies = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default StoreCurrencies
|
export default StoreCurrencies
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/store`, {
|
fetch(`<BACKEND_URL>/admin/store`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ store }) => {
|
.then(({ store }) => {
|
||||||
console.log(store.currencies, store.default_currency)
|
console.log(store.currencies, store.default_currency)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/store' \
|
curl -L -X POST '<BACKEND_URL>/admin/store' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request returns the store as an object. In that object, there are two properties related to currencies:
|
This request returns the store as an object. In that object, there are two properties related to currencies:
|
||||||
@@ -306,22 +306,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.store.addCurrency(code)
|
medusa.admin.store.addCurrency(code)
|
||||||
.then(({ store }) => {
|
.then(({ store }) => {
|
||||||
console.log(store.currencies)
|
console.log(store.currencies)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminAddStoreCurrency } from "medusa-react"
|
import { useAdminAddStoreCurrency } from "medusa-react"
|
||||||
|
|
||||||
const AddCurrency = () => {
|
const AddCurrency = () => {
|
||||||
const addCode = useAdminAddStoreCurrency()
|
const addCode = useAdminAddStoreCurrency()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -330,34 +330,34 @@ const AddCurrency = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AddCurrency
|
export default AddCurrency
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/store/currencies/${code}`, {
|
fetch(`<BACKEND_URL>/admin/store/currencies/${code}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ store }) => {
|
.then(({ store }) => {
|
||||||
console.log(store.currencies)
|
console.log(store.currencies)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/store/currencies/<CODE>' \
|
curl -L -X POST '<BACKEND_URL>/admin/store/currencies/<CODE>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the currency code to be passed as a path parameter.
|
This API Route requires the currency code to be passed as a path parameter.
|
||||||
@@ -369,22 +369,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.store.deleteCurrency(code)
|
medusa.admin.store.deleteCurrency(code)
|
||||||
.then(({ store }) => {
|
.then(({ store }) => {
|
||||||
console.log(store.currencies)
|
console.log(store.currencies)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDeleteStoreCurrency } from "medusa-react"
|
import { useAdminDeleteStoreCurrency } from "medusa-react"
|
||||||
|
|
||||||
const DeleteCurrency = () => {
|
const DeleteCurrency = () => {
|
||||||
const deleteCurrency = useAdminDeleteStoreCurrency()
|
const deleteCurrency = useAdminDeleteStoreCurrency()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -393,34 +393,34 @@ const DeleteCurrency = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DeleteCurrency
|
export default DeleteCurrency
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/store/currencies/${code}`, {
|
fetch(`<BACKEND_URL>/admin/store/currencies/${code}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ store }) => {
|
.then(({ store }) => {
|
||||||
console.log(store.currencies)
|
console.log(store.currencies)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/store/currencies/<CODE>' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/store/currencies/<CODE>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the currency code to be passed as a path parameter.
|
This API Route requires the currency code to be passed as a path parameter.
|
||||||
|
|||||||
@@ -63,24 +63,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.regions.list()
|
medusa.admin.regions.list()
|
||||||
.then(({ regions, limit, offset, count }) => {
|
.then(({ regions, limit, offset, count }) => {
|
||||||
console.log(regions.length)
|
console.log(regions.length)
|
||||||
// display regions
|
// display regions
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { Region } from "@medusajs/medusa"
|
import { Region } from "@medusajs/medusa"
|
||||||
import { useAdminRegions } from "medusa-react"
|
import { useAdminRegions } from "medusa-react"
|
||||||
|
|
||||||
const Regions = () => {
|
const Regions = () => {
|
||||||
const { regions, isLoading } = useAdminRegions()
|
const { regions, isLoading } = useAdminRegions()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -96,34 +96,34 @@ const Regions = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Regions
|
export default Regions
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/regions`, {
|
fetch(`<BACKEND_URL>/admin/regions`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ regions, limit, offset, count }) => {
|
.then(({ regions, limit, offset, count }) => {
|
||||||
console.log(regions.length)
|
console.log(regions.length)
|
||||||
// display regions
|
// display regions
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/regions' \
|
curl -L -X GET '<BACKEND_URL>/admin/regions' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request returns an array of regions, as well as [pagination fields](https://docs.medusajs.com/api/admin#pagination).
|
This request returns an array of regions, as well as [pagination fields](https://docs.medusajs.com/api/admin#pagination).
|
||||||
@@ -137,10 +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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.regions.create({
|
medusa.admin.regions.create({
|
||||||
name: "Europe",
|
name: "Europe",
|
||||||
currency_code: "eur",
|
currency_code: "eur",
|
||||||
tax_rate: 0,
|
tax_rate: 0,
|
||||||
@@ -153,19 +153,19 @@ medusa.admin.regions.create({
|
|||||||
countries: [
|
countries: [
|
||||||
"DK",
|
"DK",
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.then(({ region }) => {
|
.then(({ region }) => {
|
||||||
console.log(region.id)
|
console.log(region.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateRegion } from "medusa-react"
|
import { useAdminCreateRegion } from "medusa-react"
|
||||||
|
|
||||||
const CreateRegion = () => {
|
const CreateRegion = () => {
|
||||||
const createRegion = useAdminCreateRegion()
|
const createRegion = useAdminCreateRegion()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -187,16 +187,16 @@ const CreateRegion = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateRegion
|
export default CreateRegion
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/regions`, {
|
fetch(`<BACKEND_URL>/admin/regions`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -216,21 +216,21 @@ fetch(`<BACKEND_URL>/admin/regions`, {
|
|||||||
"DK",
|
"DK",
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ region }) => {
|
.then(({ region }) => {
|
||||||
console.log(region.id)
|
console.log(region.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/regions' \
|
curl -L -X POST '<BACKEND_URL>/admin/regions' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"name": "Europe",
|
"name": "Europe",
|
||||||
"currency_code": "eur",
|
"currency_code": "eur",
|
||||||
"tax_rate": 0,
|
"tax_rate": 0,
|
||||||
@@ -243,10 +243,10 @@ curl -L -X POST '<BACKEND_URL>/admin/regions' \
|
|||||||
"countries": [
|
"countries": [
|
||||||
"DK"
|
"DK"
|
||||||
]
|
]
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the following body parameters:
|
This request requires the following body parameters:
|
||||||
@@ -271,27 +271,27 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.regions.update(regionId, {
|
medusa.admin.regions.update(regionId, {
|
||||||
countries: [
|
countries: [
|
||||||
"DK",
|
"DK",
|
||||||
"DE",
|
"DE",
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.then(({ region }) => {
|
.then(({ region }) => {
|
||||||
console.log(region.id)
|
console.log(region.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUpdateRegion } from "medusa-react"
|
import { useAdminUpdateRegion } from "medusa-react"
|
||||||
|
|
||||||
const UpdateRegion = () => {
|
const UpdateRegion = () => {
|
||||||
const updateRegion = useAdminUpdateRegion(regionId)
|
const updateRegion = useAdminUpdateRegion(regionId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -305,16 +305,16 @@ const UpdateRegion = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdateRegion
|
export default UpdateRegion
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/regions/${regionId}`, {
|
fetch(`<BACKEND_URL>/admin/regions/${regionId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -326,29 +326,29 @@ fetch(`<BACKEND_URL>/admin/regions/${regionId}`, {
|
|||||||
"DE",
|
"DE",
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ region }) => {
|
.then(({ region }) => {
|
||||||
console.log(region.id)
|
console.log(region.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/regions/<REGION_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/regions/<REGION_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"countries": [
|
"countries": [
|
||||||
"DK",
|
"DK",
|
||||||
"DE"
|
"DE"
|
||||||
]
|
]
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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.
|
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,10 +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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.shippingOptions.create({
|
medusa.admin.shippingOptions.create({
|
||||||
name: "PostFake",
|
name: "PostFake",
|
||||||
region_id: regionId,
|
region_id: regionId,
|
||||||
provider_id: "manual",
|
provider_id: "manual",
|
||||||
@@ -381,19 +381,19 @@ medusa.admin.shippingOptions.create({
|
|||||||
},
|
},
|
||||||
price_type: "flat_rate",
|
price_type: "flat_rate",
|
||||||
amount: 1000,
|
amount: 1000,
|
||||||
})
|
})
|
||||||
.then(({ shipping_option }) => {
|
.then(({ shipping_option }) => {
|
||||||
console.log(shipping_option.id)
|
console.log(shipping_option.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateShippingOption } from "medusa-react"
|
import { useAdminCreateShippingOption } from "medusa-react"
|
||||||
|
|
||||||
const Region = () => {
|
const Region = () => {
|
||||||
const createShippingOption = useAdminCreateShippingOption()
|
const createShippingOption = useAdminCreateShippingOption()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -410,16 +410,16 @@ const Region = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Region
|
export default Region
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/shipping-options`, {
|
fetch(`<BACKEND_URL>/admin/shipping-options`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -434,31 +434,31 @@ fetch(`<BACKEND_URL>/admin/shipping-options`, {
|
|||||||
},
|
},
|
||||||
amount: 1000,
|
amount: 1000,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ shipping_option }) => {
|
.then(({ shipping_option }) => {
|
||||||
console.log(shipping_option.id)
|
console.log(shipping_option.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/shipping-options' \
|
curl -L -X POST '<BACKEND_URL>/admin/shipping-options' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"name": "PostFake",
|
"name": "PostFake",
|
||||||
"region_id": "<REGION_ID>",
|
"region_id": "<REGION_ID>",
|
||||||
"provider_id": "manual",
|
"provider_id": "manual",
|
||||||
"price_type": "flat_rate",
|
"price_type": "flat_rate",
|
||||||
"data": {},
|
"data": {},
|
||||||
"amount": 1000
|
"amount": 1000
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the following body parameters:
|
This request requires the following body parameters:
|
||||||
@@ -489,22 +489,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.regions.delete(regionId)
|
medusa.admin.regions.delete(regionId)
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDeleteRegion } from "medusa-react"
|
import { useAdminDeleteRegion } from "medusa-react"
|
||||||
|
|
||||||
const Region = () => {
|
const Region = () => {
|
||||||
const deleteRegion = useAdminDeleteRegion(regionId)
|
const deleteRegion = useAdminDeleteRegion(regionId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -513,34 +513,34 @@ const Region = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Region
|
export default Region
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/regions/${regionId}`, {
|
fetch(`<BACKEND_URL>/admin/regions/${regionId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/regions/<REGION_ID>' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/regions/<REGION_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the region ID as a path parameter. It deletes the region and returns the following fields:
|
This request requires the region ID as a path parameter. It deletes the region and returns the following fields:
|
||||||
|
|||||||
@@ -55,24 +55,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.regions.list()
|
medusa.regions.list()
|
||||||
.then(({ regions }) => {
|
.then(({ regions }) => {
|
||||||
console.log(regions.length)
|
console.log(regions.length)
|
||||||
// show customers available regions
|
// show customers available regions
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { Region } from "@medusajs/medusa"
|
import { Region } from "@medusajs/medusa"
|
||||||
import { useRegions } from "medusa-react"
|
import { useRegions } from "medusa-react"
|
||||||
|
|
||||||
const Regions = () => {
|
const Regions = () => {
|
||||||
const { regions, isLoading } = useRegions()
|
const { regions, isLoading } = useRegions()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -89,26 +89,26 @@ const Regions = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Regions
|
export default Regions
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/regions`, {
|
fetch(`<BACKEND_URL>/store/regions`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ regions }) => {
|
.then(({ regions }) => {
|
||||||
console.log(regions.length)
|
console.log(regions.length)
|
||||||
// show customers available regions
|
// show customers available regions
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request returns the list of available regions. You can show them to your customers to select their region.
|
This request returns the list of available regions. You can show them to your customers to select their region.
|
||||||
@@ -124,25 +124,25 @@ To retrieve products with the prices based on the selected regions, you can pass
|
|||||||
For example:
|
For example:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.products.list({
|
medusa.products.list({
|
||||||
region_id: regionId,
|
region_id: regionId,
|
||||||
})
|
})
|
||||||
.then(({ products, limit, offset, count }) => {
|
.then(({ products, limit, offset, count }) => {
|
||||||
console.log(products.length)
|
console.log(products.length)
|
||||||
// show customer the products
|
// show customer the products
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { formatVariantPrice } from "medusa-react"
|
import { formatVariantPrice } from "medusa-react"
|
||||||
|
|
||||||
const Product = () => {
|
const Product = () => {
|
||||||
// retrieve the region and variant(s)
|
// retrieve the region and variant(s)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -154,26 +154,26 @@ const Product = () => {
|
|||||||
})}
|
})}
|
||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Product
|
export default Product
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/products?region_id=${regionId}`, {
|
fetch(`<BACKEND_URL>/store/products?region_id=${regionId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ products, limit, offset, count }) => {
|
.then(({ products, limit, offset, count }) => {
|
||||||
console.log(products.length)
|
console.log(products.length)
|
||||||
// show customer the products
|
// show customer the products
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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`.
|
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,24 +197,24 @@ You can learn how to implement cart functionalities in your storefront in [this
|
|||||||
For example:
|
For example:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.carts.update(cartId, {
|
medusa.carts.update(cartId, {
|
||||||
region_id: regionId,
|
region_id: regionId,
|
||||||
})
|
})
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
console.log(cart.id)
|
console.log(cart.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCart } from "medusa-react"
|
import { useCart } from "medusa-react"
|
||||||
|
|
||||||
const Cart = () => {
|
const Cart = () => {
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
const { updateCart } = useCart()
|
const { updateCart } = useCart()
|
||||||
@@ -226,29 +226,29 @@ const Cart = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Cart
|
export default Cart
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/carts/${cartId}`, {
|
fetch(`<BACKEND_URL>/store/carts/${cartId}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
region_id: regionId,
|
region_id: regionId,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
console.log(cart.id)
|
console.log(cart.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</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`.
|
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`.
|
||||||
|
|||||||
@@ -55,25 +55,25 @@ You can learn more about [authenticating as an admin user in the API reference](
|
|||||||
You can create a sales channel by sending a request to the Create a Sales Channel API Route:
|
You can create a sales channel by sending a request to the Create a Sales Channel API Route:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.salesChannels.create({
|
medusa.admin.salesChannels.create({
|
||||||
name: "App",
|
name: "App",
|
||||||
description: "Mobile app",
|
description: "Mobile app",
|
||||||
})
|
})
|
||||||
.then(({ sales_channel }) => {
|
.then(({ sales_channel }) => {
|
||||||
console.log(sales_channel.id)
|
console.log(sales_channel.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateSalesChannel } from "medusa-react"
|
import { useAdminCreateSalesChannel } from "medusa-react"
|
||||||
|
|
||||||
const CreateSalesChannel = () => {
|
const CreateSalesChannel = () => {
|
||||||
const createSalesChannel = useAdminCreateSalesChannel()
|
const createSalesChannel = useAdminCreateSalesChannel()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -85,16 +85,16 @@ const CreateSalesChannel = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateSalesChannel
|
export default CreateSalesChannel
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/sales-channels`, {
|
fetch(`<BACKEND_URL>/admin/sales-channels`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -104,27 +104,27 @@ fetch(`<BACKEND_URL>/admin/sales-channels`, {
|
|||||||
name: "App",
|
name: "App",
|
||||||
description: "Mobile app",
|
description: "Mobile app",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ sales_channel }) => {
|
.then(({ sales_channel }) => {
|
||||||
console.log(sales_channel.id)
|
console.log(sales_channel.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/sales-channels' \
|
curl -L -X POST '<BACKEND_URL>/admin/sales-channels' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
name: 'App',
|
name: 'App',
|
||||||
description: 'Mobile app'
|
description: 'Mobile app'
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request requires the request body parameters `name`, and optionally accepts the `description` and `is_disabled` request body parameters.
|
This request requires the request body parameters `name`, and optionally accepts the `description` and `is_disabled` request body parameters.
|
||||||
@@ -138,23 +138,23 @@ It returns the created sales channel.
|
|||||||
You can list all sales channels by sending a request to the List Sales Channels API Route:
|
You can list all sales channels by sending a request to the List Sales Channels API Route:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.salesChannels.list()
|
medusa.admin.salesChannels.list()
|
||||||
.then(({ sales_channels, limit, offset, count }) => {
|
.then(({ sales_channels, limit, offset, count }) => {
|
||||||
console.log(sales_channels.length)
|
console.log(sales_channels.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { SalesChannel } from "@medusajs/medusa"
|
import { SalesChannel } from "@medusajs/medusa"
|
||||||
import { useAdminSalesChannels } from "medusa-react"
|
import { useAdminSalesChannels } from "medusa-react"
|
||||||
|
|
||||||
const SalesChannels = () => {
|
const SalesChannels = () => {
|
||||||
const { sales_channels, isLoading } = useAdminSalesChannels()
|
const { sales_channels, isLoading } = useAdminSalesChannels()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -172,33 +172,33 @@ const SalesChannels = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SalesChannels
|
export default SalesChannels
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/sales-channels`, {
|
fetch(`<BACKEND_URL>/admin/sales-channels`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ sales_channels, limit, offset, count }) => {
|
.then(({ sales_channels, limit, offset, count }) => {
|
||||||
console.log(sales_channels.length)
|
console.log(sales_channels.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/sales-channels' \
|
curl -L -X GET '<BACKEND_URL>/admin/sales-channels' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request returns an array of all sales channels in your store. You can also pass query parameters to filter or customize the pagination of the results. Check out [the API Reference for a full list of query parameters.](https://docs.medusajs.com/api/admin#sales-channels_getsaleschannels)
|
This request returns an array of all sales channels in your store. You can also pass query parameters to filter or customize the pagination of the results. Check out [the API Reference for a full list of query parameters.](https://docs.medusajs.com/api/admin#sales-channels_getsaleschannels)
|
||||||
@@ -210,22 +210,22 @@ This request returns an array of all sales channels in your store. You can also
|
|||||||
You can retrieve a sales channel’s details by its ID using the Get Sales Channel API Route:
|
You can retrieve a sales channel’s details by its ID using the Get Sales Channel API Route:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.salesChannels.retrieve(salesChannelId)
|
medusa.admin.salesChannels.retrieve(salesChannelId)
|
||||||
.then(({ sales_channel }) => {
|
.then(({ sales_channel }) => {
|
||||||
console.log(sales_channel.id)
|
console.log(sales_channel.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminSalesChannel } from "medusa-react"
|
import { useAdminSalesChannel } from "medusa-react"
|
||||||
|
|
||||||
const SalesChannel = () => {
|
const SalesChannel = () => {
|
||||||
const {
|
const {
|
||||||
sales_channel,
|
sales_channel,
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -237,33 +237,33 @@ const SalesChannel = () => {
|
|||||||
{sales_channel && <span>{sales_channel.name}</span>}
|
{sales_channel && <span>{sales_channel.name}</span>}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SalesChannel
|
export default SalesChannel
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/sales-channels/${salesChannelId}`, {
|
fetch(`<BACKEND_URL>/admin/sales-channels/${salesChannelId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ sales_channels, limit, offset, count }) => {
|
.then(({ sales_channels, limit, offset, count }) => {
|
||||||
console.log(sales_channels.length)
|
console.log(sales_channels.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/sales-channels/<SALES_CHANNEL_ID>' \
|
curl -L -X GET '<BACKEND_URL>/admin/sales-channels/<SALES_CHANNEL_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request returns the sales channel with the specified ID.
|
This request returns the sales channel with the specified ID.
|
||||||
@@ -275,24 +275,24 @@ This request returns the sales channel with the specified ID.
|
|||||||
You can update a Sales Channel’s details and attributes by sending a request to the Update Sales Channel API Route:
|
You can update a Sales Channel’s details and attributes by sending a request to the Update Sales Channel API Route:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.salesChannels.update(salesChannelId, {
|
medusa.admin.salesChannels.update(salesChannelId, {
|
||||||
is_disabled: false,
|
is_disabled: false,
|
||||||
})
|
})
|
||||||
.then(({ sales_channel }) => {
|
.then(({ sales_channel }) => {
|
||||||
console.log(sales_channel.id)
|
console.log(sales_channel.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUpdateSalesChannel } from "medusa-react"
|
import { useAdminUpdateSalesChannel } from "medusa-react"
|
||||||
|
|
||||||
const UpdateSalesChannel = () => {
|
const UpdateSalesChannel = () => {
|
||||||
const updateSalesChannel = useAdminUpdateSalesChannel(
|
const updateSalesChannel = useAdminUpdateSalesChannel(
|
||||||
salesChannelId
|
salesChannelId
|
||||||
)
|
)
|
||||||
@@ -305,16 +305,16 @@ const UpdateSalesChannel = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdateSalesChannel
|
export default UpdateSalesChannel
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/sales-channels/${salesChannelId}`, {
|
fetch(`<BACKEND_URL>/admin/sales-channels/${salesChannelId}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -323,26 +323,26 @@ fetch(`<BACKEND_URL>/admin/sales-channels/${salesChannelId}`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
is_disabled: false,
|
is_disabled: false,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ sales_channel }) => {
|
.then(({ sales_channel }) => {
|
||||||
console.log(sales_channel.id)
|
console.log(sales_channel.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/sales-channels/<SALES_CHANNEL_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/sales-channels/<SALES_CHANNEL_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"is_disabled": false
|
"is_disabled": false
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
In this example, you enable a sales channel by changing the value of the `is_disabled` attribute.
|
In this example, you enable a sales channel by changing the value of the `is_disabled` attribute.
|
||||||
@@ -358,22 +358,22 @@ You can check out [the API Reference for a full list of body parameters](https:/
|
|||||||
You can delete a sales channel by sending a request to the Delete Sales Channel API Route with the ID of the sales channel to delete:
|
You can delete a sales channel by sending a request to the Delete Sales Channel API Route with the ID of the sales channel to delete:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.salesChannels.delete(salesChannelId)
|
medusa.admin.salesChannels.delete(salesChannelId)
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDeleteSalesChannel } from "medusa-react"
|
import { useAdminDeleteSalesChannel } from "medusa-react"
|
||||||
|
|
||||||
const SalesChannel = () => {
|
const SalesChannel = () => {
|
||||||
const deleteSalesChannel = useAdminDeleteSalesChannel(
|
const deleteSalesChannel = useAdminDeleteSalesChannel(
|
||||||
salesChannelId
|
salesChannelId
|
||||||
)
|
)
|
||||||
@@ -384,34 +384,34 @@ const SalesChannel = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SalesChannel
|
export default SalesChannel
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/sales-channels/${salesChannelId}`, {
|
fetch(`<BACKEND_URL>/admin/sales-channels/${salesChannelId}`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/sales-channels/<SALES_CHANNEL_ID>' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/sales-channels/<SALES_CHANNEL_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
The ID of the deleted sales channel is returned in the response.
|
The ID of the deleted sales channel is returned in the response.
|
||||||
@@ -425,28 +425,28 @@ The ID of the deleted sales channel is returned in the response.
|
|||||||
To add a product to a sales channel, send a request to the Sales Channel’s Add Products API Route:
|
To add a product to a sales channel, send a request to the Sales Channel’s Add Products API Route:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.salesChannels.addProducts(salesChannelId, {
|
medusa.admin.salesChannels.addProducts(salesChannelId, {
|
||||||
product_ids: [
|
product_ids: [
|
||||||
{
|
{
|
||||||
id: productId,
|
id: productId,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.then(({ sales_channel }) => {
|
.then(({ sales_channel }) => {
|
||||||
console.log(sales_channel.id)
|
console.log(sales_channel.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminAddProductsToSalesChannel } from "medusa-react"
|
import { useAdminAddProductsToSalesChannel } from "medusa-react"
|
||||||
|
|
||||||
const SalesChannel = () => {
|
const SalesChannel = () => {
|
||||||
const addProducts = useAdminAddProductsToSalesChannel(
|
const addProducts = useAdminAddProductsToSalesChannel(
|
||||||
salesChannelId
|
salesChannelId
|
||||||
)
|
)
|
||||||
@@ -463,18 +463,18 @@ const SalesChannel = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SalesChannel
|
export default SalesChannel
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/admin/sales-channels/${salesChannelId}/products/batch`,
|
`<BACKEND_URL>/admin/sales-channels/${salesChannelId}/products/batch`,
|
||||||
{
|
{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -490,30 +490,30 @@ fetch(
|
|||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ sales_channel }) => {
|
.then(({ sales_channel }) => {
|
||||||
console.log(sales_channel.id)
|
console.log(sales_channel.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/sales-channels/<SALES_CHANNEL_ID>/products/batch' \
|
curl -L -X POST '<BACKEND_URL>/admin/sales-channels/<SALES_CHANNEL_ID>/products/batch' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"product_ids": [
|
"product_ids": [
|
||||||
{
|
{
|
||||||
"id": "<PRODUCT_ID>"
|
"id": "<PRODUCT_ID>"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request accepts the `product_ids` body parameter, which is an array of objects. Each object in the array must have an `id` property with the ID of the product to add as a value.
|
This request accepts the `product_ids` body parameter, which is an array of objects. Each object in the array must have an `id` property with the ID of the product to add as a value.
|
||||||
@@ -525,30 +525,30 @@ This request returns the sales channel.
|
|||||||
You can list the products available in a sales channel by sending a request to the List Products API Route and passing the `sales_channel_id` query parameter to filter by a specific sales channel:
|
You can list the products available in a sales channel by sending a request to the List Products API Route and passing the `sales_channel_id` query parameter to filter by a specific sales channel:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.products.list({
|
medusa.admin.products.list({
|
||||||
sales_channel_id: [
|
sales_channel_id: [
|
||||||
salesChannelId,
|
salesChannelId,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.then(({ products, limit, offset, count }) => {
|
.then(({ products, limit, offset, count }) => {
|
||||||
console.log(products.length)
|
console.log(products.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { Product } from "@medusajs/medusa"
|
import { Product } from "@medusajs/medusa"
|
||||||
import {
|
import {
|
||||||
PricedProduct,
|
PricedProduct,
|
||||||
} from "@medusajs/medusa/dist/types/pricing"
|
} from "@medusajs/medusa/dist/types/pricing"
|
||||||
import { useAdminProducts } from "medusa-react"
|
import { useAdminProducts } from "medusa-react"
|
||||||
|
|
||||||
const SalesChannelProducts = () => {
|
const SalesChannelProducts = () => {
|
||||||
const { products, isLoading } = useAdminProducts({
|
const { products, isLoading } = useAdminProducts({
|
||||||
sales_channel_id: [salesChannelId],
|
sales_channel_id: [salesChannelId],
|
||||||
})
|
})
|
||||||
@@ -570,38 +570,38 @@ const SalesChannelProducts = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SalesChannelProducts
|
export default SalesChannelProducts
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/admin/products?sales_channel_id[0]=${salesChannelId}`,
|
`<BACKEND_URL>/admin/products?sales_channel_id[0]=${salesChannelId}`,
|
||||||
{
|
{
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ products, limit, offset, count }) => {
|
.then(({ products, limit, offset, count }) => {
|
||||||
console.log(products.length)
|
console.log(products.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/products?sales_channel_id[0]=<SALES_CHANNEL_ID>' \
|
curl -L -X GET '<BACKEND_URL>/admin/products?sales_channel_id[0]=<SALES_CHANNEL_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
The request returns an array of products that are available in the specified sales channel.
|
The request returns an array of products that are available in the specified sales channel.
|
||||||
@@ -617,32 +617,32 @@ Deleting a product from a sales channel doesn't delete it completely. It only ma
|
|||||||
You can delete a product from a sales channel by sending a request to the Sales Channel’s Delete Products API Route:
|
You can delete a product from a sales channel by sending a request to the Sales Channel’s Delete Products API Route:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<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 -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.salesChannels.removeProducts(salesChannelId, {
|
medusa.admin.salesChannels.removeProducts(salesChannelId, {
|
||||||
product_ids: [
|
product_ids: [
|
||||||
{
|
{
|
||||||
id: productId,
|
id: productId,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.then(({ sales_channel }) => {
|
.then(({ sales_channel }) => {
|
||||||
console.log(sales_channel.id)
|
console.log(sales_channel.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import {
|
import {
|
||||||
useAdminDeleteProductsFromSalesChannel,
|
useAdminDeleteProductsFromSalesChannel,
|
||||||
} from "medusa-react"
|
} from "medusa-react"
|
||||||
|
|
||||||
const SalesChannel = () => {
|
const SalesChannel = () => {
|
||||||
const deleteProducts = useAdminDeleteProductsFromSalesChannel(
|
const deleteProducts = useAdminDeleteProductsFromSalesChannel(
|
||||||
salesChannelId
|
salesChannelId
|
||||||
)
|
)
|
||||||
@@ -659,18 +659,18 @@ const SalesChannel = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SalesChannel
|
export default SalesChannel
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(
|
fetch(
|
||||||
`<BACKEND_URL>/admin/sales-channels/${salesChannelId}/products/batch`,
|
`<BACKEND_URL>/admin/sales-channels/${salesChannelId}/products/batch`,
|
||||||
{
|
{
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
@@ -686,30 +686,30 @@ fetch(
|
|||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ sales_channel }) => {
|
.then(({ sales_channel }) => {
|
||||||
console.log(sales_channel.id)
|
console.log(sales_channel.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/sales-channels/<SALES_CHANNEL_ID>/products/batch' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/sales-channels/<SALES_CHANNEL_ID>/products/batch' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"product_ids": [
|
"product_ids": [
|
||||||
{
|
{
|
||||||
"id": "<PRODUCT_ID>"
|
"id": "<PRODUCT_ID>"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This request accepts the `product_ids` body parameter, which is an array of objects. Each object in the array must have an `id` property with the ID of the product to delete as a value.
|
This request accepts the `product_ids` body parameter, which is an array of objects. Each object in the array must have an `id` property with the ID of the product to delete as a value.
|
||||||
@@ -723,29 +723,29 @@ This request returns the sales channel.
|
|||||||
You can filter orders by a specific sales channel by sending a request to the List Orders API Route and passing the `sales_channel_id` query parameter to filter by a specific sales channel:
|
You can filter orders by a specific sales channel by sending a request to the List Orders API Route and passing the `sales_channel_id` query parameter to filter by a specific sales channel:
|
||||||
|
|
||||||
<Tabs groupId="request-type" isCodeTabs={true}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.orders.list({
|
medusa.admin.orders.list({
|
||||||
sales_channel_id: [
|
sales_channel_id: [
|
||||||
salesChannelId,
|
salesChannelId,
|
||||||
],
|
],
|
||||||
limit: 50,
|
limit: 50,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
})
|
})
|
||||||
.then(({ orders, limit, offset, count }) => {
|
.then(({ orders, limit, offset, count }) => {
|
||||||
console.log(orders.length)
|
console.log(orders.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { Order } from "@medusajs/medusa"
|
import { Order } from "@medusajs/medusa"
|
||||||
import { useAdminOrders } from "medusa-react"
|
import { useAdminOrders } from "medusa-react"
|
||||||
|
|
||||||
const SalesChannelOrders = () => {
|
const SalesChannelOrders = () => {
|
||||||
const { orders, isLoading } = useAdminOrders({
|
const { orders, isLoading } = useAdminOrders({
|
||||||
sales_channel_id: [salesChannelId],
|
sales_channel_id: [salesChannelId],
|
||||||
offset: 0,
|
offset: 0,
|
||||||
@@ -765,35 +765,35 @@ const SalesChannelOrders = () => {
|
|||||||
{orders && !orders.length && <span>No Orders</span>}
|
{orders && !orders.length && <span>No Orders</span>}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SalesChannelOrders
|
export default SalesChannelOrders
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/orders?sales_channel_id[0]=${salesChannelId}`, {
|
fetch(`<BACKEND_URL>/admin/orders?sales_channel_id[0]=${salesChannelId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ orders, limit, offset, count }) => {
|
.then(({ orders, limit, offset, count }) => {
|
||||||
console.log(orders.length)
|
console.log(orders.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/orders?sales_channel_id[0]=<SALES_CHANNEL_ID>' \
|
curl -L -X GET '<BACKEND_URL>/admin/orders?sales_channel_id[0]=<SALES_CHANNEL_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
The request returns an array of orders that are associated with the specified sales channel.
|
The request returns an array of orders that are associated with the specified sales channel.
|
||||||
@@ -56,27 +56,27 @@ 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:
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.products.list({
|
medusa.products.list({
|
||||||
sales_channel_id: [
|
sales_channel_id: [
|
||||||
salesChannelId,
|
salesChannelId,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.then(({ products, limit, offset, count }) => {
|
.then(({ products, limit, offset, count }) => {
|
||||||
console.log(products.length)
|
console.log(products.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { Product } from "@medusajs/medusa"
|
import { Product } from "@medusajs/medusa"
|
||||||
import { useProducts } from "medusa-react"
|
import { useProducts } from "medusa-react"
|
||||||
|
|
||||||
const Products = () => {
|
const Products = () => {
|
||||||
const { products, isLoading } = useProducts({
|
const { products, isLoading } = useProducts({
|
||||||
sales_channel_id: [
|
sales_channel_id: [
|
||||||
salesChannelId,
|
salesChannelId,
|
||||||
@@ -96,25 +96,25 @@ const Products = () => {
|
|||||||
{products && !products.length && <span>No Products</span>}
|
{products && !products.length && <span>No Products</span>}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Products
|
export default Products
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/products?sales_channel_id[0]=${salesChannelId}`)
|
fetch(`<BACKEND_URL>/store/products?sales_channel_id[0]=${salesChannelId}`)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ products, limit, offset, count }) => {
|
.then(({ products, limit, offset, count }) => {
|
||||||
console.log(products.length)
|
console.log(products.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
The `sales_channel_id` query parameter is an array of sales channel IDs. You can pass more than one sales channel.
|
The `sales_channel_id` query parameter is an array of sales channel IDs. You can pass more than one sales channel.
|
||||||
@@ -130,25 +130,24 @@ 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:
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
|
```ts
|
||||||
```ts
|
medusa.carts.create({
|
||||||
medusa.carts.create({
|
|
||||||
sales_channel_id: salesChannelId,
|
sales_channel_id: salesChannelId,
|
||||||
})
|
})
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
console.log(cart.id)
|
console.log(cart.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCart } from "medusa-react"
|
import { useCart } from "medusa-react"
|
||||||
|
|
||||||
const Cart = () => {
|
const Cart = () => {
|
||||||
const { cart, createCart } = useCart()
|
const { cart, createCart } = useCart()
|
||||||
|
|
||||||
const handleCreateCart = () => {
|
const handleCreateCart = () => {
|
||||||
@@ -165,16 +164,16 @@ const Cart = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Cart
|
export default Cart
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/carts`, {
|
fetch(`<BACKEND_URL>/store/carts`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -182,14 +181,14 @@ fetch(`<BACKEND_URL>/store/carts`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
sales_channel_id: salesChannelId,
|
sales_channel_id: salesChannelId,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
console.log(cart.id)
|
console.log(cart.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
The request returns the created cart.
|
The request returns the created cart.
|
||||||
@@ -199,24 +198,24 @@ 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:
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.carts.update(cartId, {
|
medusa.carts.update(cartId, {
|
||||||
sales_channel_id: salesChannelId,
|
sales_channel_id: salesChannelId,
|
||||||
})
|
})
|
||||||
.then(({ cart }) => {
|
.then(({ cart }) => {
|
||||||
console.log(cart.id)
|
console.log(cart.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCart } from "medusa-react"
|
import { useCart } from "medusa-react"
|
||||||
|
|
||||||
const Cart = () => {
|
const Cart = () => {
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
const { updateCart } = useCart()
|
const { updateCart } = useCart()
|
||||||
@@ -228,16 +227,16 @@ const Cart = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Cart
|
export default Cart
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/store/carts/${cartId}`, {
|
fetch(`<BACKEND_URL>/store/carts/${cartId}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -245,12 +244,12 @@ fetch(`<BACKEND_URL>/store/carts/${cartId}`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
sales_channel_id: salesChannelId,
|
sales_channel_id: salesChannelId,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ cart }) => console.log(cart.id))
|
.then(({ cart }) => console.log(cart.id))
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
The request returns the updated cart.
|
The request returns the updated cart.
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -55,22 +55,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.store.listTaxProviders()
|
medusa.admin.store.listTaxProviders()
|
||||||
.then(({ tax_providers }) => {
|
.then(({ tax_providers }) => {
|
||||||
console.log(tax_providers.length)
|
console.log(tax_providers.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminStoreTaxProviders } from "medusa-react"
|
import { useAdminStoreTaxProviders } from "medusa-react"
|
||||||
|
|
||||||
const TaxProviders = () => {
|
const TaxProviders = () => {
|
||||||
const {
|
const {
|
||||||
tax_providers,
|
tax_providers,
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -91,33 +91,33 @@ const TaxProviders = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default TaxProviders
|
export default TaxProviders
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/store/tax-providers`, {
|
fetch(`<BACKEND_URL>/admin/store/tax-providers`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ tax_providers }) => {
|
.then(({ tax_providers }) => {
|
||||||
console.log(tax_providers.length)
|
console.log(tax_providers.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/store/tax-providers' \
|
curl -L -X GET '<BACKEND_URL>/admin/store/tax-providers' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route doesn't accept any parameters.
|
This API Route doesn't accept any parameters.
|
||||||
@@ -131,24 +131,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.regions.update(regionId, {
|
medusa.admin.regions.update(regionId, {
|
||||||
tax_provider_id,
|
tax_provider_id,
|
||||||
})
|
})
|
||||||
.then(({ region }) => {
|
.then(({ region }) => {
|
||||||
console.log(region.id)
|
console.log(region.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUpdateRegion } from "medusa-react"
|
import { useAdminUpdateRegion } from "medusa-react"
|
||||||
|
|
||||||
const UpdateRegion = () => {
|
const UpdateRegion = () => {
|
||||||
const updateRegion = useAdminUpdateRegion(regionId)
|
const updateRegion = useAdminUpdateRegion(regionId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -159,16 +159,16 @@ const UpdateRegion = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdateRegion
|
export default UpdateRegion
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/regions/${regionId}`, {
|
fetch(`<BACKEND_URL>/admin/regions/${regionId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -177,26 +177,26 @@ fetch(`<BACKEND_URL>/admin/regions/${regionId}`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
tax_provider_id,
|
tax_provider_id,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ region }) => {
|
.then(({ region }) => {
|
||||||
console.log(region.id)
|
console.log(region.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/regions/<REGION_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/regions/<REGION_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"tax_provider_id": "<TAX_PROVIDER_ID>"
|
"tax_provider_id": "<TAX_PROVIDER_ID>"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the ID of the region to be passed as a path parameter.
|
This API Route requires the ID of the region to be passed as a path parameter.
|
||||||
@@ -212,28 +212,28 @@ 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:
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.regions.update(regionId, {
|
medusa.admin.regions.update(regionId, {
|
||||||
tax_provider_id,
|
tax_provider_id,
|
||||||
automatic_taxes,
|
automatic_taxes,
|
||||||
gift_cards_taxable,
|
gift_cards_taxable,
|
||||||
tax_code,
|
tax_code,
|
||||||
tax_rate,
|
tax_rate,
|
||||||
})
|
})
|
||||||
.then(({ region }) => {
|
.then(({ region }) => {
|
||||||
console.log(region.id)
|
console.log(region.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUpdateRegion } from "medusa-react"
|
import { useAdminUpdateRegion } from "medusa-react"
|
||||||
|
|
||||||
const UpdateRegion = () => {
|
const UpdateRegion = () => {
|
||||||
const updateRegion = useAdminUpdateRegion(regionId)
|
const updateRegion = useAdminUpdateRegion(regionId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -248,16 +248,16 @@ const UpdateRegion = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdateRegion
|
export default UpdateRegion
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/regions/${regionId}`, {
|
fetch(`<BACKEND_URL>/admin/regions/${regionId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -270,30 +270,30 @@ fetch(`<BACKEND_URL>/admin/regions/${regionId}`, {
|
|||||||
tax_code,
|
tax_code,
|
||||||
tax_rate,
|
tax_rate,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ region }) => {
|
.then(({ region }) => {
|
||||||
console.log(region.id)
|
console.log(region.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/regions/<REGION_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/regions/<REGION_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"tax_provider_id": "<TAX_PROVIDER_ID>",
|
"tax_provider_id": "<TAX_PROVIDER_ID>",
|
||||||
"automatic_taxes": true,
|
"automatic_taxes": true,
|
||||||
"gift_cards_taxable": true,
|
"gift_cards_taxable": true,
|
||||||
"tax_code": "<TAX_CODE>",
|
"tax_code": "<TAX_CODE>",
|
||||||
"tax_rate": 10
|
"tax_rate": 10
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
You can pass the following parameters in the body of the request that are related to tax settings:
|
You can pass the following parameters in the body of the request that are related to tax settings:
|
||||||
|
|||||||
@@ -57,22 +57,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.invites.list()
|
medusa.admin.invites.list()
|
||||||
.then(({ invites }) => {
|
.then(({ invites }) => {
|
||||||
console.log(invites.length)
|
console.log(invites.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminInvites } from "medusa-react"
|
import { useAdminInvites } from "medusa-react"
|
||||||
|
|
||||||
const Invites = () => {
|
const Invites = () => {
|
||||||
const { invites, isLoading } = useAdminInvites()
|
const { invites, isLoading } = useAdminInvites()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -88,33 +88,33 @@ const Invites = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Invites
|
export default Invites
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/invites`, {
|
fetch(`<BACKEND_URL>/admin/invites`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ invites }) => {
|
.then(({ invites }) => {
|
||||||
console.log(invites.length)
|
console.log(invites.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/invites' \
|
curl -L -X GET '<BACKEND_URL>/admin/invites' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route doesn't accept any parameters.
|
This API Route doesn't accept any parameters.
|
||||||
@@ -128,25 +128,25 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.invites.create({
|
medusa.admin.invites.create({
|
||||||
user: "user@example.com",
|
user: "user@example.com",
|
||||||
role: "admin",
|
role: "admin",
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// successful
|
// successful
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateInvite } from "medusa-react"
|
import { useAdminCreateInvite } from "medusa-react"
|
||||||
|
|
||||||
const CreateInvite = () => {
|
const CreateInvite = () => {
|
||||||
const createInvite = useAdminCreateInvite()
|
const createInvite = useAdminCreateInvite()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -158,16 +158,16 @@ const CreateInvite = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateInvite
|
export default CreateInvite
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/invites`, {
|
fetch(`<BACKEND_URL>/admin/invites`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -177,27 +177,27 @@ fetch(`<BACKEND_URL>/admin/invites`, {
|
|||||||
user: "user@example.com",
|
user: "user@example.com",
|
||||||
role: "admin",
|
role: "admin",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// successful
|
// successful
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/invites' \
|
curl -L -X POST '<BACKEND_URL>/admin/invites' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"user": "user@example.com",
|
"user": "user@example.com",
|
||||||
"role": "admin"
|
"role": "admin"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the following body parameters:
|
This API Route requires the following body parameters:
|
||||||
@@ -216,29 +216,29 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.invites.accept({
|
medusa.admin.invites.accept({
|
||||||
token,
|
token,
|
||||||
user: {
|
user: {
|
||||||
first_name: "Brigitte",
|
first_name: "Brigitte",
|
||||||
last_name: "Collier",
|
last_name: "Collier",
|
||||||
password: "supersecret",
|
password: "supersecret",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// successful
|
// successful
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminAcceptInvite } from "medusa-react"
|
import { useAdminAcceptInvite } from "medusa-react"
|
||||||
|
|
||||||
const AcceptInvite = () => {
|
const AcceptInvite = () => {
|
||||||
const acceptInvite = useAdminAcceptInvite()
|
const acceptInvite = useAdminAcceptInvite()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -254,16 +254,16 @@ const AcceptInvite = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AcceptInvite
|
export default AcceptInvite
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/invites/accept`, {
|
fetch(`<BACKEND_URL>/admin/invites/accept`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -277,30 +277,30 @@ fetch(`<BACKEND_URL>/admin/invites/accept`, {
|
|||||||
password: "supersecret",
|
password: "supersecret",
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// successful
|
// successful
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/invites/accept' \
|
curl -L -X POST '<BACKEND_URL>/admin/invites/accept' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"token": "<TOKEN>",
|
"token": "<TOKEN>",
|
||||||
"user": {
|
"user": {
|
||||||
"first_name": "Brigitte",
|
"first_name": "Brigitte",
|
||||||
"last_name": "Collier",
|
"last_name": "Collier",
|
||||||
"password": "supersecret"
|
"password": "supersecret"
|
||||||
}
|
}
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the following request body parameters:
|
This API Route requires the following request body parameters:
|
||||||
@@ -320,22 +320,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.invites.resend(inviteId)
|
medusa.admin.invites.resend(inviteId)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// successful
|
// successful
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminResendInvite } from "medusa-react"
|
import { useAdminResendInvite } from "medusa-react"
|
||||||
|
|
||||||
const ResendInvite = () => {
|
const ResendInvite = () => {
|
||||||
const resendInvite = useAdminResendInvite(inviteId)
|
const resendInvite = useAdminResendInvite(inviteId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -344,34 +344,34 @@ const ResendInvite = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ResendInvite
|
export default ResendInvite
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/invites/${inviteId}/resend`, {
|
fetch(`<BACKEND_URL>/admin/invites/${inviteId}/resend`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// successful
|
// successful
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/invites/<INVITE_ID>/resend' \
|
curl -L -X POST '<BACKEND_URL>/admin/invites/<INVITE_ID>/resend' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the invite ID as a path parameter.
|
This API Route requires the invite ID as a path parameter.
|
||||||
@@ -385,22 +385,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.invites.delete(inviteId)
|
medusa.admin.invites.delete(inviteId)
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDeleteInvite } from "medusa-react"
|
import { useAdminDeleteInvite } from "medusa-react"
|
||||||
|
|
||||||
const DeleteInvite = () => {
|
const DeleteInvite = () => {
|
||||||
const deleteInvite = useAdminDeleteInvite(inviteId)
|
const deleteInvite = useAdminDeleteInvite(inviteId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -409,34 +409,34 @@ const DeleteInvite = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DeleteInvite
|
export default DeleteInvite
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/invites/${inviteId}`, {
|
fetch(`<BACKEND_URL>/admin/invites/${inviteId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/invites/<INVITE_ID>' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/invites/<INVITE_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the invite ID as a path parameter.
|
This API Route requires the invite ID as a path parameter.
|
||||||
|
|||||||
@@ -55,25 +55,25 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.auth.createSession({
|
medusa.admin.auth.createSession({
|
||||||
email: "user@example.com",
|
email: "user@example.com",
|
||||||
password: "supersecret",
|
password: "supersecret",
|
||||||
})
|
})
|
||||||
.then(({ user }) => {
|
.then(({ user }) => {
|
||||||
console.log(user.id)
|
console.log(user.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminLogin } from "medusa-react"
|
import { useAdminLogin } from "medusa-react"
|
||||||
|
|
||||||
const Login = () => {
|
const Login = () => {
|
||||||
const adminLogin = useAdminLogin()
|
const adminLogin = useAdminLogin()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -85,16 +85,16 @@ const Login = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Login
|
export default Login
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/auth`, {
|
fetch(`<BACKEND_URL>/admin/auth`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -104,26 +104,26 @@ fetch(`<BACKEND_URL>/admin/auth`, {
|
|||||||
email: "user@example.com",
|
email: "user@example.com",
|
||||||
password: "supersecret",
|
password: "supersecret",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ user }) => {
|
.then(({ user }) => {
|
||||||
console.log(user.id)
|
console.log(user.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/auth' \
|
curl -L -X POST '<BACKEND_URL>/admin/auth' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"email": "user@example.com",
|
"email": "user@example.com",
|
||||||
"password": "supersecret"
|
"password": "supersecret"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the following request body parameters:
|
This API Route requires the following request body parameters:
|
||||||
@@ -138,22 +138,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.auth.deleteSession()
|
medusa.admin.auth.deleteSession()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// logged out successfully
|
// logged out successfully
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDeleteSession } from "medusa-react"
|
import { useAdminDeleteSession } from "medusa-react"
|
||||||
|
|
||||||
const Logout = () => {
|
const Logout = () => {
|
||||||
const adminLogout = useAdminDeleteSession()
|
const adminLogout = useAdminDeleteSession()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -162,34 +162,34 @@ const Logout = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Logout
|
export default Logout
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/auth`, {
|
fetch(`<BACKEND_URL>/admin/auth`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// logged out successfully
|
// logged out successfully
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/auth' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/auth' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
The API Route doesn't require any path or query parameters.
|
The API Route doesn't require any path or query parameters.
|
||||||
@@ -203,22 +203,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.auth.getSession()
|
medusa.admin.auth.getSession()
|
||||||
.then(({ user }) => {
|
.then(({ user }) => {
|
||||||
console.log(user.id)
|
console.log(user.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminGetSession } from "medusa-react"
|
import { useAdminGetSession } from "medusa-react"
|
||||||
|
|
||||||
const Profile = () => {
|
const Profile = () => {
|
||||||
const { user, isLoading } = useAdminGetSession()
|
const { user, isLoading } = useAdminGetSession()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -227,33 +227,33 @@ const Profile = () => {
|
|||||||
{user && <span>{user.email}</span>}
|
{user && <span>{user.email}</span>}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Profile
|
export default Profile
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/auth`, {
|
fetch(`<BACKEND_URL>/admin/auth`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ user }) => {
|
.then(({ user }) => {
|
||||||
console.log(user.id)
|
console.log(user.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/auth' \
|
curl -L -X GET '<BACKEND_URL>/admin/auth' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route doesn't require any parameters.
|
This API Route doesn't require any parameters.
|
||||||
@@ -267,27 +267,27 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.users.update(userId, {
|
medusa.admin.users.update(userId, {
|
||||||
first_name: "Marcellus",
|
first_name: "Marcellus",
|
||||||
})
|
})
|
||||||
.then(({ user }) => {
|
.then(({ user }) => {
|
||||||
console.log(user.id)
|
console.log(user.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import {
|
import {
|
||||||
useAdminDeleteSession,
|
useAdminDeleteSession,
|
||||||
useAdminUpdateUser,
|
useAdminUpdateUser,
|
||||||
} from "medusa-react"
|
} from "medusa-react"
|
||||||
|
|
||||||
const Profile = () => {
|
const Profile = () => {
|
||||||
const updateUser = useAdminUpdateUser(userId)
|
const updateUser = useAdminUpdateUser(userId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -298,16 +298,16 @@ const Profile = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Profile
|
export default Profile
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/users/${userId}`, {
|
fetch(`<BACKEND_URL>/admin/users/${userId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -316,26 +316,26 @@ fetch(`<BACKEND_URL>/admin/users/${userId}`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
first_name: "Marcellus",
|
first_name: "Marcellus",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ user }) => {
|
.then(({ user }) => {
|
||||||
console.log(user.id)
|
console.log(user.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/users/<USER_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/users/<USER_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"first_name": "Marcellus"
|
"first_name": "Marcellus"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the ID of the user as a path parameter.
|
This API Route requires the ID of the user as a path parameter.
|
||||||
@@ -363,24 +363,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.users.sendResetPasswordToken({
|
medusa.admin.users.sendResetPasswordToken({
|
||||||
email: "user@example.com",
|
email: "user@example.com",
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// successful
|
// successful
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminSendResetPasswordToken } from "medusa-react"
|
import { useAdminSendResetPasswordToken } from "medusa-react"
|
||||||
|
|
||||||
const Login = () => {
|
const Login = () => {
|
||||||
const requestPasswordReset = useAdminSendResetPasswordToken()
|
const requestPasswordReset = useAdminSendResetPasswordToken()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -391,16 +391,16 @@ const Login = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Login
|
export default Login
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/users/password-token`, {
|
fetch(`<BACKEND_URL>/admin/users/password-token`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -409,25 +409,25 @@ fetch(`<BACKEND_URL>/admin/users/password-token`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
email: "user@example.com",
|
email: "user@example.com",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// successful
|
// successful
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/users/password-token' \
|
curl -L -X POST '<BACKEND_URL>/admin/users/password-token' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"email": "user@example.com"
|
"email": "user@example.com"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the `email` parameter in the request body, which is the email of the user requesting to reset their password.
|
This API Route requires the `email` parameter in the request body, which is the email of the user requesting to reset their password.
|
||||||
@@ -441,25 +441,25 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.users.resetPassword({
|
medusa.admin.users.resetPassword({
|
||||||
token: "supersecrettoken",
|
token: "supersecrettoken",
|
||||||
password: "supersecret",
|
password: "supersecret",
|
||||||
})
|
})
|
||||||
.then(({ user }) => {
|
.then(({ user }) => {
|
||||||
console.log(user.id)
|
console.log(user.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminResetPassword } from "medusa-react"
|
import { useAdminResetPassword } from "medusa-react"
|
||||||
|
|
||||||
const ResetPassword = () => {
|
const ResetPassword = () => {
|
||||||
const resetPassword = useAdminResetPassword()
|
const resetPassword = useAdminResetPassword()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -471,16 +471,16 @@ const ResetPassword = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ResetPassword
|
export default ResetPassword
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/users/reset-password`, {
|
fetch(`<BACKEND_URL>/admin/users/reset-password`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -490,26 +490,26 @@ fetch(`<BACKEND_URL>/admin/users/reset-password`, {
|
|||||||
token: "supersecrettoken",
|
token: "supersecrettoken",
|
||||||
password: "supersecret",
|
password: "supersecret",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ user }) => {
|
.then(({ user }) => {
|
||||||
console.log(user.id)
|
console.log(user.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/users/reset-password' \
|
curl -L -X POST '<BACKEND_URL>/admin/users/reset-password' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"token": "supersecrettoken",
|
"token": "supersecrettoken",
|
||||||
"password": "supersecret"
|
"password": "supersecret"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the following request body parameters:
|
This API Route requires the following request body parameters:
|
||||||
|
|||||||
@@ -56,22 +56,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.users.list()
|
medusa.admin.users.list()
|
||||||
.then(({ users }) => {
|
.then(({ users }) => {
|
||||||
console.log(users.length)
|
console.log(users.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUsers } from "medusa-react"
|
import { useAdminUsers } from "medusa-react"
|
||||||
|
|
||||||
const Users = () => {
|
const Users = () => {
|
||||||
const { users, isLoading } = useAdminUsers()
|
const { users, isLoading } = useAdminUsers()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -87,33 +87,33 @@ const Users = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Users
|
export default Users
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/users`, {
|
fetch(`<BACKEND_URL>/admin/users`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ users }) => {
|
.then(({ users }) => {
|
||||||
console.log(users.length)
|
console.log(users.length)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X GET '<BACKEND_URL>/admin/users' \
|
curl -L -X GET '<BACKEND_URL>/admin/users' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route doesn't require any parameters.
|
This API Route doesn't require any parameters.
|
||||||
@@ -127,25 +127,25 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.users.create({
|
medusa.admin.users.create({
|
||||||
email: "user@example.com",
|
email: "user@example.com",
|
||||||
password: "supersecret",
|
password: "supersecret",
|
||||||
})
|
})
|
||||||
.then(({ user }) => {
|
.then(({ user }) => {
|
||||||
console.log(user.id)
|
console.log(user.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminCreateUser } from "medusa-react"
|
import { useAdminCreateUser } from "medusa-react"
|
||||||
|
|
||||||
const CreateUser = () => {
|
const CreateUser = () => {
|
||||||
const createUser = useAdminCreateUser()
|
const createUser = useAdminCreateUser()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -157,16 +157,16 @@ const CreateUser = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateUser
|
export default CreateUser
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/users`, {
|
fetch(`<BACKEND_URL>/admin/users`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -176,27 +176,27 @@ fetch(`<BACKEND_URL>/admin/users`, {
|
|||||||
email: "user@example.com",
|
email: "user@example.com",
|
||||||
password: "supersecret",
|
password: "supersecret",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ user }) => {
|
.then(({ user }) => {
|
||||||
console.log(user.id)
|
console.log(user.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/users' \
|
curl -L -X POST '<BACKEND_URL>/admin/users' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"email": "user@example.com",
|
"email": "user@example.com",
|
||||||
"password": "supersecret"
|
"password": "supersecret"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the following request body parameters:
|
This API Route requires the following request body parameters:
|
||||||
@@ -215,24 +215,24 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.users.update(userId, {
|
medusa.admin.users.update(userId, {
|
||||||
first_name: "Marcellus",
|
first_name: "Marcellus",
|
||||||
})
|
})
|
||||||
.then(({ user }) => {
|
.then(({ user }) => {
|
||||||
console.log(user.id)
|
console.log(user.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminUpdateUser } from "medusa-react"
|
import { useAdminUpdateUser } from "medusa-react"
|
||||||
|
|
||||||
const UpdateUser = () => {
|
const UpdateUser = () => {
|
||||||
const updateUser = useAdminUpdateUser(userId)
|
const updateUser = useAdminUpdateUser(userId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -243,16 +243,16 @@ const UpdateUser = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UpdateUser
|
export default UpdateUser
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/users/${userId}`, {
|
fetch(`<BACKEND_URL>/admin/users/${userId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -261,26 +261,26 @@ fetch(`<BACKEND_URL>/admin/users/${userId}`, {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
first_name: "Marcellus",
|
first_name: "Marcellus",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ user }) => {
|
.then(({ user }) => {
|
||||||
console.log(user.id)
|
console.log(user.id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST '<BACKEND_URL>/admin/users/<USER_ID>' \
|
curl -L -X POST '<BACKEND_URL>/admin/users/<USER_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"first_name": "Marcellus"
|
"first_name": "Marcellus"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the ID of the user as a path parameter.
|
This API Route requires the ID of the user as a path parameter.
|
||||||
@@ -296,22 +296,22 @@ 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):
|
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}>
|
<Tabs groupId="request-type" isCodeTabs={true}>
|
||||||
<TabItem value="client" label="Medusa JS Client" default>
|
<TabItem value="client" label="Medusa JS Client" default>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
medusa.admin.users.delete(userId)
|
medusa.admin.users.delete(userId)
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="medusa-react" label="Medusa React">
|
<TabItem value="medusa-react" label="Medusa React">
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useAdminDeleteUser } from "medusa-react"
|
import { useAdminDeleteUser } from "medusa-react"
|
||||||
|
|
||||||
const DeleteUser = () => {
|
const DeleteUser = () => {
|
||||||
const deleteUser = useAdminDeleteUser(userId)
|
const deleteUser = useAdminDeleteUser(userId)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -320,34 +320,34 @@ const DeleteUser = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DeleteUser
|
export default DeleteUser
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="fetch" label="Fetch API">
|
<TabItem value="fetch" label="Fetch API">
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
fetch(`<BACKEND_URL>/admin/users/${userId}`, {
|
fetch(`<BACKEND_URL>/admin/users/${userId}`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(({ id, object, deleted }) => {
|
.then(({ id, object, deleted }) => {
|
||||||
console.log(id)
|
console.log(id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="curl" label="cURL">
|
<TabItem value="curl" label="cURL">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L -X DELETE '<BACKEND_URL>/admin/users/<USER_ID>' \
|
curl -L -X DELETE '<BACKEND_URL>/admin/users/<USER_ID>' \
|
||||||
-H 'Authorization: Bearer <API_TOKEN>'
|
-H 'Authorization: Bearer <API_TOKEN>'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
This API Route requires the user ID as a path parameter.
|
This API Route requires the user ID as a path parameter.
|
||||||
|
|||||||
@@ -47,19 +47,17 @@ So, the first step would be to create the `Role` and `Permission` entities to re
|
|||||||
},
|
},
|
||||||
]} />
|
]} />
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>
|
<Summary>Example Implementation</Summary>
|
||||||
Example Implementation
|
|
||||||
</summary>
|
|
||||||
|
|
||||||
This is an example implementation of how you can create the Role and Permission entities, and extend the `User` and `Store` entities.
|
This is an example implementation of how you can create the Role and Permission entities, and extend the `User` and `Store` entities.
|
||||||
|
|
||||||
Creating an entity requires creating an entity class, a repository, and a migration. You can learn more [here](../../../development/entities/create.mdx). You’ll be creating the migration at the end of this example section.
|
Creating an entity requires creating an entity class, a repository, and a migration. You can learn more [here](../../../development/entities/create.mdx). You’ll be creating the migration at the end of this example section.
|
||||||
|
|
||||||
Create the file `src/models/role.ts` with the following content:
|
Create the file `src/models/role.ts` with the following content:
|
||||||
|
|
||||||
```ts title=src/models/role.ts
|
```ts title=src/models/role.ts
|
||||||
import {
|
import {
|
||||||
BeforeInsert,
|
BeforeInsert,
|
||||||
Column,
|
Column,
|
||||||
Entity,
|
Entity,
|
||||||
@@ -69,15 +67,15 @@ import {
|
|||||||
ManyToMany,
|
ManyToMany,
|
||||||
ManyToOne,
|
ManyToOne,
|
||||||
OneToMany,
|
OneToMany,
|
||||||
} from "typeorm"
|
} from "typeorm"
|
||||||
import { BaseEntity } from "@medusajs/medusa"
|
import { BaseEntity } from "@medusajs/medusa"
|
||||||
import { generateEntityId } from "@medusajs/medusa/dist/utils"
|
import { generateEntityId } from "@medusajs/medusa/dist/utils"
|
||||||
import { Permission } from "./permission"
|
import { Permission } from "./permission"
|
||||||
import { User } from "./user"
|
import { User } from "./user"
|
||||||
import { Store } from "./store"
|
import { Store } from "./store"
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Role extends BaseEntity {
|
export class Role extends BaseEntity {
|
||||||
@Column({ type: "varchar" })
|
@Column({ type: "varchar" })
|
||||||
name: string
|
name: string
|
||||||
|
|
||||||
@@ -112,56 +110,56 @@ export class Role extends BaseEntity {
|
|||||||
private beforeInsert(): void {
|
private beforeInsert(): void {
|
||||||
this.id = generateEntityId(this.id, "role")
|
this.id = generateEntityId(this.id, "role")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
This creates the `Role` entity. You’ll see errors in your editors, which you’ll resolve by following along the example.
|
This creates the `Role` entity. You’ll see errors in your editors, which you’ll resolve by following along the example.
|
||||||
|
|
||||||
The `Role` entity has the following attributes:
|
The `Role` entity has the following attributes:
|
||||||
|
|
||||||
- `id`: the ID of the role, which is available implicitly by extending `BaseEntity`
|
- `id`: the ID of the role, which is available implicitly by extending `BaseEntity`
|
||||||
- `name`: the name of the role
|
- `name`: the name of the role
|
||||||
- `store_id`: the ID of the store this role belongs to. This is only useful if you’re implementing RBAC in a marketplace. Otherwise, you may omit this relation.
|
- `store_id`: the ID of the store this role belongs to. This is only useful if you’re implementing RBAC in a marketplace. Otherwise, you may omit this relation.
|
||||||
|
|
||||||
It also has the following relations:
|
It also has the following relations:
|
||||||
|
|
||||||
- `permissions`: an array of permissions included in this role.
|
- `permissions`: an array of permissions included in this role.
|
||||||
- `store`: the Store this role belongs to.
|
- `store`: the Store this role belongs to.
|
||||||
- `users`: the users associated with this role.
|
- `users`: the users associated with this role.
|
||||||
|
|
||||||
Then, create the file `src/repositories/role.ts` with the following content:
|
Then, create the file `src/repositories/role.ts` with the following content:
|
||||||
|
|
||||||
```ts title=src/repositories/role.ts
|
```ts title=src/repositories/role.ts
|
||||||
import { Role } from "../models/role"
|
import { Role } from "../models/role"
|
||||||
import {
|
import {
|
||||||
dataSource,
|
dataSource,
|
||||||
} from "@medusajs/medusa/dist/loaders/database"
|
} from "@medusajs/medusa/dist/loaders/database"
|
||||||
|
|
||||||
export const RoleRepository = dataSource
|
export const RoleRepository = dataSource
|
||||||
.getRepository(Role)
|
.getRepository(Role)
|
||||||
|
|
||||||
export default RoleRepository
|
export default RoleRepository
|
||||||
```
|
```
|
||||||
|
|
||||||
Next, create the file `src/models/permission.ts` with the following content:
|
Next, create the file `src/models/permission.ts` with the following content:
|
||||||
|
|
||||||
```ts title=src/models/permission.ts
|
```ts title=src/models/permission.ts
|
||||||
import {
|
import {
|
||||||
BeforeInsert,
|
BeforeInsert,
|
||||||
Column,
|
Column,
|
||||||
Entity,
|
Entity,
|
||||||
JoinTable,
|
JoinTable,
|
||||||
ManyToMany,
|
ManyToMany,
|
||||||
} from "typeorm"
|
} from "typeorm"
|
||||||
import { BaseEntity } from "@medusajs/medusa"
|
import { BaseEntity } from "@medusajs/medusa"
|
||||||
import {
|
import {
|
||||||
DbAwareColumn,
|
DbAwareColumn,
|
||||||
generateEntityId,
|
generateEntityId,
|
||||||
} from "@medusajs/medusa/dist/utils"
|
} from "@medusajs/medusa/dist/utils"
|
||||||
import { Role } from "./role"
|
import { Role } from "./role"
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Permission extends BaseEntity {
|
export class Permission extends BaseEntity {
|
||||||
@Column({ type: "varchar" })
|
@Column({ type: "varchar" })
|
||||||
name: string
|
name: string
|
||||||
|
|
||||||
@@ -173,49 +171,49 @@ export class Permission extends BaseEntity {
|
|||||||
private beforeInsert(): void {
|
private beforeInsert(): void {
|
||||||
this.id = generateEntityId(this.id, "perm")
|
this.id = generateEntityId(this.id, "perm")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
This creates a `Permission` entity that has the following attributes:
|
This creates a `Permission` entity that has the following attributes:
|
||||||
|
|
||||||
- `id`: the ID of the permission, which is implicitly available through extending `BaseEntity`.
|
- `id`: the ID of the permission, which is implicitly available through extending `BaseEntity`.
|
||||||
- `name`: the name of the permission.
|
- `name`: the name of the permission.
|
||||||
- `metadata`: an object that will include the permissions. The object keys will be an admin path in the backend, and the value will be a boolean indicating whether the user has access to that path or not.
|
- `metadata`: an object that will include the permissions. The object keys will be an admin path in the backend, and the value will be a boolean indicating whether the user has access to that path or not.
|
||||||
|
|
||||||
Then, create the file `src/repositories/permission.ts` with the following content:
|
Then, create the file `src/repositories/permission.ts` with the following content:
|
||||||
|
|
||||||
```ts title=src/repositories/permission.ts
|
```ts title=src/repositories/permission.ts
|
||||||
import { Permission } from "../models/permission"
|
import { Permission } from "../models/permission"
|
||||||
import {
|
import {
|
||||||
dataSource,
|
dataSource,
|
||||||
} from "@medusajs/medusa/dist/loaders/database"
|
} from "@medusajs/medusa/dist/loaders/database"
|
||||||
|
|
||||||
export const PermissionRepository = dataSource
|
export const PermissionRepository = dataSource
|
||||||
.getRepository(Permission)
|
.getRepository(Permission)
|
||||||
|
|
||||||
export default PermissionRepository
|
export default PermissionRepository
|
||||||
```
|
```
|
||||||
|
|
||||||
Next, you’ll extend the `User` and `Store` entities. As mentioned earlier, extending the `Store` entity and adding the relation is only useful if you’re implementing RBAC in a marketplace or similar use cases. So, if this doesn’t apply to you, you may skip it.
|
Next, you’ll extend the `User` and `Store` entities. As mentioned earlier, extending the `Store` entity and adding the relation is only useful if you’re implementing RBAC in a marketplace or similar use cases. So, if this doesn’t apply to you, you may skip it.
|
||||||
|
|
||||||
Create the file `src/models/user.ts` with the following content:
|
Create the file `src/models/user.ts` with the following content:
|
||||||
|
|
||||||
```ts title=src/models/user.ts
|
```ts title=src/models/user.ts
|
||||||
import {
|
import {
|
||||||
Column,
|
Column,
|
||||||
Entity,
|
Entity,
|
||||||
Index,
|
Index,
|
||||||
JoinColumn,
|
JoinColumn,
|
||||||
ManyToOne,
|
ManyToOne,
|
||||||
} from "typeorm"
|
} from "typeorm"
|
||||||
import {
|
import {
|
||||||
// alias the core entity to not cause a naming conflict
|
// alias the core entity to not cause a naming conflict
|
||||||
User as MedusaUser,
|
User as MedusaUser,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
import { Role } from "./role"
|
import { Role } from "./role"
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class User extends MedusaUser {
|
export class User extends MedusaUser {
|
||||||
@Index()
|
@Index()
|
||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
role_id: string | null
|
role_id: string | null
|
||||||
@@ -223,37 +221,37 @@ export class User extends MedusaUser {
|
|||||||
@ManyToOne(() => Role, (role) => role.users)
|
@ManyToOne(() => Role, (role) => role.users)
|
||||||
@JoinColumn({ name: "role_id" })
|
@JoinColumn({ name: "role_id" })
|
||||||
teamRole: Role | null
|
teamRole: Role | null
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
This adds a new attribute `role_id` to the core `User` entity and a `teamRole` relation that optionally associates the user with a role.
|
This adds a new attribute `role_id` to the core `User` entity and a `teamRole` relation that optionally associates the user with a role.
|
||||||
|
|
||||||
Next, create the file `src/models/store.ts` with the following content:
|
Next, create the file `src/models/store.ts` with the following content:
|
||||||
|
|
||||||
```ts title=src/models/store.ts
|
```ts title=src/models/store.ts
|
||||||
import { Entity, JoinColumn, OneToMany } from "typeorm"
|
import { Entity, JoinColumn, OneToMany } from "typeorm"
|
||||||
import {
|
import {
|
||||||
// alias the core entity to not cause a naming conflict
|
// alias the core entity to not cause a naming conflict
|
||||||
Store as MedusaStore,
|
Store as MedusaStore,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
import { Role } from "./role"
|
import { Role } from "./role"
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Store extends MedusaStore {
|
export class Store extends MedusaStore {
|
||||||
@OneToMany(() => Role, (role) => role.store)
|
@OneToMany(() => Role, (role) => role.store)
|
||||||
@JoinColumn({ name: "id", referencedColumnName: "store_id" })
|
@JoinColumn({ name: "id", referencedColumnName: "store_id" })
|
||||||
roles: Role[]
|
roles: Role[]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
This adds a `roles` relation to the core `Store` entity.
|
This adds a `roles` relation to the core `Store` entity.
|
||||||
|
|
||||||
Optionally, if you’re using TypeScript, create the file `src/index.d.ts` with the following content:
|
Optionally, if you’re using TypeScript, create the file `src/index.d.ts` with the following content:
|
||||||
|
|
||||||
```ts title=src/index.d.ts
|
```ts title=src/index.d.ts
|
||||||
import { Role } from "./models/role"
|
import { Role } from "./models/role"
|
||||||
|
|
||||||
export declare module "@medusajs/medusa/dist/models/user" {
|
export declare module "@medusajs/medusa/dist/models/user" {
|
||||||
|
|
||||||
declare interface User {
|
declare interface User {
|
||||||
role_id: string | null;
|
role_id: string | null;
|
||||||
@@ -263,21 +261,21 @@ export declare module "@medusajs/medusa/dist/models/user" {
|
|||||||
declare interface Store {
|
declare interface Store {
|
||||||
roles: Role[]
|
roles: Role[]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
This ensures that your TypeScript validation and editor autocomplete recognize the new attributes and relations you added on the core entities.
|
This ensures that your TypeScript validation and editor autocomplete recognize the new attributes and relations you added on the core entities.
|
||||||
|
|
||||||
Finally, you need to create a migration to reflect these changes in the database.
|
Finally, you need to create a migration to reflect these changes in the database.
|
||||||
|
|
||||||
You can learn about creating migrations [here](../../../development/entities/migrations/create.md). An example of a migration file based on the entities created above:
|
You can learn about creating migrations [here](../../../development/entities/migrations/create.md). An example of a migration file based on the entities created above:
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts title=src/migrations/1693225851284-AddRolesAndPermissions.ts
|
```ts title=src/migrations/1693225851284-AddRolesAndPermissions.ts
|
||||||
import { MigrationInterface, QueryRunner, Table, TableIndex } from "typeorm"
|
import { MigrationInterface, QueryRunner, Table, TableIndex } from "typeorm"
|
||||||
|
|
||||||
export class AddRolesAndPermissions1693225851284 implements MigrationInterface {
|
export class AddRolesAndPermissions1693225851284 implements MigrationInterface {
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
await queryRunner.query(`ALTER TABLE "user" ADD "role_id" character varying`)
|
await queryRunner.query(`ALTER TABLE "user" ADD "role_id" character varying`)
|
||||||
@@ -310,24 +308,24 @@ export class AddRolesAndPermissions1693225851284 implements MigrationInterface {
|
|||||||
await queryRunner.query(`DROP TABLE "permission"`)
|
await queryRunner.query(`DROP TABLE "permission"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Finally, to reflect these changes, run the `build` command in the root directory of your medusa backend:
|
Finally, to reflect these changes, run the `build` command in the root directory of your medusa backend:
|
||||||
|
|
||||||
```bash npm2yarn
|
```bash npm2yarn
|
||||||
npm run build
|
npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, run the migrations:
|
Then, run the migrations:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx medusa migrations run
|
npx medusa migrations run
|
||||||
```
|
```
|
||||||
|
|
||||||
This will reflect the entity changes in your database.
|
This will reflect the entity changes in your database.
|
||||||
|
|
||||||
</details>
|
</Details>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -347,30 +345,30 @@ Since the Medusa backend uses Express, you can create a middleware and attach it
|
|||||||
}
|
}
|
||||||
}} />
|
}} />
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>Example Implementation</summary>
|
<Summary>Example Implementation</Summary>
|
||||||
|
|
||||||
In this example, you’ll create a middleware that runs on all admin-authenticated routes and checks the logged-in user’s permissions before giving them access to an API Route.
|
In this example, you’ll create a middleware that runs on all admin-authenticated routes and checks the logged-in user’s permissions before giving them access to an API Route.
|
||||||
|
|
||||||
Create the file `src/api/middlewares.ts` with the following content:
|
Create the file `src/api/middlewares.ts` with the following content:
|
||||||
|
|
||||||
```ts title=src/api/middlewares.ts
|
```ts title=src/api/middlewares.ts
|
||||||
import type {
|
import type {
|
||||||
MiddlewaresConfig,
|
MiddlewaresConfig,
|
||||||
UserService,
|
UserService,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
import express from "express"
|
import express from "express"
|
||||||
import type {
|
import type {
|
||||||
MedusaRequest,
|
MedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
MedusaNextFunction,
|
MedusaNextFunction,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
|
|
||||||
export const permissions = async (
|
export const permissions = async (
|
||||||
req: MedusaRequest,
|
req: MedusaRequest,
|
||||||
res: MedusaResponse,
|
res: MedusaResponse,
|
||||||
next: MedusaNextFunction
|
next: MedusaNextFunction
|
||||||
) => {
|
) => {
|
||||||
if (!req.user || !req.user.userId) {
|
if (!req.user || !req.user.userId) {
|
||||||
next()
|
next()
|
||||||
return
|
return
|
||||||
@@ -413,33 +411,33 @@ export const permissions = async (
|
|||||||
|
|
||||||
// deny access
|
// deny access
|
||||||
res.sendStatus(401)
|
res.sendStatus(401)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const config: MiddlewaresConfig = {
|
export const config: MiddlewaresConfig = {
|
||||||
routes: [
|
routes: [
|
||||||
{
|
{
|
||||||
matcher: "/admin/*",
|
matcher: "/admin/*",
|
||||||
middlewares: [permissions],
|
middlewares: [permissions],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
In this middleware, you ensure that there is a logged-in user and the logged-in user has a role. If not, the user is admitted to access the API Route. Here, you presume that logged-in users who don’t have a role are “super-admin” users who can access all API Routes. You may choose to implement this differently.
|
In this middleware, you ensure that there is a logged-in user and the logged-in user has a role. If not, the user is admitted to access the API Route. Here, you presume that logged-in users who don’t have a role are “super-admin” users who can access all API Routes. You may choose to implement this differently.
|
||||||
|
|
||||||
If there’s a logged-in user that has a role, you check that the role’s permissions give them access to the current API Route. You do that by checking if a permission’s metadata has a key with the same request’s path. It may be better here to check for matching using regular expressions, for example, to check routes with path parameters.
|
If there’s a logged-in user that has a role, you check that the role’s permissions give them access to the current API Route. You do that by checking if a permission’s metadata has a key with the same request’s path. It may be better here to check for matching using regular expressions, for example, to check routes with path parameters.
|
||||||
|
|
||||||
Otherwise, if the user’s role doesn’t provide them with enough permissions, you return a `401` response code.
|
Otherwise, if the user’s role doesn’t provide them with enough permissions, you return a `401` response code.
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
|
|
||||||
Notice that you use `req.path` here to get the current API Route path. However, in middlewares, this doesn’t include the mount point which is `/admin`. So, for example, if the API Route path is `/admin/products`, `req.path` will be `/products`. You can alternatively use `req.originalUrl`. Learn more in [Express’s documentation](https://expressjs.com/en/api.html#req.originalUrl).
|
Notice that you use `req.path` here to get the current API Route path. However, in middlewares, this doesn’t include the mount point which is `/admin`. So, for example, if the API Route path is `/admin/products`, `req.path` will be `/products`. You can alternatively use `req.originalUrl`. Learn more in [Express’s documentation](https://expressjs.com/en/api.html#req.originalUrl).
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
After defining the middleware, you apply it on all API Routes starting with `/admin/`.
|
After defining the middleware, you apply it on all API Routes starting with `/admin/`.
|
||||||
|
|
||||||
</details>
|
</Details>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -481,32 +479,30 @@ Furthermore, you may need to extend core services if you need to perform actions
|
|||||||
},
|
},
|
||||||
]} />
|
]} />
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>
|
<Summary>Example Implementation</Summary>
|
||||||
Example Implementation
|
|
||||||
</summary>
|
|
||||||
|
|
||||||
In this example, you’ll only implement two API Routes for simplicity: create role API Route that create a new role with permissions, and associate user API Route that associates a user with a role.
|
In this example, you’ll only implement two API Routes for simplicity: create role API Route that create a new role with permissions, and associate user API Route that associates a user with a role.
|
||||||
|
|
||||||
You’ll also create basic services for `Role` and `Permission` to perform the functionalities of each of these API Routes and extend the core `UserService` to allow associating roles with users.
|
You’ll also create basic services for `Role` and `Permission` to perform the functionalities of each of these API Routes and extend the core `UserService` to allow associating roles with users.
|
||||||
|
|
||||||
Start by creating the file `src/services/permission.ts` with the following content:
|
Start by creating the file `src/services/permission.ts` with the following content:
|
||||||
|
|
||||||
```ts title=src/services/permission.ts
|
```ts title=src/services/permission.ts
|
||||||
import { TransactionBaseService } from "@medusajs/medusa"
|
import { TransactionBaseService } from "@medusajs/medusa"
|
||||||
import { Permission } from "../models/permission"
|
import { Permission } from "../models/permission"
|
||||||
import PermissionRepository from "../repositories/permission"
|
import PermissionRepository from "../repositories/permission"
|
||||||
|
|
||||||
export type CreatePayload = Pick<
|
export type CreatePayload = Pick<
|
||||||
Permission,
|
Permission,
|
||||||
"name" | "metadata"
|
"name" | "metadata"
|
||||||
>
|
>
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
permissionRepository: typeof PermissionRepository
|
permissionRepository: typeof PermissionRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
class PermissionService extends TransactionBaseService {
|
class PermissionService extends TransactionBaseService {
|
||||||
protected readonly permissionRepository_:
|
protected readonly permissionRepository_:
|
||||||
typeof PermissionRepository
|
typeof PermissionRepository
|
||||||
|
|
||||||
@@ -528,58 +524,58 @@ class PermissionService extends TransactionBaseService {
|
|||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PermissionService
|
export default PermissionService
|
||||||
```
|
```
|
||||||
|
|
||||||
This creates the `PermissionService` with only a `create` method that can be used to create a permission.
|
This creates the `PermissionService` with only a `create` method that can be used to create a permission.
|
||||||
|
|
||||||
Next, create the file `src/services/user.ts` with the following content:
|
Next, create the file `src/services/user.ts` with the following content:
|
||||||
|
|
||||||
```ts title=src/services/user.ts
|
```ts title=src/services/user.ts
|
||||||
import {
|
import {
|
||||||
UserService as MedusaUserService, User,
|
UserService as MedusaUserService, User,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
import {
|
import {
|
||||||
UpdateUserInput,
|
UpdateUserInput,
|
||||||
} from "@medusajs/medusa/dist/types/user"
|
} from "@medusajs/medusa/dist/types/user"
|
||||||
|
|
||||||
class UserService extends MedusaUserService {
|
class UserService extends MedusaUserService {
|
||||||
async update(userId: string, update: UpdateUserInput & {
|
async update(userId: string, update: UpdateUserInput & {
|
||||||
role_id?: string
|
role_id?: string
|
||||||
}): Promise<User> {
|
}): Promise<User> {
|
||||||
return super.update(userId, update)
|
return super.update(userId, update)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UserService
|
export default UserService
|
||||||
```
|
```
|
||||||
|
|
||||||
This extends the core `UserService` to allow updating a user’s role. You may also want to extend the `create` method to allow specifying the role on creation.
|
This extends the core `UserService` to allow updating a user’s role. You may also want to extend the `create` method to allow specifying the role on creation.
|
||||||
|
|
||||||
Then, create the file `src/services/role.ts` with the following content:
|
Then, create the file `src/services/role.ts` with the following content:
|
||||||
|
|
||||||
```ts title=src/services/role.ts
|
```ts title=src/services/role.ts
|
||||||
import { TransactionBaseService } from "@medusajs/medusa"
|
import { TransactionBaseService } from "@medusajs/medusa"
|
||||||
import { Role } from "../models/role"
|
import { Role } from "../models/role"
|
||||||
import RoleRepository from "../repositories/role"
|
import RoleRepository from "../repositories/role"
|
||||||
import PermissionService, {
|
import PermissionService, {
|
||||||
CreatePayload as PermissionCreatePayload,
|
CreatePayload as PermissionCreatePayload,
|
||||||
} from "./permission"
|
} from "./permission"
|
||||||
import UserService from "./user"
|
import UserService from "./user"
|
||||||
|
|
||||||
type CreatePayload = Pick<Role, "name" | "store_id"> & {
|
type CreatePayload = Pick<Role, "name" | "store_id"> & {
|
||||||
permissions?: PermissionCreatePayload[]
|
permissions?: PermissionCreatePayload[]
|
||||||
}
|
}
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
roleRepository: typeof RoleRepository
|
roleRepository: typeof RoleRepository
|
||||||
permissionService: PermissionService
|
permissionService: PermissionService
|
||||||
userService: UserService
|
userService: UserService
|
||||||
}
|
}
|
||||||
|
|
||||||
class RoleService extends TransactionBaseService {
|
class RoleService extends TransactionBaseService {
|
||||||
protected readonly roleRpository_: typeof RoleRepository
|
protected readonly roleRpository_: typeof RoleRepository
|
||||||
protected readonly permissionService_: PermissionService
|
protected readonly permissionService_: PermissionService
|
||||||
protected readonly userService_: UserService
|
protected readonly userService_: UserService
|
||||||
@@ -650,32 +646,32 @@ class RoleService extends TransactionBaseService {
|
|||||||
return await this.retrieve(role_id)
|
return await this.retrieve(role_id)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default RoleService
|
export default RoleService
|
||||||
```
|
```
|
||||||
|
|
||||||
This creates the `RoleService` with three methods:
|
This creates the `RoleService` with three methods:
|
||||||
|
|
||||||
- `retrieve`: Retrieves a role with its relations.
|
- `retrieve`: Retrieves a role with its relations.
|
||||||
- `create`: Creates a new role and, if provided, its permissions as well.
|
- `create`: Creates a new role and, if provided, its permissions as well.
|
||||||
- `associateUser`: associates a user with a role.
|
- `associateUser`: associates a user with a role.
|
||||||
|
|
||||||
Now, you can create the API Routes.
|
Now, you can create the API Routes.
|
||||||
|
|
||||||
Start by creating the file `src/api/admin/roles/route.ts` with the following content:
|
Start by creating the file `src/api/admin/roles/route.ts` with the following content:
|
||||||
|
|
||||||
```ts title=src/api/admin/roles/route.ts
|
```ts title=src/api/admin/roles/route.ts
|
||||||
import type {
|
import type {
|
||||||
MedusaRequest,
|
MedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
import RoleService from "../../../../services/role"
|
import RoleService from "../../../../services/role"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: MedusaRequest,
|
req: MedusaRequest,
|
||||||
res: MedusaResponse
|
res: MedusaResponse
|
||||||
) => {
|
) => {
|
||||||
// omitting validation for simplicity
|
// omitting validation for simplicity
|
||||||
const {
|
const {
|
||||||
name,
|
name,
|
||||||
@@ -694,24 +690,24 @@ export const POST = async (
|
|||||||
})
|
})
|
||||||
|
|
||||||
res.json(role)
|
res.json(role)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
This creates the Create Role API Route at `/admin/roles` that uses the `RoleService` to create a new role. Notice that validation of received body parameters is omitted for simplicity.
|
This creates the Create Role API Route at `/admin/roles` that uses the `RoleService` to create a new role. Notice that validation of received body parameters is omitted for simplicity.
|
||||||
|
|
||||||
Next, create the file `src/api/routes/admin/roles/[id]/user/[user_id]/route.ts` with the following content:
|
Next, create the file `src/api/routes/admin/roles/[id]/user/[user_id]/route.ts` with the following content:
|
||||||
|
|
||||||
```ts title=src/api/routes/admin/roles/[id]/user/[user_id]/route.ts
|
```ts title=src/api/routes/admin/roles/[id]/user/[user_id]/route.ts
|
||||||
import type {
|
import type {
|
||||||
MedusaRequest,
|
MedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
import RoleService from "../../../../services/role"
|
import RoleService from "../../../../services/role"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: MedusaRequest,
|
req: MedusaRequest,
|
||||||
res: MedusaResponse
|
res: MedusaResponse
|
||||||
) => {
|
) => {
|
||||||
// omitting validation for simplicity purposes
|
// omitting validation for simplicity purposes
|
||||||
const {
|
const {
|
||||||
id,
|
id,
|
||||||
@@ -724,27 +720,27 @@ export const POST = async (
|
|||||||
const role = await roleService.associateUser(id, user_id)
|
const role = await roleService.associateUser(id, user_id)
|
||||||
|
|
||||||
res.json(role)
|
res.json(role)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
This creates the Associate User API Route at `/admin/roles/[id]/user/[user_id]` that uses the `RoleService` to associate a role with a user.
|
This creates the Associate User API Route at `/admin/roles/[id]/user/[user_id]` that uses the `RoleService` to associate a role with a user.
|
||||||
|
|
||||||
To test the API Routes out, run the `build` command in the root directory of your Medusa backend project:
|
To test the API Routes out, run the `build` command in the root directory of your Medusa backend project:
|
||||||
|
|
||||||
```bash npm2yarn
|
```bash npm2yarn
|
||||||
npm run build
|
npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, start the backend with the following command:
|
Then, start the backend with the following command:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx medusa develop
|
npx medusa develop
|
||||||
```
|
```
|
||||||
|
|
||||||
Try first to log in using the [Admin User Login API Route](https://docs.medusajs.com/api/admin#auth_postauth) with an existing admin user. Then, send a `POST` request to the `localhost:9000/admin/roles` API Route with the following request body parameters:
|
Try first to log in using the [Admin User Login API Route](https://docs.medusajs.com/api/admin#auth_postauth) with an existing admin user. Then, send a `POST` request to the `localhost:9000/admin/roles` API Route with the following request body parameters:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"store_id": "store_01H8XPDY8WA1Z650MZSEY4Y0V0",
|
"store_id": "store_01H8XPDY8WA1Z650MZSEY4Y0V0",
|
||||||
"name": "Product Manager",
|
"name": "Product Manager",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
@@ -755,18 +751,18 @@ Try first to log in using the [Admin User Login API Route](https://docs.medusajs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Make sure to replace the `store_id`'s value with your store’s ID. You can retrieve the store’s ID using the [Get Store Details API Route](https://docs.medusajs.com/api/admin#store_getstore).
|
Make sure to replace the `store_id`'s value with your store’s ID. You can retrieve the store’s ID using the [Get Store Details API Route](https://docs.medusajs.com/api/admin#store_getstore).
|
||||||
|
|
||||||
This will create a new role with a permission that allows users of this role to access the `/admin/products` API Route. As mentioned before, because of the middleware’s implementation, you must specify the path without the `/admin` prefix. If you chose to implement this differently, such as with regular expressions, then change the permission’s metadata accordingly.
|
This will create a new role with a permission that allows users of this role to access the `/admin/products` API Route. As mentioned before, because of the middleware’s implementation, you must specify the path without the `/admin` prefix. If you chose to implement this differently, such as with regular expressions, then change the permission’s metadata accordingly.
|
||||||
|
|
||||||
Next, create a new user using the [Create User API Route](https://docs.medusajs.com/api/admin#users_postusers). Then, send a `POST` request to `localhost:9000/admin/roles/<role_id>/user/<user_id>`, where `<role_id>` is the ID of the role you created, and `<user_id>` is the ID of the user you created. This will associate the user with the role you created.
|
Next, create a new user using the [Create User API Route](https://docs.medusajs.com/api/admin#users_postusers). Then, send a `POST` request to `localhost:9000/admin/roles/<role_id>/user/<user_id>`, where `<role_id>` is the ID of the role you created, and `<user_id>` is the ID of the user you created. This will associate the user with the role you created.
|
||||||
|
|
||||||
Finally, login with the user you created, then try to access any API Route other than `/admin/products`. You’ll receive a `401` unauthorized response. Then, try to access the [List Products API Route](https://docs.medusajs.com/api/admin#products_getproducts), and the user should be able to access it as expected.
|
Finally, login with the user you created, then try to access any API Route other than `/admin/products`. You’ll receive a `401` unauthorized response. Then, try to access the [List Products API Route](https://docs.medusajs.com/api/admin#products_getproducts), and the user should be able to access it as expected.
|
||||||
|
|
||||||
</details>
|
</Details>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
+96
-114
@@ -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.
|
The rest of this section includes the field names you can customize using this option for each content model type.
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>
|
<Summary>product</Summary>
|
||||||
product
|
|
||||||
</summary>
|
|
||||||
|
|
||||||
- `title`
|
- `title`
|
||||||
- `subtitle`
|
- `subtitle`
|
||||||
- `description`
|
- `description`
|
||||||
- `variants`
|
- `variants`
|
||||||
- `options`
|
- `options`
|
||||||
- `medusaId`
|
- `medusaId`
|
||||||
- `type`
|
- `type`
|
||||||
- `collection`
|
- `collection`
|
||||||
- `tags`
|
- `tags`
|
||||||
- `handle`
|
- `handle`
|
||||||
|
|
||||||
</details>
|
</Details>
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>
|
<Summary>variant</Summary>
|
||||||
variant
|
|
||||||
</summary>
|
|
||||||
|
|
||||||
- `title`
|
- `title`
|
||||||
- `sku`
|
- `sku`
|
||||||
- `prices`
|
- `prices`
|
||||||
- `options`
|
- `options`
|
||||||
- `medusaId`
|
- `medusaId`
|
||||||
|
|
||||||
</details>
|
</Details>
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>
|
<Summary>region</Summary>
|
||||||
region
|
|
||||||
</summary>
|
|
||||||
|
|
||||||
- `name`
|
- `name`
|
||||||
- `countries`
|
- `countries`
|
||||||
- `paymentProviders`
|
- `paymentProviders`
|
||||||
- `fulfillmentProviders`
|
- `fulfillmentProviders`
|
||||||
- `medusaId`
|
- `medusaId`
|
||||||
|
|
||||||
</details>
|
</Details>
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>
|
<Summary>collection</Summary>
|
||||||
collection
|
|
||||||
</summary>
|
|
||||||
|
|
||||||
- `title`
|
- `title`
|
||||||
- `medusaId`
|
- `medusaId`
|
||||||
|
|
||||||
</details>
|
</Details>
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>
|
<Summary>type</Summary>
|
||||||
type
|
|
||||||
</summary>
|
|
||||||
|
|
||||||
- `name`
|
- `name`
|
||||||
- `medusaId`
|
- `medusaId`
|
||||||
|
|
||||||
</details>
|
</Details>
|
||||||
|
|
||||||
### Migrate Content Models
|
### Migrate Content Models
|
||||||
|
|
||||||
@@ -173,22 +163,20 @@ Before creating the migration scripts, run the following command in the root of
|
|||||||
npm install --save-dev contentful-migration
|
npm install --save-dev contentful-migration
|
||||||
```
|
```
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>
|
<Summary>product Content Model</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
|
```ts title=src/loaders/contentful-migrations/product.ts
|
||||||
import Migration, {
|
import Migration, {
|
||||||
MigrationContext,
|
MigrationContext,
|
||||||
} from "contentful-migration"
|
} from "contentful-migration"
|
||||||
|
|
||||||
export function productMigration(
|
export function productMigration(
|
||||||
migration: Migration,
|
migration: Migration,
|
||||||
context?: MigrationContext
|
context?: MigrationContext
|
||||||
) {
|
) {
|
||||||
const product = migration
|
const product = migration
|
||||||
.createContentType("product")
|
.createContentType("product")
|
||||||
.name("Product")
|
.name("Product")
|
||||||
@@ -249,27 +237,25 @@ export function productMigration(
|
|||||||
.createField("medusaId")
|
.createField("medusaId")
|
||||||
.name("Medusa ID")
|
.name("Medusa ID")
|
||||||
.type("Symbol")
|
.type("Symbol")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</Details>
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>
|
<Summary>productVariant Content Model</Summary>
|
||||||
productVariant Content Model
|
|
||||||
</summary>
|
|
||||||
|
|
||||||
Create the file `src/loaders/contentful-migrations/product-variant.ts` with the following content:
|
Create the file `src/loaders/contentful-migrations/product-variant.ts` with the following content:
|
||||||
|
|
||||||
```ts title=src/loaders/contentful-migrations/product-variant.ts
|
```ts title=src/loaders/contentful-migrations/product-variant.ts
|
||||||
import Migration, {
|
import Migration, {
|
||||||
MigrationContext,
|
MigrationContext,
|
||||||
} from "contentful-migration"
|
} from "contentful-migration"
|
||||||
|
|
||||||
export function productVariantMigration(
|
export function productVariantMigration(
|
||||||
migration: Migration,
|
migration: Migration,
|
||||||
context?: MigrationContext
|
context?: MigrationContext
|
||||||
) {
|
) {
|
||||||
const productVariant = migration
|
const productVariant = migration
|
||||||
.createContentType("productVariant")
|
.createContentType("productVariant")
|
||||||
.name("Product Variant")
|
.name("Product Variant")
|
||||||
@@ -296,27 +282,25 @@ export function productVariantMigration(
|
|||||||
.createField("medusaId")
|
.createField("medusaId")
|
||||||
.name("Medusa ID")
|
.name("Medusa ID")
|
||||||
.type("Symbol")
|
.type("Symbol")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</Details>
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>
|
<Summary>collection Content Model</Summary>
|
||||||
collection Content Model
|
|
||||||
</summary>
|
|
||||||
|
|
||||||
Create the file `src/loaders/contentful-migrations/product-collection.ts` with the following content:
|
Create the file `src/loaders/contentful-migrations/product-collection.ts` with the following content:
|
||||||
|
|
||||||
```ts title=src/loaders/contentful-migrations/product-collection.ts
|
```ts title=src/loaders/contentful-migrations/product-collection.ts
|
||||||
import Migration, {
|
import Migration, {
|
||||||
MigrationContext,
|
MigrationContext,
|
||||||
} from "contentful-migration"
|
} from "contentful-migration"
|
||||||
|
|
||||||
export function productCollectionMigration(
|
export function productCollectionMigration(
|
||||||
migration: Migration,
|
migration: Migration,
|
||||||
context?: MigrationContext
|
context?: MigrationContext
|
||||||
) {
|
) {
|
||||||
const collection = migration
|
const collection = migration
|
||||||
.createContentType("collection")
|
.createContentType("collection")
|
||||||
.name("Product Collection")
|
.name("Product Collection")
|
||||||
@@ -331,26 +315,25 @@ export function productCollectionMigration(
|
|||||||
.createField("medusaId")
|
.createField("medusaId")
|
||||||
.name("Medusa ID")
|
.name("Medusa ID")
|
||||||
.type("Symbol")
|
.type("Symbol")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
|
||||||
<details>
|
</Details>
|
||||||
<summary>
|
|
||||||
productType Content Model
|
|
||||||
</summary>
|
|
||||||
|
|
||||||
Create the file `src/loaders/contentful-migrations/product-type.ts` with the following content:
|
<Details>
|
||||||
|
<Summary>productType Content Model</Summary>
|
||||||
|
|
||||||
```ts title=src/loaders/contentful-migrations/product-type.ts
|
Create the file `src/loaders/contentful-migrations/product-type.ts` with the following content:
|
||||||
import Migration, {
|
|
||||||
|
```ts title=src/loaders/contentful-migrations/product-type.ts
|
||||||
|
import Migration, {
|
||||||
MigrationContext,
|
MigrationContext,
|
||||||
} from "contentful-migration"
|
} from "contentful-migration"
|
||||||
|
|
||||||
export function productTypeMigration(
|
export function productTypeMigration(
|
||||||
migration: Migration,
|
migration: Migration,
|
||||||
context?: MigrationContext
|
context?: MigrationContext
|
||||||
) {
|
) {
|
||||||
const collection = migration
|
const collection = migration
|
||||||
.createContentType("productType")
|
.createContentType("productType")
|
||||||
.name("Product Type")
|
.name("Product Type")
|
||||||
@@ -365,26 +348,25 @@ export function productTypeMigration(
|
|||||||
.createField("medusaId")
|
.createField("medusaId")
|
||||||
.name("Medusa ID")
|
.name("Medusa ID")
|
||||||
.type("Symbol")
|
.type("Symbol")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
|
||||||
<details>
|
</Details>
|
||||||
<summary>
|
|
||||||
region Content Model
|
|
||||||
</summary>
|
|
||||||
|
|
||||||
Create the file `src/loaders/contentful-migrations/region.ts` with the following content:
|
<Details>
|
||||||
|
<Summary>region Content Model</Summary>
|
||||||
|
|
||||||
```ts title=src/loaders/contentful-migrations/region.ts
|
Create the file `src/loaders/contentful-migrations/region.ts` with the following content:
|
||||||
import Migration, {
|
|
||||||
|
```ts title=src/loaders/contentful-migrations/region.ts
|
||||||
|
import Migration, {
|
||||||
MigrationContext,
|
MigrationContext,
|
||||||
} from "contentful-migration"
|
} from "contentful-migration"
|
||||||
|
|
||||||
export function regionMigration(
|
export function regionMigration(
|
||||||
migration: Migration,
|
migration: Migration,
|
||||||
context?: MigrationContext
|
context?: MigrationContext
|
||||||
) {
|
) {
|
||||||
const region = migration
|
const region = migration
|
||||||
.createContentType("region")
|
.createContentType("region")
|
||||||
.name("Region")
|
.name("Region")
|
||||||
@@ -415,10 +397,10 @@ export function regionMigration(
|
|||||||
.createField("medusaId")
|
.createField("medusaId")
|
||||||
.name("Medusa ID")
|
.name("Medusa ID")
|
||||||
.type("Symbol")
|
.type("Symbol")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</Details>
|
||||||
|
|
||||||
Finally, create a [loader](../../development/loaders/overview.mdx) at `src/loaders/index.ts` with the following content:
|
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
|
## 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
|
:::note
|
||||||
|
|
||||||
@@ -85,8 +85,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 place a new order.
|
**Description:** Template to be sent to the customer when they place a new order.
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>Example Data</summary>
|
<Summary>Example Data</Summary>
|
||||||
|
|
||||||
```json noReport
|
```json noReport
|
||||||
{
|
{
|
||||||
@@ -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>,
|
"updated_at": Any<Date>,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
</Details>
|
||||||
|
|
||||||
### Order Canceled
|
### 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.
|
**Description:** Template to be sent to a customer when their order is canceled.
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>Example Data</summary>
|
<Summary>Example Data</Summary>
|
||||||
|
|
||||||
```json noReport
|
```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>,
|
"updated_at": Any<Date>,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
</Details>
|
||||||
|
|
||||||
### Order Shipment Created
|
### 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.
|
**Description:** Template to be sent to the customer when a shipment of their order has been created.
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>Example Data</summary>
|
<Summary>Example Data</Summary>
|
||||||
|
|
||||||
```json noReport
|
```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": "",
|
"tracking_number": "",
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
</Details>
|
||||||
|
|
||||||
### Order Return Requested
|
### 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.
|
**Description:** Template to be sent to the customer when a return request is made for an order.
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>Example Data</summary>
|
<Summary>Example Data</Summary>
|
||||||
|
|
||||||
```json noReport
|
```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",
|
"subtotal": "12.00 USD",
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
</Details>
|
||||||
|
|
||||||
### Order Items Returned
|
### 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.
|
**Description:** Template to be sent to the customer when an order’s items have been returned.
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>Example Data</summary>
|
<Summary>Example Data</Summary>
|
||||||
|
|
||||||
```json noReport
|
```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",
|
"subtotal": "12.00 USD",
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
</Details>
|
||||||
|
|
||||||
### Claim Shipment Created
|
### 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.
|
**Description:** Template to be sent to the customer when a Claim shipment has been created.
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>Example Data</summary>
|
<Summary>Example Data</Summary>
|
||||||
|
|
||||||
```json noReport
|
```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": "",
|
"tracking_number": "",
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
</Details>
|
||||||
|
|
||||||
### Swap Created
|
### 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.
|
**Description:** Template to be sent to the customer when a swap for an order has been created.
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>Example Data</summary>
|
<Summary>Example Data</Summary>
|
||||||
|
|
||||||
```json noReport
|
```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"
|
"additional_total": "11.25 USD"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
</Details>
|
||||||
|
|
||||||
### Swap Shipment Created
|
### 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.
|
**Description:** Template to be sent to the customer when a shipment of a swap of an order has been created.
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>Example Data</summary>
|
<Summary>Example Data</Summary>
|
||||||
|
|
||||||
```json noReport
|
```json noReport
|
||||||
Object {
|
Object {
|
||||||
@@ -3087,7 +3094,8 @@ You don’t have to create a template for every type in the reference. You can s
|
|||||||
"tracking_number": "",
|
"tracking_number": "",
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
</Details>
|
||||||
|
|
||||||
### Swap Received
|
### 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.
|
**Description:** Template to be sent to the customer when a swap of an order has been received.
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>Example Data</summary>
|
<Summary>Example Data</Summary>
|
||||||
|
|
||||||
```json noReport
|
```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"
|
"additional_total": "11.25 USD"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
</Details>
|
||||||
|
|
||||||
### Gift Card Created
|
### 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.
|
**Description:** Template to be to the customer sent when a gift card in their order has been created.
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>Example Data</summary>
|
<Summary>Example Data</Summary>
|
||||||
|
|
||||||
```json noReport
|
```json noReport
|
||||||
Object {
|
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
|
"display_value": 4
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
</Details>
|
||||||
|
|
||||||
### Customer Password Reset
|
### 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.
|
**Description:** Template to be sent to the customer when they request a password reset.
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>Example Data</summary>
|
<Summary>Example Data</Summary>
|
||||||
|
|
||||||
```json noReport
|
```json noReport
|
||||||
Object {
|
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>,
|
"token": Any<String>,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
</Details>
|
||||||
|
|
||||||
### User Password Reset
|
### 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.
|
**Description:** Template to be sent to the admin user when they request a password reset.
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>Example Data</summary>
|
<Summary>Example Data</Summary>
|
||||||
|
|
||||||
```json noReport
|
```json noReport
|
||||||
Object {
|
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>,
|
"token": Any<String>,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
</Details>
|
||||||
|
|
||||||
### Restock Notification
|
### 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.
|
**Description:** Template to be sent to admin users when a product has hit the restock quantity threshold.
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>Example Data</summary>
|
<Summary>Example Data</Summary>
|
||||||
|
|
||||||
```json noReport
|
```json noReport
|
||||||
Object {
|
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,7 +4017,6 @@ export const POST = async (
|
|||||||
to: "customer@mail.com",
|
to: "customer@mail.com",
|
||||||
dynamic_template_data: { dynamic: "data" },
|
dynamic_template_data: { dynamic: "data" },
|
||||||
}
|
}
|
||||||
|
|
||||||
sendgridService.sendEmail(sendOptions)
|
sendgridService.sendEmail(sendOptions)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -266,24 +266,22 @@ Medusa allows you to create custom API Routes exposed as REST APIs.
|
|||||||
}
|
}
|
||||||
}} />
|
}} />
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>
|
<Summary>Example Implementation</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
|
```ts title=src/api/store/customers/is-b2b/route.ts
|
||||||
import type {
|
import type {
|
||||||
CustomerService,
|
CustomerService,
|
||||||
MedusaRequest,
|
MedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: MedusaRequest,
|
req: MedusaRequest,
|
||||||
res: MedusaResponse
|
res: MedusaResponse
|
||||||
) => {
|
) => {
|
||||||
const customerService: CustomerService = req.scope.resolve(
|
const customerService: CustomerService = req.scope.resolve(
|
||||||
"customerService"
|
"customerService"
|
||||||
)
|
)
|
||||||
@@ -300,28 +298,28 @@ export const GET = async (
|
|||||||
return res.json({
|
return res.json({
|
||||||
is_b2b,
|
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
|
```ts title=src/api/middlewares.ts
|
||||||
import {
|
import {
|
||||||
requireCustomerAuthentication,
|
requireCustomerAuthentication,
|
||||||
type MiddlewaresConfig,
|
type MiddlewaresConfig,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
|
|
||||||
export const config: MiddlewaresConfig = {
|
export const config: MiddlewaresConfig = {
|
||||||
routes: [
|
routes: [
|
||||||
{
|
{
|
||||||
matcher: "/store/customers/is-b2b",
|
matcher: "/store/customers/is-b2b",
|
||||||
middlewares: [requireCustomerAuthentication()],
|
middlewares: [requireCustomerAuthentication()],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</Details>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -100,28 +100,26 @@ Medusa also provides official notification plugins that integrate with third-par
|
|||||||
},
|
},
|
||||||
]} />
|
]} />
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>
|
<Summary>Example: Sending an email for new notes</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:
|
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:
|
||||||
|
|
||||||
```ts title=src/subscribers/new-note.ts
|
```ts title=src/subscribers/new-note.ts
|
||||||
import {
|
import {
|
||||||
EventBusService,
|
EventBusService,
|
||||||
NoteService,
|
NoteService,
|
||||||
OrderService,
|
OrderService,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
eventBusService: EventBusService
|
eventBusService: EventBusService
|
||||||
sendgridService: any
|
sendgridService: any
|
||||||
noteService: NoteService
|
noteService: NoteService
|
||||||
orderService: OrderService
|
orderService: OrderService
|
||||||
}
|
}
|
||||||
|
|
||||||
class NewNoteSubscriber {
|
class NewNoteSubscriber {
|
||||||
protected sendGridService_: any
|
protected sendGridService_: any
|
||||||
protected noteService_: NoteService
|
protected noteService_: NoteService
|
||||||
protected orderService_: OrderService
|
protected orderService_: OrderService
|
||||||
@@ -173,12 +171,12 @@ class NewNoteSubscriber {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default NewNoteSubscriber
|
export default NewNoteSubscriber
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</Details>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -198,28 +196,26 @@ You can implement automatic synchronization in Medusa using scheduled jobs. A sc
|
|||||||
}
|
}
|
||||||
}} />
|
}} />
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>
|
<Summary>Example: Synchronizing products with a third-party service</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
|
```ts title=src/loaders/sync-products.ts
|
||||||
import {
|
import {
|
||||||
Logger,
|
Logger,
|
||||||
ProductService,
|
ProductService,
|
||||||
StoreService,
|
StoreService,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
import {
|
import {
|
||||||
ProductSelector,
|
ProductSelector,
|
||||||
} from "@medusajs/medusa/dist/types/product"
|
} from "@medusajs/medusa/dist/types/product"
|
||||||
import { AwilixContainer } from "awilix"
|
import { AwilixContainer } from "awilix"
|
||||||
|
|
||||||
export default async (
|
export default async (
|
||||||
container: AwilixContainer,
|
container: AwilixContainer,
|
||||||
config: Record<string, unknown>
|
config: Record<string, unknown>
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
const logger = container.resolve<Logger>("logger")
|
const logger = container.resolve<Logger>("logger")
|
||||||
logger.info("Synchronizing products...")
|
logger.info("Synchronizing products...")
|
||||||
const productService = container.resolve<ProductService>(
|
const productService = container.resolve<ProductService>(
|
||||||
@@ -258,15 +254,15 @@ export default async (
|
|||||||
})
|
})
|
||||||
|
|
||||||
logger.info("Finish synchronizing products")
|
logger.info("Finish synchronizing products")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Notice that here it’s assumed that:
|
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.
|
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.
|
2. The connection to the third-party service is assumed to be available and handled within the `client` variable.
|
||||||
|
|
||||||
</details>
|
</Details>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -419,29 +415,27 @@ For example, if you're grouping customers with over twenty orders, you can use a
|
|||||||
},
|
},
|
||||||
]} />
|
]} />
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>
|
<Summary>Example: Add customer to VIP group</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
|
```ts title=src/subscribers/add-custom-to-vip.ts
|
||||||
import {
|
import {
|
||||||
CustomerGroupService,
|
CustomerGroupService,
|
||||||
CustomerService,
|
CustomerService,
|
||||||
EventBusService,
|
EventBusService,
|
||||||
OrderService,
|
OrderService,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
orderService: OrderService
|
orderService: OrderService
|
||||||
customerService: CustomerService
|
customerService: CustomerService
|
||||||
customerGroupService: CustomerGroupService
|
customerGroupService: CustomerGroupService
|
||||||
eventBusService: EventBusService
|
eventBusService: EventBusService
|
||||||
}
|
}
|
||||||
|
|
||||||
class AddCustomerToVipSubscriber {
|
class AddCustomerToVipSubscriber {
|
||||||
protected orderService_: OrderService
|
protected orderService_: OrderService
|
||||||
protected customerService_: CustomerService
|
protected customerService_: CustomerService
|
||||||
protected customerGroupService_: CustomerGroupService
|
protected customerGroupService_: CustomerGroupService
|
||||||
@@ -495,12 +489,12 @@ class AddCustomerToVipSubscriber {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AddCustomerToVipSubscriber
|
export default AddCustomerToVipSubscriber
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</Details>
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -543,35 +537,33 @@ You can alternatively have a Scheduled Job that checks if the number of new prod
|
|||||||
},
|
},
|
||||||
]} />
|
]} />
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>
|
<Summary>Example: Sending a newsletter email after adding ten products</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
|
```ts title=src/subscribers/send-products-newsletter.ts
|
||||||
import {
|
import {
|
||||||
CustomerService,
|
CustomerService,
|
||||||
EventBusService,
|
EventBusService,
|
||||||
NoteService,
|
NoteService,
|
||||||
OrderService,
|
OrderService,
|
||||||
ProductService,
|
ProductService,
|
||||||
StoreService,
|
StoreService,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
import {
|
import {
|
||||||
ProductSelector,
|
ProductSelector,
|
||||||
} from "@medusajs/medusa/dist/types/product"
|
} from "@medusajs/medusa/dist/types/product"
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
eventBusService: EventBusService
|
eventBusService: EventBusService
|
||||||
sendgridService: any
|
sendgridService: any
|
||||||
productService: ProductService
|
productService: ProductService
|
||||||
storeService: StoreService
|
storeService: StoreService
|
||||||
customerService: CustomerService
|
customerService: CustomerService
|
||||||
}
|
}
|
||||||
|
|
||||||
class SendProductsNewsletterSubscriber {
|
class SendProductsNewsletterSubscriber {
|
||||||
protected sendGridService_: any
|
protected sendGridService_: any
|
||||||
protected productService_: ProductService
|
protected productService_: ProductService
|
||||||
protected storeService_: StoreService
|
protected storeService_: StoreService
|
||||||
@@ -636,12 +628,12 @@ class SendProductsNewsletterSubscriber {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SendProductsNewsletterSubscriber
|
export default SendProductsNewsletterSubscriber
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</Details>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -41,26 +41,26 @@ To associate these entities with the `Store` entity, you need to extend and cust
|
|||||||
}
|
}
|
||||||
}} />
|
}} />
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>Example: Associate User with Store</summary>
|
<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
|
```ts title=src/models/user.ts
|
||||||
import {
|
import {
|
||||||
Column,
|
Column,
|
||||||
Entity,
|
Entity,
|
||||||
Index,
|
Index,
|
||||||
JoinColumn,
|
JoinColumn,
|
||||||
ManyToOne,
|
ManyToOne,
|
||||||
} from "typeorm"
|
} from "typeorm"
|
||||||
import {
|
import {
|
||||||
User as MedusaUser,
|
User as MedusaUser,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
import { Store } from "./store"
|
import { Store } from "./store"
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class User extends MedusaUser {
|
export class User extends MedusaUser {
|
||||||
@Index("UserStoreId")
|
@Index("UserStoreId")
|
||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
store_id?: string
|
store_id?: string
|
||||||
@@ -68,21 +68,21 @@ export class User extends MedusaUser {
|
|||||||
@ManyToOne(() => Store, (store) => store.members)
|
@ManyToOne(() => Store, (store) => store.members)
|
||||||
@JoinColumn({ name: "store_id", referencedColumnName: "id" })
|
@JoinColumn({ name: "store_id", referencedColumnName: "id" })
|
||||||
store?: Store
|
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
|
```ts title=src/repositories/user.ts
|
||||||
import { User } from "../models/user"
|
import { User } from "../models/user"
|
||||||
import {
|
import {
|
||||||
dataSource,
|
dataSource,
|
||||||
} from "@medusajs/medusa/dist/loaders/database"
|
} from "@medusajs/medusa/dist/loaders/database"
|
||||||
import {
|
import {
|
||||||
UserRepository as MedusaUserRepository,
|
UserRepository as MedusaUserRepository,
|
||||||
} from "@medusajs/medusa/dist/repositories/user"
|
} from "@medusajs/medusa/dist/repositories/user"
|
||||||
|
|
||||||
export const UserRepository = dataSource
|
export const UserRepository = dataSource
|
||||||
.getRepository(User)
|
.getRepository(User)
|
||||||
.extend({
|
.extend({
|
||||||
...Object.assign(
|
...Object.assign(
|
||||||
@@ -91,21 +91,21 @@ export const UserRepository = dataSource
|
|||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
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
|
```bash
|
||||||
npx typeorm migration:create src/migrations/add-user-store-id
|
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
|
export class AddUserStoreId1681287255173
|
||||||
implements MigrationInterface {
|
implements MigrationInterface {
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -127,19 +127,19 @@ export class AddUserStoreId1681287255173
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
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
|
```bash npm2yarn
|
||||||
npm run build
|
npm run build
|
||||||
npx medusa migrations run
|
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,31 +179,31 @@ You can also extend services if you need to customize a functionality implemente
|
|||||||
}
|
}
|
||||||
}} />
|
}} />
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>Example: Extend User Service</summary>
|
<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 -->
|
<!-- eslint-disable prefer-rest-params -->
|
||||||
|
|
||||||
```ts title=src/services/user.ts
|
```ts title=src/services/user.ts
|
||||||
import { Lifetime } from "awilix"
|
import { Lifetime } from "awilix"
|
||||||
import {
|
import {
|
||||||
UserService as MedusaUserService,
|
UserService as MedusaUserService,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
import { User } from "../models/user"
|
import { User } from "../models/user"
|
||||||
import {
|
import {
|
||||||
CreateUserInput as MedusaCreateUserInput,
|
CreateUserInput as MedusaCreateUserInput,
|
||||||
} from "@medusajs/medusa/dist/types/user"
|
} from "@medusajs/medusa/dist/types/user"
|
||||||
import StoreRepository from "../repositories/store"
|
import StoreRepository from "../repositories/store"
|
||||||
|
|
||||||
type CreateUserInput = {
|
type CreateUserInput = {
|
||||||
store_id?: string
|
store_id?: string
|
||||||
} & MedusaCreateUserInput
|
} & MedusaCreateUserInput
|
||||||
|
|
||||||
class UserService extends MedusaUserService {
|
class UserService extends MedusaUserService {
|
||||||
static LIFE_TIME = Lifetime.SCOPED
|
static LIFE_TIME = Lifetime.SCOPED
|
||||||
protected readonly loggedInUser_: User | null
|
protected readonly loggedInUser_: User | null
|
||||||
protected readonly storeRepository_: typeof StoreRepository
|
protected readonly storeRepository_: typeof StoreRepository
|
||||||
@@ -234,20 +234,21 @@ class UserService extends MedusaUserService {
|
|||||||
|
|
||||||
return await super.create(user, password)
|
return await super.create(user, password)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UserService
|
export default UserService
|
||||||
```
|
```
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
You can then test out your customization by running the `build` command and starting the backend:
|
You can then test out your customization by running the `build` command and starting the backend:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run build
|
npm run build
|
||||||
npx medusa develop
|
npx medusa develop
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
</Details>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -267,13 +268,13 @@ To listen to events, you need to create Subscribers that subscribe a handler met
|
|||||||
}
|
}
|
||||||
}} />
|
}} />
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>Example: Listen to Order Created Event</summary>
|
<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
|
```ts title=src/subscribers/orderNotifier.ts
|
||||||
class OrderNotifierSubscriber {
|
class OrderNotifierSubscriber {
|
||||||
constructor({ eventBusService }) {
|
constructor({ eventBusService }) {
|
||||||
eventBusService.subscribe("order.placed", this.handleOrder)
|
eventBusService.subscribe("order.placed", this.handleOrder)
|
||||||
}
|
}
|
||||||
@@ -281,20 +282,21 @@ class OrderNotifierSubscriber {
|
|||||||
handleOrder = async (data) => {
|
handleOrder = async (data) => {
|
||||||
// TODO perform functionality
|
// 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
|
```bash
|
||||||
npm run build
|
npm run build
|
||||||
npx medusa develop
|
npx medusa develop
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
</Details>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -94,25 +94,23 @@ To search through product variants by their barcode, you can create a custom API
|
|||||||
},
|
},
|
||||||
]} />
|
]} />
|
||||||
|
|
||||||
<details>
|
<Details>
|
||||||
<summary>
|
<Summary>Example: Search Products By Barcode API Route</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
|
```ts title=src/api/store/pos/search-barcode/route.ts
|
||||||
import type {
|
import type {
|
||||||
MedusaRequest,
|
MedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
ProductVariantService,
|
ProductVariantService,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
import { MedusaError } from "@medusajs/utils"
|
import { MedusaError } from "@medusajs/utils"
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: MedusaRequest,
|
req: MedusaRequest,
|
||||||
res: MedusaResponse
|
res: MedusaResponse
|
||||||
) => {
|
) => {
|
||||||
const barcode = (req.query.barcode as string) || ""
|
const barcode = (req.query.barcode as string) || ""
|
||||||
if (!barcode) {
|
if (!barcode) {
|
||||||
throw new MedusaError(
|
throw new MedusaError(
|
||||||
@@ -134,10 +132,10 @@ export const GET = async (
|
|||||||
res.json({
|
res.json({
|
||||||
product_variants: productVariants,
|
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",
|
"name": "country",
|
||||||
"type": "``null`` \\| [`Country`](Country.mdx)",
|
"type": "``null`` \\| [Country](Country.mdx)",
|
||||||
"description": "A country object.",
|
"description": "A country object.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -76,7 +76,7 @@ An address is used across the Medusa backend within other schemas and object typ
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "customer",
|
"name": "customer",
|
||||||
"type": "``null`` \\| [`Customer`](Customer.mdx)",
|
"type": "``null`` \\| [Customer](Customer.mdx)",
|
||||||
"description": "Available if the relation `customer` is expanded.",
|
"description": "Available if the relation `customer` is expanded.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -130,7 +130,7 @@ An address is used across the Medusa backend within other schemas and object typ
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ A Batch Job indicates an asynchronus task stored in the Medusa backend. Its stat
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "context",
|
"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.",
|
"description": "The context of the batch job, the type of the batch job determines what the context should contain.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -67,7 +67,7 @@ A Batch Job indicates an asynchronus task stored in the Medusa backend. Its stat
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "created_by_user",
|
"name": "created_by_user",
|
||||||
"type": "[`User`](User.mdx)",
|
"type": "[User](User.mdx)",
|
||||||
"description": "The details of the user that created the batch job.",
|
"description": "The details of the user that created the batch job.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -138,7 +138,7 @@ A Batch Job indicates an asynchronus task stored in the Medusa backend. Its stat
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -156,7 +156,7 @@ A Batch Job indicates an asynchronus task stored in the Medusa backend. Its stat
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "role",
|
"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.",
|
"description": "The user's role. These roles don't provide any different privileges.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "member",
|
"defaultValue": "member",
|
||||||
@@ -230,7 +230,7 @@ A Batch Job indicates an asynchronus task stored in the Medusa backend. Its stat
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "result",
|
"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": "`{ 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>`",
|
||||||
"description": "The result of the batch job.",
|
"description": "The result of the batch job.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -256,7 +256,7 @@ A Batch Job indicates an asynchronus task stored in the Medusa backend. Its stat
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "errors",
|
"name": "errors",
|
||||||
"type": "(`string` \\| [`BatchJobResultError`](../types/BatchJobResultError.mdx))[]",
|
"type": "(`string` \\| [BatchJobResultError](../types/BatchJobResultError.mdx))[]",
|
||||||
"description": "",
|
"description": "",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -292,7 +292,7 @@ A Batch Job indicates an asynchronus task stored in the Medusa backend. Its stat
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "stat_descriptors",
|
"name": "stat_descriptors",
|
||||||
"type": "[`BatchJobResultStatDescriptor`](../types/BatchJobResultStatDescriptor.mdx)[]",
|
"type": "[BatchJobResultStatDescriptor](../types/BatchJobResultStatDescriptor.mdx)[]",
|
||||||
"description": "",
|
"description": "",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -303,7 +303,7 @@ A Batch Job indicates an asynchronus task stored in the Medusa backend. Its stat
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "status",
|
"name": "status",
|
||||||
"type": "[`BatchJobStatus`](../enums/BatchJobStatus.mdx)",
|
"type": "[BatchJobStatus](../enums/BatchJobStatus.mdx)",
|
||||||
"description": "The status of the batch job.",
|
"description": "The status of the batch job.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "created",
|
"defaultValue": "created",
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
|
|||||||
<ParameterTypes parameters={[
|
<ParameterTypes parameters={[
|
||||||
{
|
{
|
||||||
"name": "billing_address",
|
"name": "billing_address",
|
||||||
"type": "[`Address`](Address.mdx)",
|
"type": "[Address](Address.mdx)",
|
||||||
"description": "The details of the billing address associated with the cart.",
|
"description": "The details of the billing address associated with the cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -40,7 +40,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "context",
|
"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.",
|
"description": "The context of the cart which can include info like IP or user agent.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -58,7 +58,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "customer",
|
"name": "customer",
|
||||||
"type": "[`Customer`](Customer.mdx)",
|
"type": "[Customer](Customer.mdx)",
|
||||||
"description": "The details of the customer the cart belongs to.",
|
"description": "The details of the customer the cart belongs to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -94,7 +94,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "discounts",
|
"name": "discounts",
|
||||||
"type": "[`Discount`](Discount.mdx)[]",
|
"type": "[Discount](Discount.mdx)[]",
|
||||||
"description": "An array of details of all discounts applied to the cart.",
|
"description": "An array of details of all discounts applied to the cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -130,7 +130,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "gift_cards",
|
"name": "gift_cards",
|
||||||
"type": "[`GiftCard`](GiftCard.mdx)[]",
|
"type": "[GiftCard](GiftCard.mdx)[]",
|
||||||
"description": "An array of details of all gift cards applied to the cart.",
|
"description": "An array of details of all gift cards applied to the cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -166,7 +166,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "items",
|
"name": "items",
|
||||||
"type": "[`LineItem`](LineItem.mdx)[]",
|
"type": "[LineItem](LineItem.mdx)[]",
|
||||||
"description": "The line items added to the cart.",
|
"description": "The line items added to the cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -175,7 +175,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -193,7 +193,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "payment",
|
"name": "payment",
|
||||||
"type": "[`Payment`](Payment.mdx)",
|
"type": "[Payment](Payment.mdx)",
|
||||||
"description": "The details of the payment associated with the cart.",
|
"description": "The details of the payment associated with the cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -220,7 +220,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "payment_session",
|
"name": "payment_session",
|
||||||
"type": "``null`` \\| [`PaymentSession`](PaymentSession.mdx)",
|
"type": "``null`` \\| [PaymentSession](PaymentSession.mdx)",
|
||||||
"description": "The details of the selected payment session in the cart.",
|
"description": "The details of the selected payment session in the cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -229,7 +229,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "payment_sessions",
|
"name": "payment_sessions",
|
||||||
"type": "[`PaymentSession`](PaymentSession.mdx)[]",
|
"type": "[PaymentSession](PaymentSession.mdx)[]",
|
||||||
"description": "The details of all payment sessions created on the cart.",
|
"description": "The details of all payment sessions created on the cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -265,7 +265,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "region",
|
"name": "region",
|
||||||
"type": "[`Region`](Region.mdx)",
|
"type": "[Region](Region.mdx)",
|
||||||
"description": "The details of the region associated with the cart.",
|
"description": "The details of the region associated with the cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -283,7 +283,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sales_channel",
|
"name": "sales_channel",
|
||||||
"type": "[`SalesChannel`](SalesChannel.mdx)",
|
"type": "[SalesChannel](SalesChannel.mdx)",
|
||||||
"description": "The details of the sales channel associated with the cart.",
|
"description": "The details of the sales channel associated with the cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -301,7 +301,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "shipping_address",
|
"name": "shipping_address",
|
||||||
"type": "``null`` \\| [`Address`](Address.mdx)",
|
"type": "``null`` \\| [Address](Address.mdx)",
|
||||||
"description": "The details of the shipping address associated with the cart.",
|
"description": "The details of the shipping address associated with the cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -319,7 +319,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "shipping_methods",
|
"name": "shipping_methods",
|
||||||
"type": "[`ShippingMethod`](ShippingMethod.mdx)[]",
|
"type": "[ShippingMethod](ShippingMethod.mdx)[]",
|
||||||
"description": "The details of the shipping methods added to the cart.",
|
"description": "The details of the shipping methods added to the cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -373,7 +373,7 @@ A cart represents a virtual shopping bag. It can be used to complete an order, a
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "type",
|
"name": "type",
|
||||||
"type": "[`CartType`](../enums/CartType.mdx)",
|
"type": "[CartType](../enums/CartType.mdx)",
|
||||||
"description": "The cart's type.",
|
"description": "The cart's type.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "default",
|
"defaultValue": "default",
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ The details of an image attached to a claim.
|
|||||||
<ParameterTypes parameters={[
|
<ParameterTypes parameters={[
|
||||||
{
|
{
|
||||||
"name": "claim_item",
|
"name": "claim_item",
|
||||||
"type": "[`ClaimItem`](ClaimItem.mdx)",
|
"type": "[ClaimItem](ClaimItem.mdx)",
|
||||||
"description": "The details of the claim item this image is associated with.",
|
"description": "The details of the claim item this image is associated with.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -21,7 +21,7 @@ The details of an image attached to a claim.
|
|||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"name": "claim_order",
|
"name": "claim_order",
|
||||||
"type": "[`ClaimOrder`](ClaimOrder.mdx)",
|
"type": "[ClaimOrder](ClaimOrder.mdx)",
|
||||||
"description": "The details of the claim this item belongs to.",
|
"description": "The details of the claim this item belongs to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -66,7 +66,7 @@ The details of an image attached to a claim.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "images",
|
"name": "images",
|
||||||
"type": "[`ClaimImage`](ClaimImage.mdx)[]",
|
"type": "[ClaimImage](ClaimImage.mdx)[]",
|
||||||
"description": "The claim images that are attached to the claim item.",
|
"description": "The claim images that are attached to the claim item.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -75,7 +75,7 @@ The details of an image attached to a claim.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "item",
|
"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.",
|
"description": "The details of the line item in the original order that this claim item refers to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -93,7 +93,7 @@ The details of an image attached to a claim.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -120,7 +120,7 @@ The details of an image attached to a claim.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "reason",
|
"name": "reason",
|
||||||
"type": "[`ClaimReason`](../enums/ClaimReason.mdx)",
|
"type": "[ClaimReason](../enums/ClaimReason.mdx)",
|
||||||
"description": "The reason for the claim",
|
"description": "The reason for the claim",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -129,7 +129,7 @@ The details of an image attached to a claim.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "tags",
|
"name": "tags",
|
||||||
"type": "[`ClaimTag`](ClaimTag.mdx)[]",
|
"type": "[ClaimTag](ClaimTag.mdx)[]",
|
||||||
"description": "User defined tags for easy filtering and grouping.",
|
"description": "User defined tags for easy filtering and grouping.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -147,7 +147,7 @@ The details of an image attached to a claim.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "variant",
|
"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.",
|
"description": "The details of the product variant to potentially replace the item in the original order.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -203,7 +203,7 @@ The details of an image attached to a claim.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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={[
|
<ParameterTypes parameters={[
|
||||||
{
|
{
|
||||||
"name": "claim_order",
|
"name": "claim_order",
|
||||||
"type": "[`ClaimOrder`](ClaimOrder.mdx)",
|
"type": "[ClaimOrder](ClaimOrder.mdx)",
|
||||||
"description": "The details of the claim this item belongs to.",
|
"description": "The details of the claim this item belongs to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -21,7 +21,7 @@ A claim item is an item created as part of a claim. It references an item in the
|
|||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"name": "additional_items",
|
"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`",
|
"description": "The details of the new items to be shipped when the claim's type is `replace`",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "claim_items",
|
||||||
"type": "[`ClaimItem`](ClaimItem.mdx)[]",
|
"type": "[ClaimItem](ClaimItem.mdx)[]",
|
||||||
"description": "The details of the items that should be replaced or refunded.",
|
"description": "The details of the items that should be replaced or refunded.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "fulfillment_status",
|
||||||
"type": "[`ClaimFulfillmentStatus`](../enums/ClaimFulfillmentStatus.mdx)",
|
"type": "[ClaimFulfillmentStatus](../enums/ClaimFulfillmentStatus.mdx)",
|
||||||
"description": "The claim's fulfillment status",
|
"description": "The claim's fulfillment status",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "not_fulfilled",
|
"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",
|
"name": "fulfillments",
|
||||||
"type": "[`Fulfillment`](Fulfillment.mdx)[]",
|
"type": "[Fulfillment](Fulfillment.mdx)[]",
|
||||||
"description": "The fulfillments of the new items to be shipped",
|
"description": "The fulfillments of the new items to be shipped",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "order",
|
||||||
"type": "[`Order`](Order.mdx)",
|
"type": "[Order](Order.mdx)",
|
||||||
"description": "The details of the order that this claim was created for.",
|
"description": "The details of the order that this claim was created for.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "payment_status",
|
||||||
"type": "[`ClaimPaymentStatus`](../enums/ClaimPaymentStatus.mdx)",
|
"type": "[ClaimPaymentStatus](../enums/ClaimPaymentStatus.mdx)",
|
||||||
"description": "The status of the claim's payment",
|
"description": "The status of the claim's payment",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "na",
|
"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",
|
"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`.",
|
"description": "The details of the return associated with the claim if the claim's type is `replace`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "shipping_address",
|
||||||
"type": "[`Address`](Address.mdx)",
|
"type": "[Address](Address.mdx)",
|
||||||
"description": "The details of the address that new items should be shipped to.",
|
"description": "The details of the address that new items should be shipped to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"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.",
|
"description": "The details of the shipping methods that the claim order will be shipped with.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "type",
|
||||||
"type": "[`ClaimType`](../enums/ClaimType.mdx)",
|
"type": "[ClaimType](../enums/ClaimType.mdx)",
|
||||||
"description": "The claim's type",
|
"description": "The claim's type",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "images",
|
||||||
"type": "[`ClaimImage`](ClaimImage.mdx)[]",
|
"type": "[ClaimImage](ClaimImage.mdx)[]",
|
||||||
"description": "The claim images that are attached to the claim item.",
|
"description": "The claim images that are attached to the claim item.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -256,7 +256,7 @@ A claim item is an item created as part of a claim. It references an item in the
|
|||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"name": "claim_item",
|
"name": "claim_item",
|
||||||
"type": "[`ClaimItem`](ClaimItem.mdx)",
|
"type": "[ClaimItem](ClaimItem.mdx)",
|
||||||
"description": "The details of the claim item this image is associated with.",
|
"description": "The details of the claim item this image is associated with.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"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.",
|
"description": "The details of the line item in the original order that this claim item refers to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -338,7 +338,7 @@ A claim item is an item created as part of a claim. It references an item in the
|
|||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"name": "adjustments",
|
"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.",
|
"description": "The details of the item's adjustments, which are available when a discount is applied on the item.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "cart",
|
||||||
"type": "[`Cart`](Cart.mdx)",
|
"type": "[Cart](Cart.mdx)",
|
||||||
"description": "The details of the cart that the line item may belongs to.",
|
"description": "The details of the cart that the line item may belongs to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "claim_order",
|
||||||
"type": "[`ClaimOrder`](ClaimOrder.mdx)",
|
"type": "[ClaimOrder](ClaimOrder.mdx)",
|
||||||
"description": "The details of the claim that the line item may belong to.",
|
"description": "The details of the claim that the line item may belong to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "includes_tax",
|
||||||
"type": "`boolean`",
|
"type": "`boolean`",
|
||||||
"description": "Indicates if the line item unit_price include tax",
|
"description": "Indicates if the line item unit\\_price include tax",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "false",
|
"defaultValue": "false",
|
||||||
"expandable": 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",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "order",
|
||||||
"type": "[`Order`](Order.mdx)",
|
"type": "[Order](Order.mdx)",
|
||||||
"description": "The details of the order that the line item may belongs to.",
|
"description": "The details of the order that the line item may belongs to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "order_edit",
|
||||||
"type": "``null`` \\| [`OrderEdit`](OrderEdit.mdx)",
|
"type": "``null`` \\| [OrderEdit](OrderEdit.mdx)",
|
||||||
"description": "The details of the order edit.",
|
"description": "The details of the order edit.",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "swap",
|
||||||
"type": "[`Swap`](Swap.mdx)",
|
"type": "[Swap](Swap.mdx)",
|
||||||
"description": "The details of the swap that the line item may belong to.",
|
"description": "The details of the swap that the line item may belong to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "tax_lines",
|
||||||
"type": "[`LineItemTaxLine`](LineItemTaxLine.mdx)[]",
|
"type": "[LineItemTaxLine](LineItemTaxLine.mdx)[]",
|
||||||
"description": "The details of the item's tax lines.",
|
"description": "The details of the item's tax lines.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "variant",
|
||||||
"type": "[`ProductVariant`](ProductVariant.mdx)",
|
"type": "[ProductVariant](ProductVariant.mdx)",
|
||||||
"description": "The details of the product variant that this item was created from.",
|
"description": "The details of the product variant that this item was created from.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "reason",
|
||||||
"type": "[`ClaimReason`](../enums/ClaimReason.mdx)",
|
"type": "[ClaimReason](../enums/ClaimReason.mdx)",
|
||||||
"description": "The reason for the claim",
|
"description": "The reason for the claim",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "tags",
|
||||||
"type": "[`ClaimTag`](ClaimTag.mdx)[]",
|
"type": "[ClaimTag](ClaimTag.mdx)[]",
|
||||||
"description": "User defined tags for easy filtering and grouping.",
|
"description": "User defined tags for easy filtering and grouping.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"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.",
|
"description": "The details of the product variant to potentially replace the item in the original order.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "allow_backorder",
|
||||||
"type": "`boolean`",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "false",
|
"defaultValue": "false",
|
||||||
"expandable": 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",
|
"name": "inventory_items",
|
||||||
"type": "[`ProductVariantInventoryItem`](ProductVariantInventoryItem.mdx)[]",
|
"type": "[ProductVariantInventoryItem](ProductVariantInventoryItem.mdx)[]",
|
||||||
"description": "The details inventory items of the product variant.",
|
"description": "The details inventory items of the product variant.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "metadata",
|
||||||
"type": "``null`` \\| Record<`string`, `unknown`\\>",
|
"type": "``null`` \\| `Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "options",
|
||||||
"type": "[`ProductOptionValue`](ProductOptionValue.mdx)[]",
|
"type": "[ProductOptionValue](ProductOptionValue.mdx)[]",
|
||||||
"description": "The details of the product options that this product variant defines values for.",
|
"description": "The details of the product options that this product variant defines values for.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"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",
|
"name": "product",
|
||||||
"type": "[`Product`](Product.mdx)",
|
"type": "[Product](Product.mdx)",
|
||||||
"description": "The details of the product that the product variant belongs to.",
|
"description": "The details of the product that the product variant belongs to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ A Claim represents a group of faulty or missing items. It consists of claim item
|
|||||||
<ParameterTypes parameters={[
|
<ParameterTypes parameters={[
|
||||||
{
|
{
|
||||||
"name": "additional_items",
|
"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`",
|
"description": "The details of the new items to be shipped when the claim's type is `replace`",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -31,7 +31,7 @@ A Claim represents a group of faulty or missing items. It consists of claim item
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "claim_items",
|
"name": "claim_items",
|
||||||
"type": "[`ClaimItem`](ClaimItem.mdx)[]",
|
"type": "[ClaimItem](ClaimItem.mdx)[]",
|
||||||
"description": "The details of the items that should be replaced or refunded.",
|
"description": "The details of the items that should be replaced or refunded.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -58,7 +58,7 @@ A Claim represents a group of faulty or missing items. It consists of claim item
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "fulfillment_status",
|
"name": "fulfillment_status",
|
||||||
"type": "[`ClaimFulfillmentStatus`](../enums/ClaimFulfillmentStatus.mdx)",
|
"type": "[ClaimFulfillmentStatus](../enums/ClaimFulfillmentStatus.mdx)",
|
||||||
"description": "The claim's fulfillment status",
|
"description": "The claim's fulfillment status",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "not_fulfilled",
|
"defaultValue": "not_fulfilled",
|
||||||
@@ -67,7 +67,7 @@ A Claim represents a group of faulty or missing items. It consists of claim item
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "fulfillments",
|
"name": "fulfillments",
|
||||||
"type": "[`Fulfillment`](Fulfillment.mdx)[]",
|
"type": "[Fulfillment](Fulfillment.mdx)[]",
|
||||||
"description": "The fulfillments of the new items to be shipped",
|
"description": "The fulfillments of the new items to be shipped",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -94,7 +94,7 @@ A Claim represents a group of faulty or missing items. It consists of claim item
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -112,7 +112,7 @@ A Claim represents a group of faulty or missing items. It consists of claim item
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "order",
|
"name": "order",
|
||||||
"type": "[`Order`](Order.mdx)",
|
"type": "[Order](Order.mdx)",
|
||||||
"description": "The details of the order that this claim was created for.",
|
"description": "The details of the order that this claim was created for.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -130,7 +130,7 @@ A Claim represents a group of faulty or missing items. It consists of claim item
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "payment_status",
|
"name": "payment_status",
|
||||||
"type": "[`ClaimPaymentStatus`](../enums/ClaimPaymentStatus.mdx)",
|
"type": "[ClaimPaymentStatus](../enums/ClaimPaymentStatus.mdx)",
|
||||||
"description": "The status of the claim's payment",
|
"description": "The status of the claim's payment",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "na",
|
"defaultValue": "na",
|
||||||
@@ -148,7 +148,7 @@ A Claim represents a group of faulty or missing items. It consists of claim item
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "return_order",
|
"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`.",
|
"description": "The details of the return associated with the claim if the claim's type is `replace`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -157,7 +157,7 @@ A Claim represents a group of faulty or missing items. It consists of claim item
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "shipping_address",
|
"name": "shipping_address",
|
||||||
"type": "[`Address`](Address.mdx)",
|
"type": "[Address](Address.mdx)",
|
||||||
"description": "The details of the address that new items should be shipped to.",
|
"description": "The details of the address that new items should be shipped to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -175,7 +175,7 @@ A Claim represents a group of faulty or missing items. It consists of claim item
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "shipping_methods",
|
"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.",
|
"description": "The details of the shipping methods that the claim order will be shipped with.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -184,7 +184,7 @@ A Claim represents a group of faulty or missing items. It consists of claim item
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "type",
|
"name": "type",
|
||||||
"type": "[`ClaimType`](../enums/ClaimType.mdx)",
|
"type": "[ClaimType](../enums/ClaimType.mdx)",
|
||||||
"description": "The claim's type",
|
"description": "The claim's type",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ Claim Tags are user defined tags that can be assigned to claim items for easy fi
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ Country details
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "region",
|
"name": "region",
|
||||||
"type": "[`Region`](Region.mdx)",
|
"type": "[Region](Region.mdx)",
|
||||||
"description": "The details of the region the country is associated with.",
|
"description": "The details of the region the country is associated with.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -84,7 +84,7 @@ Country details
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "countries",
|
"name": "countries",
|
||||||
"type": "[`Country`](Country.mdx)[]",
|
"type": "[Country](Country.mdx)[]",
|
||||||
"description": "The details of the countries included in this region.",
|
"description": "The details of the countries included in this region.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -102,7 +102,7 @@ Country details
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "currency",
|
"name": "currency",
|
||||||
"type": "[`Currency`](Currency.mdx)",
|
"type": "[Currency](Currency.mdx)",
|
||||||
"description": "The details of the currency used in the region.",
|
"description": "The details of the currency used in the region.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -129,7 +129,7 @@ Country details
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "fulfillment_providers",
|
"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.",
|
"description": "The details of the fulfillment providers that can be used to fulfill items of orders and similar resources in the region.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -166,7 +166,7 @@ Country details
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -184,7 +184,7 @@ Country details
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "payment_providers",
|
"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.",
|
"description": "The details of the payment providers that can be used to process payments in the region.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -202,7 +202,7 @@ Country details
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "tax_provider",
|
"name": "tax_provider",
|
||||||
"type": "[`TaxProvider`](TaxProvider.mdx)",
|
"type": "[TaxProvider](TaxProvider.mdx)",
|
||||||
"description": "The details of the tax provider used in the region.",
|
"description": "The details of the tax provider used in the region.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -229,7 +229,7 @@ Country details
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "tax_rates",
|
"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.",
|
"description": "The details of the tax rates used in the region, aside from the default rate.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
<ParameterTypes parameters={[
|
<ParameterTypes parameters={[
|
||||||
{
|
{
|
||||||
"name": "cart",
|
"name": "cart",
|
||||||
"type": "[`Cart`](Cart.mdx)",
|
"type": "[Cart](Cart.mdx)",
|
||||||
"description": "The details of the cart this shipping option belongs to.",
|
"description": "The details of the cart this shipping option belongs to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -21,7 +21,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"name": "billing_address",
|
"name": "billing_address",
|
||||||
"type": "[`Address`](Address.mdx)",
|
"type": "[Address](Address.mdx)",
|
||||||
"description": "The details of the billing address associated with the cart.",
|
"description": "The details of the billing address associated with the cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -48,7 +48,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "context",
|
"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.",
|
"description": "The context of the cart which can include info like IP or user agent.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -66,7 +66,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "customer",
|
"name": "customer",
|
||||||
"type": "[`Customer`](Customer.mdx)",
|
"type": "[Customer](Customer.mdx)",
|
||||||
"description": "The details of the customer the cart belongs to.",
|
"description": "The details of the customer the cart belongs to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -102,7 +102,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "discounts",
|
"name": "discounts",
|
||||||
"type": "[`Discount`](Discount.mdx)[]",
|
"type": "[Discount](Discount.mdx)[]",
|
||||||
"description": "An array of details of all discounts applied to the cart.",
|
"description": "An array of details of all discounts applied to the cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -138,7 +138,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "gift_cards",
|
"name": "gift_cards",
|
||||||
"type": "[`GiftCard`](GiftCard.mdx)[]",
|
"type": "[GiftCard](GiftCard.mdx)[]",
|
||||||
"description": "An array of details of all gift cards applied to the cart.",
|
"description": "An array of details of all gift cards applied to the cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -174,7 +174,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "items",
|
"name": "items",
|
||||||
"type": "[`LineItem`](LineItem.mdx)[]",
|
"type": "[LineItem](LineItem.mdx)[]",
|
||||||
"description": "The line items added to the cart.",
|
"description": "The line items added to the cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -183,7 +183,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -201,7 +201,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "payment",
|
"name": "payment",
|
||||||
"type": "[`Payment`](Payment.mdx)",
|
"type": "[Payment](Payment.mdx)",
|
||||||
"description": "The details of the payment associated with the cart.",
|
"description": "The details of the payment associated with the cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -228,7 +228,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "payment_session",
|
"name": "payment_session",
|
||||||
"type": "``null`` \\| [`PaymentSession`](PaymentSession.mdx)",
|
"type": "``null`` \\| [PaymentSession](PaymentSession.mdx)",
|
||||||
"description": "The details of the selected payment session in the cart.",
|
"description": "The details of the selected payment session in the cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -237,7 +237,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "payment_sessions",
|
"name": "payment_sessions",
|
||||||
"type": "[`PaymentSession`](PaymentSession.mdx)[]",
|
"type": "[PaymentSession](PaymentSession.mdx)[]",
|
||||||
"description": "The details of all payment sessions created on the cart.",
|
"description": "The details of all payment sessions created on the cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -273,7 +273,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "region",
|
"name": "region",
|
||||||
"type": "[`Region`](Region.mdx)",
|
"type": "[Region](Region.mdx)",
|
||||||
"description": "The details of the region associated with the cart.",
|
"description": "The details of the region associated with the cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -291,7 +291,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sales_channel",
|
"name": "sales_channel",
|
||||||
"type": "[`SalesChannel`](SalesChannel.mdx)",
|
"type": "[SalesChannel](SalesChannel.mdx)",
|
||||||
"description": "The details of the sales channel associated with the cart.",
|
"description": "The details of the sales channel associated with the cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -309,7 +309,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "shipping_address",
|
"name": "shipping_address",
|
||||||
"type": "``null`` \\| [`Address`](Address.mdx)",
|
"type": "``null`` \\| [Address](Address.mdx)",
|
||||||
"description": "The details of the shipping address associated with the cart.",
|
"description": "The details of the shipping address associated with the cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -327,7 +327,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "shipping_methods",
|
"name": "shipping_methods",
|
||||||
"type": "[`ShippingMethod`](ShippingMethod.mdx)[]",
|
"type": "[ShippingMethod](ShippingMethod.mdx)[]",
|
||||||
"description": "The details of the shipping methods added to the cart.",
|
"description": "The details of the shipping methods added to the cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -381,7 +381,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "type",
|
"name": "type",
|
||||||
"type": "[`CartType`](../enums/CartType.mdx)",
|
"type": "[CartType](../enums/CartType.mdx)",
|
||||||
"description": "The cart's type.",
|
"description": "The cart's type.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "default",
|
"defaultValue": "default",
|
||||||
@@ -437,7 +437,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -455,7 +455,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "shipping_option",
|
"name": "shipping_option",
|
||||||
"type": "[`ShippingOption`](ShippingOption.mdx)",
|
"type": "[ShippingOption](ShippingOption.mdx)",
|
||||||
"description": "The details of the overridden shipping options.",
|
"description": "The details of the overridden shipping options.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -473,7 +473,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
{
|
{
|
||||||
"name": "amount",
|
"name": "amount",
|
||||||
"type": "``null`` \\| `number`",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": false,
|
"expandable": false,
|
||||||
@@ -490,7 +490,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "data",
|
"name": "data",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "The data needed for the Fulfillment Provider to identify the Shipping Option.",
|
"description": "The data needed for the Fulfillment Provider to identify the Shipping Option.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -536,7 +536,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -554,8 +554,8 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "price_type",
|
"name": "price_type",
|
||||||
"type": "[`ShippingOptionPriceType`](../enums/ShippingOptionPriceType.mdx)",
|
"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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": false,
|
"expandable": false,
|
||||||
@@ -563,7 +563,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "profile",
|
"name": "profile",
|
||||||
"type": "[`ShippingProfile`](ShippingProfile.mdx)",
|
"type": "[ShippingProfile](ShippingProfile.mdx)",
|
||||||
"description": "The details of the shipping profile that the shipping option belongs to.",
|
"description": "The details of the shipping profile that the shipping option belongs to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -581,7 +581,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "provider",
|
"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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -599,7 +599,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "region",
|
"name": "region",
|
||||||
"type": "[`Region`](Region.mdx)",
|
"type": "[Region](Region.mdx)",
|
||||||
"description": "The details of the region this shipping option can be used in.",
|
"description": "The details of the region this shipping option can be used in.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -617,7 +617,7 @@ Custom Shipping Options are overridden Shipping Options. Admins can attach a Cus
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "requirements",
|
"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.",
|
"description": "The details of the requirements that must be satisfied for the Shipping Option to be available for usage in a Cart.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
<ParameterTypes parameters={[
|
<ParameterTypes parameters={[
|
||||||
{
|
{
|
||||||
"name": "billing_address",
|
"name": "billing_address",
|
||||||
"type": "[`Address`](Address.mdx)",
|
"type": "[Address](Address.mdx)",
|
||||||
"description": "The details of the billing address associated with the customer.",
|
"description": "The details of the billing address associated with the customer.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -57,7 +57,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "country",
|
"name": "country",
|
||||||
"type": "``null`` \\| [`Country`](Country.mdx)",
|
"type": "``null`` \\| [Country](Country.mdx)",
|
||||||
"description": "A country object.",
|
"description": "A country object.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -84,7 +84,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "customer",
|
"name": "customer",
|
||||||
"type": "``null`` \\| [`Customer`](Customer.mdx)",
|
"type": "``null`` \\| [Customer](Customer.mdx)",
|
||||||
"description": "Available if the relation `customer` is expanded.",
|
"description": "Available if the relation `customer` is expanded.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -138,7 +138,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -230,7 +230,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "groups",
|
"name": "groups",
|
||||||
"type": "[`CustomerGroup`](CustomerGroup.mdx)[]",
|
"type": "[CustomerGroup](CustomerGroup.mdx)[]",
|
||||||
"description": "The customer groups the customer belongs to.",
|
"description": "The customer groups the customer belongs to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -247,7 +247,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "customers",
|
"name": "customers",
|
||||||
"type": "[`Customer`](Customer.mdx)[]",
|
"type": "[Customer](Customer.mdx)[]",
|
||||||
"description": "The details of the customers that belong to the customer group.",
|
"description": "The details of the customers that belong to the customer group.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -274,7 +274,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -292,7 +292,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "price_lists",
|
"name": "price_lists",
|
||||||
"type": "[`PriceList`](PriceList.mdx)[]",
|
"type": "[PriceList](PriceList.mdx)[]",
|
||||||
"description": "The price lists that are associated with the customer group.",
|
"description": "The price lists that are associated with the customer group.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -339,7 +339,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -348,7 +348,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "orders",
|
"name": "orders",
|
||||||
"type": "[`Order`](Order.mdx)[]",
|
"type": "[Order](Order.mdx)[]",
|
||||||
"description": "The details of the orders this customer placed.",
|
"description": "The details of the orders this customer placed.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -356,7 +356,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"name": "billing_address",
|
"name": "billing_address",
|
||||||
"type": "[`Address`](Address.mdx)",
|
"type": "[Address](Address.mdx)",
|
||||||
"description": "The details of the billing address associated with the order.",
|
"description": "The details of the billing address associated with the order.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -383,7 +383,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "cart",
|
"name": "cart",
|
||||||
"type": "[`Cart`](Cart.mdx)",
|
"type": "[Cart](Cart.mdx)",
|
||||||
"description": "The details of the cart associated with the order.",
|
"description": "The details of the cart associated with the order.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -401,7 +401,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "claims",
|
"name": "claims",
|
||||||
"type": "[`ClaimOrder`](ClaimOrder.mdx)[]",
|
"type": "[ClaimOrder](ClaimOrder.mdx)[]",
|
||||||
"description": "The details of the claims created for the order.",
|
"description": "The details of the claims created for the order.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -419,7 +419,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "currency",
|
"name": "currency",
|
||||||
"type": "[`Currency`](Currency.mdx)",
|
"type": "[Currency](Currency.mdx)",
|
||||||
"description": "The details of the currency used in the order.",
|
"description": "The details of the currency used in the order.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -437,7 +437,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "customer",
|
"name": "customer",
|
||||||
"type": "[`Customer`](Customer.mdx)",
|
"type": "[Customer](Customer.mdx)",
|
||||||
"description": "The details of the customer associated with the order.",
|
"description": "The details of the customer associated with the order.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -464,7 +464,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "discounts",
|
"name": "discounts",
|
||||||
"type": "[`Discount`](Discount.mdx)[]",
|
"type": "[Discount](Discount.mdx)[]",
|
||||||
"description": "The details of the discounts applied on the order.",
|
"description": "The details of the discounts applied on the order.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -482,7 +482,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "draft_order",
|
"name": "draft_order",
|
||||||
"type": "[`DraftOrder`](DraftOrder.mdx)",
|
"type": "[DraftOrder](DraftOrder.mdx)",
|
||||||
"description": "The details of the draft order this order was created from.",
|
"description": "The details of the draft order this order was created from.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -500,7 +500,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "edits",
|
"name": "edits",
|
||||||
"type": "[`OrderEdit`](OrderEdit.mdx)[]",
|
"type": "[OrderEdit](OrderEdit.mdx)[]",
|
||||||
"description": "The details of the order edits done on the order.",
|
"description": "The details of the order edits done on the order.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -527,7 +527,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "fulfillment_status",
|
"name": "fulfillment_status",
|
||||||
"type": "[`FulfillmentStatus`](../enums/FulfillmentStatus.mdx)",
|
"type": "[FulfillmentStatus](../enums/FulfillmentStatus.mdx)",
|
||||||
"description": "The order's fulfillment status",
|
"description": "The order's fulfillment status",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "not_fulfilled",
|
"defaultValue": "not_fulfilled",
|
||||||
@@ -536,7 +536,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "fulfillments",
|
"name": "fulfillments",
|
||||||
"type": "[`Fulfillment`](Fulfillment.mdx)[]",
|
"type": "[Fulfillment](Fulfillment.mdx)[]",
|
||||||
"description": "The details of the fulfillments created for the order.",
|
"description": "The details of the fulfillments created for the order.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -563,7 +563,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "gift_card_transactions",
|
"name": "gift_card_transactions",
|
||||||
"type": "[`GiftCardTransaction`](GiftCardTransaction.mdx)[]",
|
"type": "[GiftCardTransaction](GiftCardTransaction.mdx)[]",
|
||||||
"description": "The gift card transactions made in the order.",
|
"description": "The gift card transactions made in the order.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -572,7 +572,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "gift_cards",
|
"name": "gift_cards",
|
||||||
"type": "[`GiftCard`](GiftCard.mdx)[]",
|
"type": "[GiftCard](GiftCard.mdx)[]",
|
||||||
"description": "The details of the gift card used in the order.",
|
"description": "The details of the gift card used in the order.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -608,7 +608,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "items",
|
"name": "items",
|
||||||
"type": "[`LineItem`](LineItem.mdx)[]",
|
"type": "[LineItem](LineItem.mdx)[]",
|
||||||
"description": "The details of the line items that belong to the order.",
|
"description": "The details of the line items that belong to the order.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -617,7 +617,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -653,7 +653,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "payment_status",
|
"name": "payment_status",
|
||||||
"type": "[`PaymentStatus`](../enums/PaymentStatus.mdx)",
|
"type": "[PaymentStatus](../enums/PaymentStatus.mdx)",
|
||||||
"description": "The order's payment status",
|
"description": "The order's payment status",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "not_paid",
|
"defaultValue": "not_paid",
|
||||||
@@ -662,7 +662,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "payments",
|
"name": "payments",
|
||||||
"type": "[`Payment`](Payment.mdx)[]",
|
"type": "[Payment](Payment.mdx)[]",
|
||||||
"description": "The details of the payments used in the order.",
|
"description": "The details of the payments used in the order.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -698,7 +698,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "refunds",
|
"name": "refunds",
|
||||||
"type": "[`Refund`](Refund.mdx)[]",
|
"type": "[Refund](Refund.mdx)[]",
|
||||||
"description": "The details of the refunds created for the order.",
|
"description": "The details of the refunds created for the order.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -707,7 +707,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "region",
|
"name": "region",
|
||||||
"type": "[`Region`](Region.mdx)",
|
"type": "[Region](Region.mdx)",
|
||||||
"description": "The details of the region this order was created in.",
|
"description": "The details of the region this order was created in.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -725,7 +725,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "returnable_items",
|
"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",
|
"description": "The details of the line items that are returnable as part of the order, swaps, or claims",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -734,7 +734,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "returns",
|
"name": "returns",
|
||||||
"type": "[`Return`](Return.mdx)[]",
|
"type": "[Return](Return.mdx)[]",
|
||||||
"description": "The details of the returns created for the order.",
|
"description": "The details of the returns created for the order.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -743,7 +743,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sales_channel",
|
"name": "sales_channel",
|
||||||
"type": "[`SalesChannel`](SalesChannel.mdx)",
|
"type": "[SalesChannel](SalesChannel.mdx)",
|
||||||
"description": "The details of the sales channel this order belongs to.",
|
"description": "The details of the sales channel this order belongs to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -761,7 +761,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "shipping_address",
|
"name": "shipping_address",
|
||||||
"type": "[`Address`](Address.mdx)",
|
"type": "[Address](Address.mdx)",
|
||||||
"description": "The details of the shipping address associated with the order.",
|
"description": "The details of the shipping address associated with the order.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -779,7 +779,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "shipping_methods",
|
"name": "shipping_methods",
|
||||||
"type": "[`ShippingMethod`](ShippingMethod.mdx)[]",
|
"type": "[ShippingMethod](ShippingMethod.mdx)[]",
|
||||||
"description": "The details of the shipping methods used in the order.",
|
"description": "The details of the shipping methods used in the order.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -806,7 +806,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "status",
|
"name": "status",
|
||||||
"type": "[`OrderStatus`](../enums/OrderStatus.mdx)",
|
"type": "[OrderStatus](../enums/OrderStatus.mdx)",
|
||||||
"description": "The order's status",
|
"description": "The order's status",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "pending",
|
"defaultValue": "pending",
|
||||||
@@ -824,7 +824,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "swaps",
|
"name": "swaps",
|
||||||
"type": "[`Swap`](Swap.mdx)[]",
|
"type": "[Swap](Swap.mdx)[]",
|
||||||
"description": "The details of the swaps created for the order.",
|
"description": "The details of the swaps created for the order.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -889,7 +889,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "shipping_addresses",
|
"name": "shipping_addresses",
|
||||||
"type": "[`Address`](Address.mdx)[]",
|
"type": "[Address](Address.mdx)[]",
|
||||||
"description": "The details of the shipping addresses associated with the customer.",
|
"description": "The details of the shipping addresses associated with the customer.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -933,7 +933,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "country",
|
"name": "country",
|
||||||
"type": "``null`` \\| [`Country`](Country.mdx)",
|
"type": "``null`` \\| [Country](Country.mdx)",
|
||||||
"description": "A country object.",
|
"description": "A country object.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -960,7 +960,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "customer",
|
"name": "customer",
|
||||||
"type": "``null`` \\| [`Customer`](Customer.mdx)",
|
"type": "``null`` \\| [Customer](Customer.mdx)",
|
||||||
"description": "Available if the relation `customer` is expanded.",
|
"description": "Available if the relation `customer` is expanded.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -1014,7 +1014,7 @@ A customer can make purchases in your store and manage their profile.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ A customer group that can be used to organize customers into groups of similar t
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "customers",
|
"name": "customers",
|
||||||
"type": "[`Customer`](Customer.mdx)[]",
|
"type": "[Customer](Customer.mdx)[]",
|
||||||
"description": "The details of the customers that belong to the customer group.",
|
"description": "The details of the customers that belong to the customer group.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -30,7 +30,7 @@ A customer group that can be used to organize customers into groups of similar t
|
|||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"name": "billing_address",
|
"name": "billing_address",
|
||||||
"type": "[`Address`](Address.mdx)",
|
"type": "[Address](Address.mdx)",
|
||||||
"description": "The details of the billing address associated with the customer.",
|
"description": "The details of the billing address associated with the customer.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -84,7 +84,7 @@ A customer group that can be used to organize customers into groups of similar t
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "groups",
|
"name": "groups",
|
||||||
"type": "[`CustomerGroup`](CustomerGroup.mdx)[]",
|
"type": "[CustomerGroup](CustomerGroup.mdx)[]",
|
||||||
"description": "The customer groups the customer belongs to.",
|
"description": "The customer groups the customer belongs to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -120,7 +120,7 @@ A customer group that can be used to organize customers into groups of similar t
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -129,7 +129,7 @@ A customer group that can be used to organize customers into groups of similar t
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "orders",
|
"name": "orders",
|
||||||
"type": "[`Order`](Order.mdx)[]",
|
"type": "[Order](Order.mdx)[]",
|
||||||
"description": "The details of the orders this customer placed.",
|
"description": "The details of the orders this customer placed.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -156,7 +156,7 @@ A customer group that can be used to organize customers into groups of similar t
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "shipping_addresses",
|
"name": "shipping_addresses",
|
||||||
"type": "[`Address`](Address.mdx)[]",
|
"type": "[Address](Address.mdx)[]",
|
||||||
"description": "The details of the shipping addresses associated with the customer.",
|
"description": "The details of the shipping addresses associated with the customer.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -194,7 +194,7 @@ A customer group that can be used to organize customers into groups of similar t
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -212,7 +212,7 @@ A customer group that can be used to organize customers into groups of similar t
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "price_lists",
|
"name": "price_lists",
|
||||||
"type": "[`PriceList`](PriceList.mdx)[]",
|
"type": "[PriceList](PriceList.mdx)[]",
|
||||||
"description": "The price lists that are associated with the customer group.",
|
"description": "The price lists that are associated with the customer group.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -229,7 +229,7 @@ A customer group that can be used to organize customers into groups of similar t
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "customer_groups",
|
"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.",
|
"description": "The details of the customer groups that the Price List can apply to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -293,7 +293,7 @@ A customer group that can be used to organize customers into groups of similar t
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "prices",
|
"name": "prices",
|
||||||
"type": "[`MoneyAmount`](MoneyAmount.mdx)[]",
|
"type": "[MoneyAmount](MoneyAmount.mdx)[]",
|
||||||
"description": "The prices that belong to the price list, represented as a Money Amount.",
|
"description": "The prices that belong to the price list, represented as a Money Amount.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -311,7 +311,7 @@ A customer group that can be used to organize customers into groups of similar t
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "status",
|
"name": "status",
|
||||||
"type": "[`PriceListStatus`](../enums/PriceListStatus.mdx)",
|
"type": "[PriceListStatus](../enums/PriceListStatus.mdx)",
|
||||||
"description": "The status of the Price List",
|
"description": "The status of the Price List",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "draft",
|
"defaultValue": "draft",
|
||||||
@@ -320,7 +320,7 @@ A customer group that can be used to organize customers into groups of similar t
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "type",
|
"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`.",
|
"description": "The type of Price List. This can be one of either `sale` or `override`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "sale",
|
"defaultValue": "sale",
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ A discount can be applied to a cart for promotional purposes.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -85,7 +85,7 @@ A discount can be applied to a cart for promotional purposes.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "parent_discount",
|
"name": "parent_discount",
|
||||||
"type": "[`Discount`](Discount.mdx)",
|
"type": "[Discount](Discount.mdx)",
|
||||||
"description": "The details of the parent discount that this discount was created from.",
|
"description": "The details of the parent discount that this discount was created from.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -156,7 +156,7 @@ A discount can be applied to a cart for promotional purposes.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -165,7 +165,7 @@ A discount can be applied to a cart for promotional purposes.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "parent_discount",
|
"name": "parent_discount",
|
||||||
"type": "[`Discount`](Discount.mdx)",
|
"type": "[Discount](Discount.mdx)",
|
||||||
"description": "The details of the parent discount that this discount was created from.",
|
"description": "The details of the parent discount that this discount was created from.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -183,7 +183,7 @@ A discount can be applied to a cart for promotional purposes.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "regions",
|
"name": "regions",
|
||||||
"type": "[`Region`](Region.mdx)[]",
|
"type": "[Region](Region.mdx)[]",
|
||||||
"description": "The details of the regions in which the Discount can be used.",
|
"description": "The details of the regions in which the Discount can be used.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -192,7 +192,7 @@ A discount can be applied to a cart for promotional purposes.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "rule",
|
"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..",
|
"description": "The details of the discount rule that defines how the discount will be applied to a cart..",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -266,7 +266,7 @@ A discount can be applied to a cart for promotional purposes.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "regions",
|
"name": "regions",
|
||||||
"type": "[`Region`](Region.mdx)[]",
|
"type": "[Region](Region.mdx)[]",
|
||||||
"description": "The details of the regions in which the Discount can be used.",
|
"description": "The details of the regions in which the Discount can be used.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -283,7 +283,7 @@ A discount can be applied to a cart for promotional purposes.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "countries",
|
"name": "countries",
|
||||||
"type": "[`Country`](Country.mdx)[]",
|
"type": "[Country](Country.mdx)[]",
|
||||||
"description": "The details of the countries included in this region.",
|
"description": "The details of the countries included in this region.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -301,7 +301,7 @@ A discount can be applied to a cart for promotional purposes.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "currency",
|
"name": "currency",
|
||||||
"type": "[`Currency`](Currency.mdx)",
|
"type": "[Currency](Currency.mdx)",
|
||||||
"description": "The details of the currency used in the region.",
|
"description": "The details of the currency used in the region.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -328,7 +328,7 @@ A discount can be applied to a cart for promotional purposes.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "fulfillment_providers",
|
"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.",
|
"description": "The details of the fulfillment providers that can be used to fulfill items of orders and similar resources in the region.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -365,7 +365,7 @@ A discount can be applied to a cart for promotional purposes.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -383,7 +383,7 @@ A discount can be applied to a cart for promotional purposes.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "payment_providers",
|
"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.",
|
"description": "The details of the payment providers that can be used to process payments in the region.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -401,7 +401,7 @@ A discount can be applied to a cart for promotional purposes.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "tax_provider",
|
"name": "tax_provider",
|
||||||
"type": "[`TaxProvider`](TaxProvider.mdx)",
|
"type": "[TaxProvider](TaxProvider.mdx)",
|
||||||
"description": "The details of the tax provider used in the region.",
|
"description": "The details of the tax provider used in the region.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -428,7 +428,7 @@ A discount can be applied to a cart for promotional purposes.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "tax_rates",
|
"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.",
|
"description": "The details of the tax rates used in the region, aside from the default rate.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -448,7 +448,7 @@ A discount can be applied to a cart for promotional purposes.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "rule",
|
"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..",
|
"description": "The details of the discount rule that defines how the discount will be applied to a cart..",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -456,7 +456,7 @@ A discount can be applied to a cart for promotional purposes.
|
|||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"name": "allocation",
|
"name": "allocation",
|
||||||
"type": "[`AllocationType`](../enums/AllocationType.mdx)",
|
"type": "[AllocationType](../enums/AllocationType.mdx)",
|
||||||
"description": "The scope that the discount should apply to.",
|
"description": "The scope that the discount should apply to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -465,7 +465,7 @@ A discount can be applied to a cart for promotional purposes.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "conditions",
|
"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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -510,7 +510,7 @@ A discount can be applied to a cart for promotional purposes.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -519,8 +519,8 @@ A discount can be applied to a cart for promotional purposes.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "type",
|
"name": "type",
|
||||||
"type": "[`DiscountRuleType`](../enums/DiscountRuleType.mdx)",
|
"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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": false,
|
"expandable": false,
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "customer_groups",
|
"name": "customer_groups",
|
||||||
"type": "[`CustomerGroup`](CustomerGroup.mdx)[]",
|
"type": "[CustomerGroup](CustomerGroup.mdx)[]",
|
||||||
"description": "Customer groups associated with this condition if `type` is `customer_groups`.",
|
"description": "Customer groups associated with this condition if `type` is `customer\\_groups`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": true,
|
"expandable": true,
|
||||||
@@ -39,7 +39,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "customers",
|
"name": "customers",
|
||||||
"type": "[`Customer`](Customer.mdx)[]",
|
"type": "[Customer](Customer.mdx)[]",
|
||||||
"description": "The details of the customers that belong to the customer group.",
|
"description": "The details of the customers that belong to the customer group.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -66,7 +66,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -84,7 +84,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "price_lists",
|
"name": "price_lists",
|
||||||
"type": "[`PriceList`](PriceList.mdx)[]",
|
"type": "[PriceList](PriceList.mdx)[]",
|
||||||
"description": "The price lists that are associated with the customer group.",
|
"description": "The price lists that are associated with the customer group.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -113,7 +113,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "discount_rule",
|
"name": "discount_rule",
|
||||||
"type": "[`DiscountRule`](DiscountRule.mdx)",
|
"type": "[DiscountRule](DiscountRule.mdx)",
|
||||||
"description": "The details of the discount rule associated with the condition.",
|
"description": "The details of the discount rule associated with the condition.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -121,7 +121,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"name": "allocation",
|
"name": "allocation",
|
||||||
"type": "[`AllocationType`](../enums/AllocationType.mdx)",
|
"type": "[AllocationType](../enums/AllocationType.mdx)",
|
||||||
"description": "The scope that the discount should apply to.",
|
"description": "The scope that the discount should apply to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -130,7 +130,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "conditions",
|
"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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -175,7 +175,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -184,8 +184,8 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "type",
|
"name": "type",
|
||||||
"type": "[`DiscountRuleType`](../enums/DiscountRuleType.mdx)",
|
"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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": false,
|
"expandable": false,
|
||||||
@@ -231,7 +231,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -240,8 +240,8 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "operator",
|
"name": "operator",
|
||||||
"type": "[`DiscountConditionOperator`](../enums/DiscountConditionOperator.mdx)",
|
"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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": false,
|
"expandable": false,
|
||||||
@@ -268,8 +268,8 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "product_collections",
|
"name": "product_collections",
|
||||||
"type": "[`ProductCollection`](ProductCollection.mdx)[]",
|
"type": "[ProductCollection](ProductCollection.mdx)[]",
|
||||||
"description": "Product collections associated with this condition if `type` is `product_collections`.",
|
"description": "Product collections associated with this condition if `type` is `product\\_collections`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": true,
|
"expandable": true,
|
||||||
@@ -312,7 +312,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -321,7 +321,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "products",
|
"name": "products",
|
||||||
"type": "[`Product`](Product.mdx)[]",
|
"type": "[Product](Product.mdx)[]",
|
||||||
"description": "The details of the products that belong to this product collection.",
|
"description": "The details of the products that belong to this product collection.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -350,8 +350,8 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "product_tags",
|
"name": "product_tags",
|
||||||
"type": "[`ProductTag`](ProductTag.mdx)[]",
|
"type": "[ProductTag](ProductTag.mdx)[]",
|
||||||
"description": "Product tags associated with this condition if `type` is `product_tags`.",
|
"description": "Product tags associated with this condition if `type` is `product\\_tags`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": true,
|
"expandable": true,
|
||||||
@@ -385,7 +385,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -414,8 +414,8 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "product_types",
|
"name": "product_types",
|
||||||
"type": "[`ProductType`](ProductType.mdx)[]",
|
"type": "[ProductType](ProductType.mdx)[]",
|
||||||
"description": "Product types associated with this condition if `type` is `product_types`.",
|
"description": "Product types associated with this condition if `type` is `product\\_types`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": true,
|
"expandable": true,
|
||||||
@@ -449,7 +449,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -478,7 +478,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "products",
|
"name": "products",
|
||||||
"type": "[`Product`](Product.mdx)[]",
|
"type": "[Product](Product.mdx)[]",
|
||||||
"description": "products associated with this condition if `type` is `products`.",
|
"description": "products associated with this condition if `type` is `products`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -486,7 +486,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"name": "categories",
|
"name": "categories",
|
||||||
"type": "[`ProductCategory`](ProductCategory.mdx)[]",
|
"type": "[ProductCategory](ProductCategory.mdx)[]",
|
||||||
"description": "The details of the product categories that this product belongs to.",
|
"description": "The details of the product categories that this product belongs to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -496,7 +496,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "collection",
|
"name": "collection",
|
||||||
"type": "[`ProductCollection`](ProductCollection.mdx)",
|
"type": "[ProductCollection](ProductCollection.mdx)",
|
||||||
"description": "The details of the product collection that the product belongs to.",
|
"description": "The details of the product collection that the product belongs to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -595,7 +595,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "images",
|
"name": "images",
|
||||||
"type": "[`Image`](Image.mdx)[]",
|
"type": "[Image](Image.mdx)[]",
|
||||||
"description": "The details of the product's images.",
|
"description": "The details of the product's images.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -631,7 +631,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "``null`` \\| Record<`string`, `unknown`\\>",
|
"type": "``null`` \\| `Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -649,7 +649,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "options",
|
"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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -667,7 +667,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "profile",
|
"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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -685,7 +685,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "profiles",
|
"name": "profiles",
|
||||||
"type": "[`ShippingProfile`](ShippingProfile.mdx)[]",
|
"type": "[ShippingProfile](ShippingProfile.mdx)[]",
|
||||||
"description": "Available if the relation `profiles` is expanded.",
|
"description": "Available if the relation `profiles` is expanded.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -694,7 +694,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sales_channels",
|
"name": "sales_channels",
|
||||||
"type": "[`SalesChannel`](SalesChannel.mdx)[]",
|
"type": "[SalesChannel](SalesChannel.mdx)[]",
|
||||||
"description": "The details of the sales channels this product is available in.",
|
"description": "The details of the sales channels this product is available in.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -703,7 +703,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "status",
|
"name": "status",
|
||||||
"type": "[`ProductStatus`](../enums/ProductStatus.mdx)",
|
"type": "[ProductStatus](../enums/ProductStatus.mdx)",
|
||||||
"description": "The status of the product",
|
"description": "The status of the product",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "draft",
|
"defaultValue": "draft",
|
||||||
@@ -721,7 +721,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "tags",
|
"name": "tags",
|
||||||
"type": "[`ProductTag`](ProductTag.mdx)[]",
|
"type": "[ProductTag](ProductTag.mdx)[]",
|
||||||
"description": "The details of the product tags used in this product.",
|
"description": "The details of the product tags used in this product.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -748,7 +748,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "type",
|
"name": "type",
|
||||||
"type": "[`ProductType`](ProductType.mdx)",
|
"type": "[ProductType](ProductType.mdx)",
|
||||||
"description": "The details of the product type that the product belongs to.",
|
"description": "The details of the product type that the product belongs to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -775,7 +775,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "variants",
|
"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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -804,7 +804,7 @@ Holds rule conditions for when a discount is applicable
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
|
|||||||
+22
-22
@@ -31,8 +31,8 @@ Associates a discount condition with a customer group
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "customer_group",
|
"name": "customer_group",
|
||||||
"type": "[`CustomerGroup`](CustomerGroup.mdx)",
|
"type": "[CustomerGroup](CustomerGroup.mdx)",
|
||||||
"description": "Available if the relation `customer_group` is expanded.",
|
"description": "Available if the relation `customer\\_group` is expanded.",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": false,
|
"expandable": false,
|
||||||
@@ -48,7 +48,7 @@ Associates a discount condition with a customer group
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "customers",
|
"name": "customers",
|
||||||
"type": "[`Customer`](Customer.mdx)[]",
|
"type": "[Customer](Customer.mdx)[]",
|
||||||
"description": "The details of the customers that belong to the customer group.",
|
"description": "The details of the customers that belong to the customer group.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -75,7 +75,7 @@ Associates a discount condition with a customer group
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -93,7 +93,7 @@ Associates a discount condition with a customer group
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "price_lists",
|
"name": "price_lists",
|
||||||
"type": "[`PriceList`](PriceList.mdx)[]",
|
"type": "[PriceList](PriceList.mdx)[]",
|
||||||
"description": "The price lists that are associated with the customer group.",
|
"description": "The price lists that are associated with the customer group.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -122,8 +122,8 @@ Associates a discount condition with a customer group
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "discount_condition",
|
"name": "discount_condition",
|
||||||
"type": "[`DiscountCondition`](DiscountCondition.mdx)",
|
"type": "[DiscountCondition](DiscountCondition.mdx)",
|
||||||
"description": "Available if the relation `discount_condition` is expanded.",
|
"description": "Available if the relation `discount\\_condition` is expanded.",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": false,
|
"expandable": false,
|
||||||
@@ -139,8 +139,8 @@ Associates a discount condition with a customer group
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "customer_groups",
|
"name": "customer_groups",
|
||||||
"type": "[`CustomerGroup`](CustomerGroup.mdx)[]",
|
"type": "[CustomerGroup](CustomerGroup.mdx)[]",
|
||||||
"description": "Customer groups associated with this condition if `type` is `customer_groups`.",
|
"description": "Customer groups associated with this condition if `type` is `customer\\_groups`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": true,
|
"expandable": true,
|
||||||
@@ -157,7 +157,7 @@ Associates a discount condition with a customer group
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "discount_rule",
|
"name": "discount_rule",
|
||||||
"type": "[`DiscountRule`](DiscountRule.mdx)",
|
"type": "[DiscountRule](DiscountRule.mdx)",
|
||||||
"description": "The details of the discount rule associated with the condition.",
|
"description": "The details of the discount rule associated with the condition.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -184,7 +184,7 @@ Associates a discount condition with a customer group
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -193,8 +193,8 @@ Associates a discount condition with a customer group
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "operator",
|
"name": "operator",
|
||||||
"type": "[`DiscountConditionOperator`](../enums/DiscountConditionOperator.mdx)",
|
"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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": false,
|
"expandable": false,
|
||||||
@@ -202,8 +202,8 @@ Associates a discount condition with a customer group
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "product_collections",
|
"name": "product_collections",
|
||||||
"type": "[`ProductCollection`](ProductCollection.mdx)[]",
|
"type": "[ProductCollection](ProductCollection.mdx)[]",
|
||||||
"description": "Product collections associated with this condition if `type` is `product_collections`.",
|
"description": "Product collections associated with this condition if `type` is `product\\_collections`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": true,
|
"expandable": true,
|
||||||
@@ -211,8 +211,8 @@ Associates a discount condition with a customer group
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "product_tags",
|
"name": "product_tags",
|
||||||
"type": "[`ProductTag`](ProductTag.mdx)[]",
|
"type": "[ProductTag](ProductTag.mdx)[]",
|
||||||
"description": "Product tags associated with this condition if `type` is `product_tags`.",
|
"description": "Product tags associated with this condition if `type` is `product\\_tags`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": true,
|
"expandable": true,
|
||||||
@@ -220,8 +220,8 @@ Associates a discount condition with a customer group
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "product_types",
|
"name": "product_types",
|
||||||
"type": "[`ProductType`](ProductType.mdx)[]",
|
"type": "[ProductType](ProductType.mdx)[]",
|
||||||
"description": "Product types associated with this condition if `type` is `product_types`.",
|
"description": "Product types associated with this condition if `type` is `product\\_types`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": true,
|
"expandable": true,
|
||||||
@@ -229,7 +229,7 @@ Associates a discount condition with a customer group
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "products",
|
"name": "products",
|
||||||
"type": "[`Product`](Product.mdx)[]",
|
"type": "[Product](Product.mdx)[]",
|
||||||
"description": "products associated with this condition if `type` is `products`.",
|
"description": "products associated with this condition if `type` is `products`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -238,7 +238,7 @@ Associates a discount condition with a customer group
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -258,7 +258,7 @@ Associates a discount condition with a customer group
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "discount_condition",
|
"name": "discount_condition",
|
||||||
"type": "[`DiscountCondition`](DiscountCondition.mdx)",
|
"type": "[DiscountCondition](DiscountCondition.mdx)",
|
||||||
"description": "The details of the discount condition.",
|
"description": "The details of the discount condition.",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -48,8 +48,8 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "customer_groups",
|
"name": "customer_groups",
|
||||||
"type": "[`CustomerGroup`](CustomerGroup.mdx)[]",
|
"type": "[CustomerGroup](CustomerGroup.mdx)[]",
|
||||||
"description": "Customer groups associated with this condition if `type` is `customer_groups`.",
|
"description": "Customer groups associated with this condition if `type` is `customer\\_groups`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": true,
|
"expandable": true,
|
||||||
@@ -66,7 +66,7 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "discount_rule",
|
"name": "discount_rule",
|
||||||
"type": "[`DiscountRule`](DiscountRule.mdx)",
|
"type": "[DiscountRule](DiscountRule.mdx)",
|
||||||
"description": "The details of the discount rule associated with the condition.",
|
"description": "The details of the discount rule associated with the condition.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -93,7 +93,7 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -102,8 +102,8 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "operator",
|
"name": "operator",
|
||||||
"type": "[`DiscountConditionOperator`](../enums/DiscountConditionOperator.mdx)",
|
"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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": false,
|
"expandable": false,
|
||||||
@@ -111,8 +111,8 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "product_collections",
|
"name": "product_collections",
|
||||||
"type": "[`ProductCollection`](ProductCollection.mdx)[]",
|
"type": "[ProductCollection](ProductCollection.mdx)[]",
|
||||||
"description": "Product collections associated with this condition if `type` is `product_collections`.",
|
"description": "Product collections associated with this condition if `type` is `product\\_collections`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": true,
|
"expandable": true,
|
||||||
@@ -120,8 +120,8 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "product_tags",
|
"name": "product_tags",
|
||||||
"type": "[`ProductTag`](ProductTag.mdx)[]",
|
"type": "[ProductTag](ProductTag.mdx)[]",
|
||||||
"description": "Product tags associated with this condition if `type` is `product_tags`.",
|
"description": "Product tags associated with this condition if `type` is `product\\_tags`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": true,
|
"expandable": true,
|
||||||
@@ -129,8 +129,8 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "product_types",
|
"name": "product_types",
|
||||||
"type": "[`ProductType`](ProductType.mdx)[]",
|
"type": "[ProductType](ProductType.mdx)[]",
|
||||||
"description": "Product types associated with this condition if `type` is `product_types`.",
|
"description": "Product types associated with this condition if `type` is `product\\_types`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": true,
|
"expandable": true,
|
||||||
@@ -138,7 +138,7 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "products",
|
"name": "products",
|
||||||
"type": "[`Product`](Product.mdx)[]",
|
"type": "[Product](Product.mdx)[]",
|
||||||
"description": "products associated with this condition if `type` is `products`.",
|
"description": "products associated with this condition if `type` is `products`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -147,7 +147,7 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -167,7 +167,7 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -176,7 +176,7 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "product",
|
"name": "product",
|
||||||
"type": "[`Product`](Product.mdx)",
|
"type": "[Product](Product.mdx)",
|
||||||
"description": "The details of the product.",
|
"description": "The details of the product.",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -184,7 +184,7 @@ This represents the association between a discount condition and a product
|
|||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"name": "categories",
|
"name": "categories",
|
||||||
"type": "[`ProductCategory`](ProductCategory.mdx)[]",
|
"type": "[ProductCategory](ProductCategory.mdx)[]",
|
||||||
"description": "The details of the product categories that this product belongs to.",
|
"description": "The details of the product categories that this product belongs to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -194,7 +194,7 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "collection",
|
"name": "collection",
|
||||||
"type": "[`ProductCollection`](ProductCollection.mdx)",
|
"type": "[ProductCollection](ProductCollection.mdx)",
|
||||||
"description": "The details of the product collection that the product belongs to.",
|
"description": "The details of the product collection that the product belongs to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -293,7 +293,7 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "images",
|
"name": "images",
|
||||||
"type": "[`Image`](Image.mdx)[]",
|
"type": "[Image](Image.mdx)[]",
|
||||||
"description": "The details of the product's images.",
|
"description": "The details of the product's images.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -329,7 +329,7 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "``null`` \\| Record<`string`, `unknown`\\>",
|
"type": "``null`` \\| `Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -347,7 +347,7 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "options",
|
"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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -365,7 +365,7 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "profile",
|
"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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -383,7 +383,7 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "profiles",
|
"name": "profiles",
|
||||||
"type": "[`ShippingProfile`](ShippingProfile.mdx)[]",
|
"type": "[ShippingProfile](ShippingProfile.mdx)[]",
|
||||||
"description": "Available if the relation `profiles` is expanded.",
|
"description": "Available if the relation `profiles` is expanded.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -392,7 +392,7 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sales_channels",
|
"name": "sales_channels",
|
||||||
"type": "[`SalesChannel`](SalesChannel.mdx)[]",
|
"type": "[SalesChannel](SalesChannel.mdx)[]",
|
||||||
"description": "The details of the sales channels this product is available in.",
|
"description": "The details of the sales channels this product is available in.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -401,7 +401,7 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "status",
|
"name": "status",
|
||||||
"type": "[`ProductStatus`](../enums/ProductStatus.mdx)",
|
"type": "[ProductStatus](../enums/ProductStatus.mdx)",
|
||||||
"description": "The status of the product",
|
"description": "The status of the product",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "draft",
|
"defaultValue": "draft",
|
||||||
@@ -419,7 +419,7 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "tags",
|
"name": "tags",
|
||||||
"type": "[`ProductTag`](ProductTag.mdx)[]",
|
"type": "[ProductTag](ProductTag.mdx)[]",
|
||||||
"description": "The details of the product tags used in this product.",
|
"description": "The details of the product tags used in this product.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -446,7 +446,7 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "type",
|
"name": "type",
|
||||||
"type": "[`ProductType`](ProductType.mdx)",
|
"type": "[ProductType](ProductType.mdx)",
|
||||||
"description": "The details of the product type that the product belongs to.",
|
"description": "The details of the product type that the product belongs to.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -473,7 +473,7 @@ This represents the association between a discount condition and a product
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "variants",
|
"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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
|
|||||||
+19
-19
@@ -31,7 +31,7 @@ This represents the association between a discount condition and a product colle
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "discount_condition",
|
"name": "discount_condition",
|
||||||
"type": "[`DiscountCondition`](DiscountCondition.mdx)",
|
"type": "[DiscountCondition](DiscountCondition.mdx)",
|
||||||
"description": "The details of the discount condition.",
|
"description": "The details of the discount condition.",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -48,8 +48,8 @@ This represents the association between a discount condition and a product colle
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "customer_groups",
|
"name": "customer_groups",
|
||||||
"type": "[`CustomerGroup`](CustomerGroup.mdx)[]",
|
"type": "[CustomerGroup](CustomerGroup.mdx)[]",
|
||||||
"description": "Customer groups associated with this condition if `type` is `customer_groups`.",
|
"description": "Customer groups associated with this condition if `type` is `customer\\_groups`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": true,
|
"expandable": true,
|
||||||
@@ -66,7 +66,7 @@ This represents the association between a discount condition and a product colle
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "discount_rule",
|
"name": "discount_rule",
|
||||||
"type": "[`DiscountRule`](DiscountRule.mdx)",
|
"type": "[DiscountRule](DiscountRule.mdx)",
|
||||||
"description": "The details of the discount rule associated with the condition.",
|
"description": "The details of the discount rule associated with the condition.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -93,7 +93,7 @@ This represents the association between a discount condition and a product colle
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -102,8 +102,8 @@ This represents the association between a discount condition and a product colle
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "operator",
|
"name": "operator",
|
||||||
"type": "[`DiscountConditionOperator`](../enums/DiscountConditionOperator.mdx)",
|
"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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": false,
|
"expandable": false,
|
||||||
@@ -111,8 +111,8 @@ This represents the association between a discount condition and a product colle
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "product_collections",
|
"name": "product_collections",
|
||||||
"type": "[`ProductCollection`](ProductCollection.mdx)[]",
|
"type": "[ProductCollection](ProductCollection.mdx)[]",
|
||||||
"description": "Product collections associated with this condition if `type` is `product_collections`.",
|
"description": "Product collections associated with this condition if `type` is `product\\_collections`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": true,
|
"expandable": true,
|
||||||
@@ -120,8 +120,8 @@ This represents the association between a discount condition and a product colle
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "product_tags",
|
"name": "product_tags",
|
||||||
"type": "[`ProductTag`](ProductTag.mdx)[]",
|
"type": "[ProductTag](ProductTag.mdx)[]",
|
||||||
"description": "Product tags associated with this condition if `type` is `product_tags`.",
|
"description": "Product tags associated with this condition if `type` is `product\\_tags`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": true,
|
"expandable": true,
|
||||||
@@ -129,8 +129,8 @@ This represents the association between a discount condition and a product colle
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "product_types",
|
"name": "product_types",
|
||||||
"type": "[`ProductType`](ProductType.mdx)[]",
|
"type": "[ProductType](ProductType.mdx)[]",
|
||||||
"description": "Product types associated with this condition if `type` is `product_types`.",
|
"description": "Product types associated with this condition if `type` is `product\\_types`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": true,
|
"expandable": true,
|
||||||
@@ -138,7 +138,7 @@ This represents the association between a discount condition and a product colle
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "products",
|
"name": "products",
|
||||||
"type": "[`Product`](Product.mdx)[]",
|
"type": "[Product](Product.mdx)[]",
|
||||||
"description": "products associated with this condition if `type` is `products`.",
|
"description": "products associated with this condition if `type` is `products`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -147,7 +147,7 @@ This represents the association between a discount condition and a product colle
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -167,7 +167,7 @@ This represents the association between a discount condition and a product colle
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -176,7 +176,7 @@ This represents the association between a discount condition and a product colle
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "product_collection",
|
"name": "product_collection",
|
||||||
"type": "[`ProductCollection`](ProductCollection.mdx)",
|
"type": "[ProductCollection](ProductCollection.mdx)",
|
||||||
"description": "The details of the product collection.",
|
"description": "The details of the product collection.",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -220,7 +220,7 @@ This represents the association between a discount condition and a product colle
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -229,7 +229,7 @@ This represents the association between a discount condition and a product colle
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "products",
|
"name": "products",
|
||||||
"type": "[`Product`](Product.mdx)[]",
|
"type": "[Product](Product.mdx)[]",
|
||||||
"description": "The details of the products that belong to this product collection.",
|
"description": "The details of the products that belong to this product collection.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ This represents the association between a discount condition and a product tag
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "discount_condition",
|
"name": "discount_condition",
|
||||||
"type": "[`DiscountCondition`](DiscountCondition.mdx)",
|
"type": "[DiscountCondition](DiscountCondition.mdx)",
|
||||||
"description": "The details of the discount condition.",
|
"description": "The details of the discount condition.",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -48,8 +48,8 @@ This represents the association between a discount condition and a product tag
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "customer_groups",
|
"name": "customer_groups",
|
||||||
"type": "[`CustomerGroup`](CustomerGroup.mdx)[]",
|
"type": "[CustomerGroup](CustomerGroup.mdx)[]",
|
||||||
"description": "Customer groups associated with this condition if `type` is `customer_groups`.",
|
"description": "Customer groups associated with this condition if `type` is `customer\\_groups`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": true,
|
"expandable": true,
|
||||||
@@ -66,7 +66,7 @@ This represents the association between a discount condition and a product tag
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "discount_rule",
|
"name": "discount_rule",
|
||||||
"type": "[`DiscountRule`](DiscountRule.mdx)",
|
"type": "[DiscountRule](DiscountRule.mdx)",
|
||||||
"description": "The details of the discount rule associated with the condition.",
|
"description": "The details of the discount rule associated with the condition.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -93,7 +93,7 @@ This represents the association between a discount condition and a product tag
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -102,8 +102,8 @@ This represents the association between a discount condition and a product tag
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "operator",
|
"name": "operator",
|
||||||
"type": "[`DiscountConditionOperator`](../enums/DiscountConditionOperator.mdx)",
|
"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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": false,
|
"expandable": false,
|
||||||
@@ -111,8 +111,8 @@ This represents the association between a discount condition and a product tag
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "product_collections",
|
"name": "product_collections",
|
||||||
"type": "[`ProductCollection`](ProductCollection.mdx)[]",
|
"type": "[ProductCollection](ProductCollection.mdx)[]",
|
||||||
"description": "Product collections associated with this condition if `type` is `product_collections`.",
|
"description": "Product collections associated with this condition if `type` is `product\\_collections`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": true,
|
"expandable": true,
|
||||||
@@ -120,8 +120,8 @@ This represents the association between a discount condition and a product tag
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "product_tags",
|
"name": "product_tags",
|
||||||
"type": "[`ProductTag`](ProductTag.mdx)[]",
|
"type": "[ProductTag](ProductTag.mdx)[]",
|
||||||
"description": "Product tags associated with this condition if `type` is `product_tags`.",
|
"description": "Product tags associated with this condition if `type` is `product\\_tags`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": true,
|
"expandable": true,
|
||||||
@@ -129,8 +129,8 @@ This represents the association between a discount condition and a product tag
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "product_types",
|
"name": "product_types",
|
||||||
"type": "[`ProductType`](ProductType.mdx)[]",
|
"type": "[ProductType](ProductType.mdx)[]",
|
||||||
"description": "Product types associated with this condition if `type` is `product_types`.",
|
"description": "Product types associated with this condition if `type` is `product\\_types`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"expandable": true,
|
"expandable": true,
|
||||||
@@ -138,7 +138,7 @@ This represents the association between a discount condition and a product tag
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "products",
|
"name": "products",
|
||||||
"type": "[`Product`](Product.mdx)[]",
|
"type": "[Product](Product.mdx)[]",
|
||||||
"description": "products associated with this condition if `type` is `products`.",
|
"description": "products associated with this condition if `type` is `products`.",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -147,7 +147,7 @@ This represents the association between a discount condition and a product tag
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "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.",
|
"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,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -167,7 +167,7 @@ This represents the association between a discount condition and a product tag
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -176,7 +176,7 @@ This represents the association between a discount condition and a product tag
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "product_tag",
|
"name": "product_tag",
|
||||||
"type": "[`ProductTag`](ProductTag.mdx)",
|
"type": "[ProductTag](ProductTag.mdx)",
|
||||||
"description": "The details of the product tag.",
|
"description": "The details of the product tag.",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
@@ -211,7 +211,7 @@ This represents the association between a discount condition and a product tag
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "Record<`string`, `unknown`\\>",
|
"type": "`Record<string, unknown>`",
|
||||||
"description": "An optional key-value map with additional details",
|
"description": "An optional key-value map with additional details",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
|
|||||||
Loaded 100 of 2265 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user