使用 API 更新/编辑 Wholesale Pricing
通过公共 API 更新现有的 Wholesale Pricing 规则,包含完整的请求正文参考。
本文介绍如何使用公共 API 更新现有的 Wholesale Pricing 规则。
要更新现有的 Wholesale Pricing 记录,请使用以下端点:
PUT https://wholesale.samita.io/api/v1/wholesale-pricings/{id}{id}是 Wholesale Pricing 记录的 ID- 可在应用界面中获取该 ID(不含“#”符号)
- 参考示例:

PUT https://wholesale.samita.io/api/v1/wholesale-pricings/12. 请求头
Section titled “2. 请求头”所有 API 请求都必须包含以下必填请求头:
| 请求头 | 说明 | 必填 |
|---|---|---|
X-SAMITA-API-KEY |
Wholesale 应用中提供的 API 密钥 | 是 |
X-SAMITA-SHOP-URL |
Shopify 商店域名,格式为 xxx.myshopify.com | 是 |
CONTENT-TYPE |
必须为 application/json |
是 |
如果缺少任何必填请求头,请求将被拒绝。
3. 请求正文
Section titled “3. 请求正文”_ 用于更新 Wholesale Pricing 的数据必须以 JSON 格式发送。本文末尾提供了示例 JSON 结构。
_ 请求中只需包含要更新的字段。与 Create API 方法不同,无需发送所有字段。
_ 未指定的字段将保持不变
示例请求 JSON:
{ "title": "New Wholesale Pricing", "status": true, "apply_customer": { "type": "all", "tags": [] }, "exclude_customer": { "type": "none", "tags": [] }, "apply_product": { "type": "all", "product_ids": [], "product_tags": [], "collection_ids": [], "apply_for_variants": false }, "exclude_product": { "type": "none", "product_ids": [], "collection_ids": [] }, "discount_for_variants": [ { "id": 8516448190631, "variant_pricing": true, "variants": [ { "id": 46747346763943, "discount_groups": [ { "name": "all", "type": "percent", "value": "10" } ] } ] } ], "apply_market": { "type": "all", "handle": [] }, "discount_group": { "type": "percent", "value": "10" }, "active_date": { "types": ["start_date", "end_date"], "start_at": "2026-01-15 10:00:00", "end_at": "2026-01-15 10:00:00" }}c. title
Section titled “c. title”- 用于标识 Wholesale Pricing 记录的名称
- 在 Update API 中为可选
- 必须为字符串
- 最大长度:255 个字符
d. status
Section titled “d. status”- 定义记录是否启用
- 在 Update API 中为可选
- 仅接受以下值:
| 值 | 说明 |
|---|---|
true |
定价规则已启用 |
false |
定价规则未启用 |
e. apply_customer
Section titled “e. apply_customer”定义哪些客户符合此定价规则。
结构:
"apply_customer": { "type": "all", "tags": []}type
可接受的值:
allloggednon-loggedcustomer-tags
tags
- 仅当
type == customer-tags时必填 - 必须为以逗号分隔的数组
- 示例:
["wholesale","b2b"]
f. exclude_customer
Section titled “f. exclude_customer”用于将特定客户排除在定价规则之外。
结构:
"exclude_customer": { "type": "none", "tags": []}type
- 默认值:
none - 可接受的值:
| 值 | 说明 |
|---|---|
none |
不排除任何客户 |
customer-tags |
按标签排除客户 |
tags
- 仅当
type == customer-tags时必填 - 示例:
["vip","wholesale"]
g. apply_product(必填)
Section titled “g. apply_product(必填)”定义定价规则适用于哪些产品。
结构:
"apply_product": { "type": "all", "product_ids": [], "product_tags": [], "collection_ids": [], "apply_for_variants": false}type
可接受的值:
allproductscollectionsproduct-tags
其他字段是否必填取决于所选的 type:
product_ids→ 如果type == products,则必填product_tags→ 如果type == product-tags,则必填collection_ids→ 如果type == collections,则必填
apply_for_variants
- 可接受的值:
true或false - 默认值:
false
h. exclude_product
Section titled “h. exclude_product”定义要排除在规则之外的产品。
结构:
"exclude_product": { "type": "none", "product_ids": [], "collection_ids": []}可接受的类型:
noneproductscollections
i. discount_for_variants
Section titled “i. discount_for_variants”在按多属性配置折扣时使用。
- 如果
apply_product.apply_for_variants == false,则必须为空 - 当
apply_product.apply_for_variants == true时必填
示例结构:
"discount_for_variants": [
{
"id": 8516448190631,
"variant_pricing": true,
"variants": [
{
"id": 46747346763943,
"discount_groups": [
{
"name": "all",
"type": "percent",
"value": "10"
}
]
}
]
}
]
结构:
- 产品数组
- 每个产品包含:
id– 产品 IDvariant_pricing– 必须为truevariants– 多属性数组
每个多属性包含:
id– 多属性 IDdiscount_groups– 折扣配置数组
discount_groups 规则
- 如果
apply_customer.type为all、logged或non-logged
→ 只允许 一项 - 如果
apply_customer.type == customer-tags
→ 可以提供多个折扣组
discount_groups 中的字段:
| 字段 | 说明 |
|---|---|
name |
必须与客户类型或客户标签匹配 |
type |
折扣类型 |
value |
折扣值 |
可接受的折扣类型:
percentamountfixed-amount
值的规则:
- 必须是大于 0 的数字
- 如果 type 为
percent,value 必须小于 100
j. apply_market(必填)
Section titled “j. apply_market(必填)”定义规则适用于哪些 Shopify 市场。
结构:
"apply_market": { "type": "all", "handle": []}type
可接受的值:
allspecific-market
handle
- 仅当
type == specific-market时必填 - 以逗号分隔的市场 handle 列表
- 示例:
["japan","us"]
k. discount_group
Section titled “k. discount_group”在未按多属性配置折扣时使用。
在以下情况下必填:
apply_product.type不是products,或apply_product.type == products且未应用多属性
结构:
"discount_group": { "type": "percent", "value": "10"}规则:
type必须为以下之一:percentamountfixed-amount
value- 必须大于 0
- 如果 type 为
percent,value 必须小于 100
l. active_date
Section titled “l. active_date”用于配置定价规则的开始和结束时间。
结构:
"active_date": { "types": ["start_date", "end_date"], "start_at": "2026-01-15T10:00:00", "end_at": "2026-01-15T10:00:00"}types
- 可选
- 可接受的值:
start_date、end_date - 示例:
["start_date","end_date"]
start_at
- 如果
types包含start_date,则为必填 - 格式:
YYYY-MM-DD HH:MM:SS
end_at
- 如果
types包含end_date,则为必填 - 格式:
YYYY-MM-DD HH:MM:SS
4. API 响应
Section titled “4. API 响应”a. 错误响应
Section titled “a. 错误响应”401 – Unauthorized
可能的原因:
- 缺少商店 URL
- 缺少 API 密钥
- 商店 URL 无效
- API 密钥无效
- API 密钥与商店不匹配
403 – This action is unauthorized
- API 密钥没有 Update 权限
- 每个 API 密钥可拥有:View、Create、Update、Delete 权限
- 此 API 需要 Update 权限
- 所提供的 ID 不存在时也会返回此错误
429 – Too Many Requests
超出速率限制:
- 最多 每 5 分钟 1 次请求
- 最多 每天 50 次请求
b. 成功响应
Section titled “b. 成功响应”200 – API Success
- Wholesale Pricing 记录更新成功
- 响应以 JSON 格式返回
示例响应 JSON:
{ "id": 1, "title": "New Wholesale Pricing", "status": true, "apply_customer": { "type": "all", "tags": [] }, "exclude_customer": { "type": "none", "tags": [] }, "apply_product": { "type": "all", "product_ids": [], "product_tags": [], "collection_ids": [], "apply_for_variants": false }, "exclude_product": { "type": "none", "product_ids": [], "collection_ids": [] }, "discount_for_variants": [ { "id": 8516448190631, "variant_pricing": true, "variants": [ { "id": 46747346763943, "discount_groups": [ { "name": "all", "type": "percent", "value": "10" } ] } ] } ], "apply_market": { "type": "all", "handle": [] }, "discount_group": { "type": "percent", "value": "10" }, "active_date": { "types": [], "start_at": "", "end_at": "" }, "created_at": "2026-01-15T10:00:00", "updated_at": "2026-01-15T10:00:00"}