chore(docs): Generated References (automated) (#12154)
Generated the following references: - `api_key` - `auth` - `cart` - `cart_models` - `core_flows` - `currency` - `customer` - `event` - `file_service` - `fulfillment` - `fulfillment_provider` - `inventory_next` - `js_sdk` - `locking` - `medusa` - `modules` - `modules_sdk` - `notification_service` - `order` - `payment` - `payment_provider` - `pricing` - `product` - `promotion` - `region` - `sales_channel` - `stock_location_next` - `store` - `tax` - `types` - `user` - `utils` - `workflows` Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com> Co-authored-by: Shahed Nasser <27354907+shahednasser@users.noreply.github.com>
This commit is contained in:
1790 files changed
+220057
-187216
No files matched your search
+30
-2
@@ -2,10 +2,38 @@ import { TypeList } from "docs-ui"
|
||||
|
||||
# addRules
|
||||
|
||||
This method creates and adds rules to a promotion. It can be the promotion's rules,
|
||||
or its application method's buy or target rules. That depends on the rule type
|
||||
you specify as a parameter.
|
||||
|
||||
- If you set the `ruleType` to `rules`, the method sends a request to the
|
||||
[Manage Promotion's Rules API Route](https://docs.medusajs.com/api/admin#promotions\_postpromotionsidrulesbatch).
|
||||
- If you set the `ruleType` to `buy-rules`, the method sends a request to the
|
||||
[Manage Promotion's Buy Rules API Route](https://docs.medusajs.com/api/admin#promotions\_postpromotionsidbuyrulesbatch).
|
||||
- If you set the `ruleType` to `target-rules`, the method sends a request to the
|
||||
[Manage Promotion's Target Rules API Route](https://docs.medusajs.com/api/admin#promotions\_postpromotionsidtargetrulesbatch).
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
sdk.admin.promotion.addRules("promo_123", "rules", {
|
||||
rules: [
|
||||
{
|
||||
operator: "eq",
|
||||
attribute: "product_id",
|
||||
values: ["prod_123"]
|
||||
}
|
||||
]
|
||||
})
|
||||
.then(({ promotion }) => {
|
||||
console.log(promotion)
|
||||
})
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<TypeList types={[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"ruleType","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[BatchAddPromotionRulesReq](../../../../../types/HttpTypes/interfaces/types.HttpTypes.BatchAddPromotionRulesReq/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"rules","type":"[AdminCreatePromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCreatePromotionRule/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"operator","type":"[PromotionRuleOperatorValues](../../../../../promotion/types/promotion.PromotionRuleOperatorValues/page.mdx)","description":"The possible operators to use in a promotion rule.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"attribute","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"values","type":"`string` \\| `string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="addRules"/>
|
||||
<TypeList types={[{"name":"id","type":"`string`","description":"The promotion's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"ruleType","type":"`string`","description":"The type of rules to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[BatchAddPromotionRulesReq](../../../../../types/HttpTypes/interfaces/types.HttpTypes.BatchAddPromotionRulesReq/page.mdx)","description":"The rules to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"rules","type":"[AdminCreatePromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCreatePromotionRule/page.mdx)[]","description":"The rules to add.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"operator","type":"[PromotionRuleOperatorValues](../../../../../promotion/types/promotion.PromotionRuleOperatorValues/page.mdx)","description":"The operator used to check whether the buy rule applies on a cart. \nFor example, `eq` means that the cart's value for the specified attribute \nmust match the specified value.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"attribute","type":"`string`","description":"The attribute to compare against when checking whether a promotion can be applied on a cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"values","type":"`string` \\| `string`[]","description":"The value to compare against when checking whether a promotion can be applied on a cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"The description of the promotion rule.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="addRules"/>
|
||||
|
||||
## Returns
|
||||
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[AdminPromotionResponse](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionResponse/page.mdx)>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"promotion","type":"[AdminPromotion](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"application_method","type":"[AdminApplicationMethod](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminApplicationMethod/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rules","type":"[AdminPromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionRule/page.mdx)[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[PromotionTypeValues](../../../../../promotion/types/promotion.PromotionTypeValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_automatic","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PromotionStatusValues](../../../../../promotion/types/promotion.PromotionStatusValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_id","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign","type":"[AdminCampaign](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCampaign/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="addRules"/>
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[AdminPromotionResponse](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionResponse/page.mdx)>","optional":false,"defaultValue":"","description":"The promotion's details.","expandable":false,"children":[{"name":"promotion","type":"[AdminPromotion](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotion/page.mdx)","description":"The promotion's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"application_method","type":"[AdminApplicationMethod](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminApplicationMethod/page.mdx)","description":"The promotion's application method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rules","type":"[AdminPromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionRule/page.mdx)[]","description":"The rules for the promotion.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[PromotionTypeValues](../../../../../promotion/types/promotion.PromotionTypeValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_automatic","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PromotionStatusValues](../../../../../promotion/types/promotion.PromotionStatusValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_id","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign","type":"[AdminCampaign](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCampaign/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="addRules"/>
|
||||
+21
-2
@@ -2,10 +2,29 @@ import { TypeList } from "docs-ui"
|
||||
|
||||
# create
|
||||
|
||||
This method creates a new promotion. It sends a request to the
|
||||
[Create Promotion](https://docs.medusajs.com/api/admin#promotions\_postpromotions)
|
||||
API route.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
sdk.admin.promotion.create({
|
||||
name: "My Promotion",
|
||||
description: "This is a test promotion",
|
||||
code: "PROMO123",
|
||||
starts_at: "2021-01-01",
|
||||
ends_at: "2021-01-01",
|
||||
})
|
||||
.then(({ promotion }) => {
|
||||
console.log(promotion)
|
||||
})
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<TypeList types={[{"name":"payload","type":"[AdminCreatePromotion](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCreatePromotion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[PromotionTypeValues](../../../../../promotion/types/promotion.PromotionTypeValues/page.mdx)","description":"The promotion's possible types.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"application_method","type":"[AdminCreateApplicationMethod](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCreateApplicationMethod/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ApplicationMethodTypeValues](../../../../../promotion/types/promotion.ApplicationMethodTypeValues/page.mdx)","description":"The application method's possible types.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"target_type","type":"[ApplicationMethodTargetTypeValues](../../../../../promotion/types/promotion.ApplicationMethodTargetTypeValues/page.mdx)","description":"The application method's possible target types.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"max_quantity","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"allocation","type":"[ApplicationMethodAllocationValues](../../../../../promotion/types/promotion.ApplicationMethodAllocationValues/page.mdx)","description":"The application method's possible allocation values.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"target_rules","type":"[AdminCreatePromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCreatePromotionRule/page.mdx)[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"buy_rules","type":"[AdminCreatePromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCreatePromotionRule/page.mdx)[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"apply_to_quantity","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"buy_rules_min_quantity","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"is_automatic","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_id","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign","type":"[AdminCreateCampaign](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCreateCampaign/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"The campaign's name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The campaign's description.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"currency","type":"`null` \\| `string`","description":"The campaign's currency code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_identifier","type":"`string`","description":"The campaign's identifier.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"starts_at","type":"`null` \\| `Date`","description":"The date the campaign and its promotions start at.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ends_at","type":"`null` \\| `Date`","description":"The date the campaign and its promotions end at.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"budget","type":"`null` \\| `object`","description":"The campaign's budget.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"rules","type":"[AdminCreatePromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCreatePromotionRule/page.mdx)[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"operator","type":"[PromotionRuleOperatorValues](../../../../../promotion/types/promotion.PromotionRuleOperatorValues/page.mdx)","description":"The possible operators to use in a proLine truncated
|
||||
<TypeList types={[{"name":"payload","type":"[AdminCreatePromotion](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCreatePromotion/page.mdx)","description":"The promotion to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The promotion's code.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[PromotionTypeValues](../../../../../promotion/types/promotion.PromotionTypeValues/page.mdx)","description":"The type of promotion.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"application_method","type":"[AdminCreateApplicationMethod](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCreateApplicationMethod/page.mdx)","description":"The application method of the promotion.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`number`","description":"The value of the application method.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ApplicationMethodTypeValues](../../../../../promotion/types/promotion.ApplicationMethodTypeValues/page.mdx)","description":"The type of the application method.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"target_type","type":"[ApplicationMethodTargetTypeValues](../../../../../promotion/types/promotion.ApplicationMethodTargetTypeValues/page.mdx)","description":"The target type of the application method indicating whether the associated promotion is applied \nto the cart's items, shipping methods, or the whole order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"The description of the application method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`null` \\| `string`","description":"The currency code of the application method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"max_quantity","type":"`null` \\| `number`","description":"The max quantity allowed in the cart for the associated promotion to be applied.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"allocation","type":"[ApplicationMethodAllocationValues](../../../../../promotion/types/promotion.ApplicationMethodAllocationValues/page.mdx)","description":"The allocation value that indicates whether the associated promotion is applied on each \nitem in a cart or split between the items in the cart.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"target_rules","type":"[AdminCreatePromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCreatePromotionRule/page.mdx)[]","description":"The target rules of the application method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"buy_rules","type":"[AdminCreatePromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCreatePromotionRule/page.mdx)[]","description":"The buy rules of the application method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"apply_to_quantity","type":"`null` \\| `number`","description":"The quantity of the application method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"buy_rules_min_quantity","type":"`null` \\| `number`","description":"The minimum quantity required for a `buyget` promotion to be applied. For example, \nif the promotion is a \"Buy 2 shirts get 1 free\", the value of this attribute is 2.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"is_automatic","type":"`boolean`","description":"Whether the promotion is applied automatically \nor requires the customer to manually apply it\nby entering the code at checkout.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_id","type":"`null` \\| `string`","description":"The ID of the campaign that the promotion belongs to.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign","type":"[AdminCreateCampaign](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCreateCampaign/page.mdx)","description":"The campaign that the promotion belongs to.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"The campaign's name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The campaign's description.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"currency","type":"`null` \\| `string`","description":"The campaign's currency code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_identifier","type":"`string`","description":"The campaign's identifier.","optional":Line truncated
|
||||
|
||||
## Returns
|
||||
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[AdminPromotionResponse](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionResponse/page.mdx)>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"promotion","type":"[AdminPromotion](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"application_method","type":"[AdminApplicationMethod](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminApplicationMethod/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rules","type":"[AdminPromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionRule/page.mdx)[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[PromotionTypeValues](../../../../../promotion/types/promotion.PromotionTypeValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_automatic","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PromotionStatusValues](../../../../../promotion/types/promotion.PromotionStatusValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_id","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign","type":"[AdminCampaign](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCampaign/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="create"/>
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[AdminPromotionResponse](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionResponse/page.mdx)>","optional":false,"defaultValue":"","description":"The promotion's details.","expandable":false,"children":[{"name":"promotion","type":"[AdminPromotion](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotion/page.mdx)","description":"The promotion's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"application_method","type":"[AdminApplicationMethod](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminApplicationMethod/page.mdx)","description":"The promotion's application method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rules","type":"[AdminPromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionRule/page.mdx)[]","description":"The rules for the promotion.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[PromotionTypeValues](../../../../../promotion/types/promotion.PromotionTypeValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_automatic","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PromotionStatusValues](../../../../../promotion/types/promotion.PromotionStatusValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_id","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign","type":"[AdminCampaign](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCampaign/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="create"/>
|
||||
+15
-2
@@ -2,10 +2,23 @@ import { TypeList } from "docs-ui"
|
||||
|
||||
# delete
|
||||
|
||||
This method deletes a promotion. It sends a request to the
|
||||
[Delete Promotion](https://docs.medusajs.com/api/admin#promotions\_deletepromotionsid)
|
||||
API route.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
sdk.admin.promotion.delete("promo_123")
|
||||
.then(({ promotion }) => {
|
||||
console.log(promotion)
|
||||
})
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<TypeList types={[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="delete"/>
|
||||
<TypeList types={[{"name":"id","type":"`string`","description":"The promotion's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="delete"/>
|
||||
|
||||
## Returns
|
||||
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[DeleteResponse](../../../../../types/HttpTypes/types/types.HttpTypes.DeleteResponse/page.mdx)<\"promotion\">>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"\"promotion\"","type":"`\"promotion\"`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="delete"/>
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[DeleteResponse](../../../../../types/HttpTypes/types/types.HttpTypes.DeleteResponse/page.mdx)<\"promotion\">>","optional":false,"defaultValue":"","description":"The deleted promotion's details.","expandable":false,"children":[{"name":"\"promotion\"","type":"`\"promotion\"`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="delete"/>
|
||||
+45
-2
@@ -2,10 +2,53 @@ import { TypeList } from "docs-ui"
|
||||
|
||||
# list
|
||||
|
||||
This method retrieves a list of promotions. It sends a request to the
|
||||
[List Promotions](https://docs.medusajs.com/api/admin#promotions\_getpromotions)
|
||||
API route.
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve the list of promotions:
|
||||
|
||||
```ts
|
||||
sdk.admin.promotion.list()
|
||||
.then(({ promotions, count, limit, offset }) => {
|
||||
console.log(promotions)
|
||||
})
|
||||
```
|
||||
|
||||
To configure the pagination, pass the `limit` and `offset` query parameters.
|
||||
|
||||
For example, to retrieve only 10 items and skip 10 items:
|
||||
|
||||
```ts
|
||||
sdk.admin.promotion.list({
|
||||
limit: 10,
|
||||
offset: 10
|
||||
})
|
||||
.then(({ promotions, count, limit, offset }) => {
|
||||
console.log(promotions)
|
||||
})
|
||||
```
|
||||
|
||||
Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
||||
in each promotion:
|
||||
|
||||
```ts
|
||||
sdk.admin.promotion.list({
|
||||
fields: "id,*application_method"
|
||||
})
|
||||
.then(({ promotions, count, limit, offset }) => {
|
||||
console.log(promotions)
|
||||
})
|
||||
```
|
||||
|
||||
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
|
||||
## Parameters
|
||||
|
||||
<TypeList types={[{"name":"query","type":"[AdminGetPromotionsParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminGetPromotionsParams/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"The fields and relations to retrieve separated by commas.\n\nLearn more in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"The maximum number of items to retrieve.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip before retrieving the returned items.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort by and in which order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string` \\| `string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_id","type":"`string` \\| `string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"application_method","type":"`object`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"currency_code","type":"`string` \\| `string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"[OperatorMap](../../../../../types/DAL/types/types.DAL.OperatorMap/page.mdx)<string>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"$and","type":"[Query](../../../../../types/types/types.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$or","type":"[Query](../../../../../types/types/types.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$eq","type":"[ExpandScalar](../../../../../types/types/types.ExpandScalar/page.mdx)<T> \\| [ExpandScalar](../../../../../types/types/types.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ne","type":"[ExpandScalar](../../../../../types/types/types.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$in","type":"[ExpandScalar](../../../../../types/types/types.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$nin","type":"[ExpandScalar](../../../../../types/types/types.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$not","type":"[Query](../../../../../types/types/types.Query/page.mdx)<T>","description":"API wrapper around the remoteQuery","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gt","type":"[ExpandScalar](../../../../../types/types/types.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gte","type":"[ExpandScalar](../../../../../types/types/types.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lt","type":"[ExpandScalar](../../../../../types/types/types.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lte","type":"[ExpandScalar](../../../../../types/types/types.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$like","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$re","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ilike","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$fulltext","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$overlap","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contains","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contained","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$exists","type":"`boolean`","description":"","optional":truLine truncated
|
||||
<TypeList types={[{"name":"query","type":"[AdminGetPromotionsParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminGetPromotionsParams/page.mdx)","description":"Filters and pagination configurations.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"The fields and relations to retrieve separated by commas.\n\nLearn more in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"The maximum number of items to retrieve.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip before retrieving the returned items.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort by and in which order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"Search for a promotion by its searchable","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string` \\| `string`[] \\| [OperatorMap](../../../../../types/DAL/types/types.DAL.OperatorMap/page.mdx)<string>","description":"Filter by promotion code.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"$and","type":"[Query](../../../../../types/types/types.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$or","type":"[Query](../../../../../types/types/types.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$eq","type":"[ExpandScalar](../../../../../types/types/types.ExpandScalar/page.mdx)<T> \\| [ExpandScalar](../../../../../types/types/types.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ne","type":"[ExpandScalar](../../../../../types/types/types.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$in","type":"[ExpandScalar](../../../../../types/types/types.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$nin","type":"[ExpandScalar](../../../../../types/types/types.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$not","type":"[Query](../../../../../types/types/types.Query/page.mdx)<T>","description":"API wrapper around the remoteQuery","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gt","type":"[ExpandScalar](../../../../../types/types/types.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gte","type":"[ExpandScalar](../../../../../types/types/types.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lt","type":"[ExpandScalar](../../../../../types/types/types.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lte","type":"[ExpandScalar](../../../../../types/types/types.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$like","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$re","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ilike","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$fulltext","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$overlap","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contains","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contained","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$exists","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"campaign_id","type":"`string` \\| `string`[]","description":"Filter by campaign ID to retrieve promotions by campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"application_method","type":"`object`","description":"Filter by the promotion's application method.","optional":true,"defaultValue":"","expandable":false,"childLine truncated
|
||||
|
||||
## Returns
|
||||
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[AdminPromotionListResponse](../../../../../types/HttpTypes/types/types.HttpTypes.AdminPromotionListResponse/page.mdx)>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items retrieved.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip before retrieving the returned items.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="list"/>
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[AdminPromotionListResponse](../../../../../types/HttpTypes/types/types.HttpTypes.AdminPromotionListResponse/page.mdx)>","optional":false,"defaultValue":"","description":"The list of promotions.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items retrieved.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip before retrieving the returned items.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="list"/>
|
||||
+20
-2
@@ -2,10 +2,28 @@ import { TypeList } from "docs-ui"
|
||||
|
||||
# listRuleAttributes
|
||||
|
||||
Retrieve a list of potential rule attributes for the promotion and application method types specified in the query parameters. Only the attributes of the rule type specified in the path parameter are retrieved:
|
||||
|
||||
- If `rule_type` is `rules`, the attributes of the promotion's type are retrieved.
|
||||
- If `rule_type` is `target-rules`, the target rules' attributes of the application method's type are retrieved.
|
||||
- If `rule_type` is `buy-rules`, the buy rules' attributes of the application method's type are retrieved.
|
||||
|
||||
This method sends a request to the
|
||||
[List Rule Attribute Options API Route](https://docs.medusajs.com/api/admin#promotions\_getpromotionsruleattributeoptionsrule\_type)
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
sdk.admin.promotion.listRuleAttributes("rules", "standard")
|
||||
.then(({ attributes }) => {
|
||||
console.log(attributes)
|
||||
})
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<TypeList types={[{"name":"ruleType","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"promotionType","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="listRuleAttributes"/>
|
||||
<TypeList types={[{"name":"ruleType","type":"`string`","description":"The type of rules to retrieve the attributes for. Can be `rules`, `buy-rules`, or `target-rules`.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"promotionType","type":"`string`","description":"The type of promotion to retrieve the attributes for. It can be `standard` or `buyget`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="listRuleAttributes"/>
|
||||
|
||||
## Returns
|
||||
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[AdminRuleAttributeOptionsListResponse](../../../../../types/HttpTypes/types/types.HttpTypes.AdminRuleAttributeOptionsListResponse/page.mdx)>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"attributes","type":"[AdminRuleAttributeOption](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminRuleAttributeOption/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"label","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"operators","type":"[BaseRuleOperatorOptions](../../../../../types/interfaces/types.BaseRuleOperatorOptions/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="listRuleAttributes"/>
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[AdminRuleAttributeOptionsListResponse](../../../../../types/HttpTypes/types/types.HttpTypes.AdminRuleAttributeOptionsListResponse/page.mdx)>","optional":false,"defaultValue":"","description":"The list of rule attributes.","expandable":false,"children":[{"name":"attributes","type":"[AdminRuleAttributeOption](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminRuleAttributeOption/page.mdx)[]","description":"The list of rule attribute options.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The rule attribute option's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string`","description":"The rule attribute option's value.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"label","type":"`string`","description":"The rule attribute option's label.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"operators","type":"[BaseRuleOperatorOptions](../../../../../types/interfaces/types.BaseRuleOperatorOptions/page.mdx)[]","description":"The attribute option's operators.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="listRuleAttributes"/>
|
||||
+18
-2
@@ -2,10 +2,26 @@ import { TypeList } from "docs-ui"
|
||||
|
||||
# listRuleValues
|
||||
|
||||
Retrieve all potential values for promotion rules and target and buy rules based on the specified rule attribute and type.
|
||||
For example, if you provide the ID of the `currency_code` rule attribute, and set `rule_type` to rules,
|
||||
a list of currencies are retrieved in label-value pairs.
|
||||
|
||||
This method sends a request to the
|
||||
[List Rule Values API Route](https://docs.medusajs.com/api/admin#promotions\_getpromotionsrulevalueoptionsrule\_typerule\_attribute\_id)
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
sdk.admin.promotion.listRuleValues("rules", "attr_123")
|
||||
.then(({ values }) => {
|
||||
console.log(values)
|
||||
})
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<TypeList types={[{"name":"ruleType","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"ruleValue","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[AdminGetPromotionsRuleValueParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminGetPromotionsRuleValueParams/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"The fields and relations to retrieve separated by commas.\n\nLearn more in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"The maximum number of items to retrieve.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip before retrieving the returned items.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort by and in which order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string` \\| `string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="listRuleValues"/>
|
||||
<TypeList types={[{"name":"ruleType","type":"`string`","description":"The type of rules to retrieve the values for. Can be `rules`, `buy-rules`, or `target-rules`.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"ruleValue","type":"`string`","description":"The ID of the rule attribute to retrieve the values for.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[AdminGetPromotionsRuleValueParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminGetPromotionsRuleValueParams/page.mdx)","description":"Configure the fields to retrieve in the rule values.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"The fields and relations to retrieve separated by commas.\n\nLearn more in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"The maximum number of items to retrieve.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip before retrieving the returned items.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort by and in which order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"Search for a rule value by its searchable","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string` \\| `string`[]","description":"Filter by rule value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="listRuleValues"/>
|
||||
|
||||
## Returns
|
||||
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[AdminRuleValueOptionsListResponse](../../../../../types/HttpTypes/types/types.HttpTypes.AdminRuleValueOptionsListResponse/page.mdx)>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"values","type":"[AdminRuleValueOption](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminRuleValueOption/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"label","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="listRuleValues"/>
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[AdminRuleValueOptionsListResponse](../../../../../types/HttpTypes/types/types.HttpTypes.AdminRuleValueOptionsListResponse/page.mdx)>","optional":false,"defaultValue":"","description":"The list of rule values.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items retrieved.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip before retrieving the returned items.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="listRuleValues"/>
|
||||
+18
-2
@@ -2,10 +2,26 @@ import { TypeList } from "docs-ui"
|
||||
|
||||
# listRules
|
||||
|
||||
This method retrieves the rules of a promotion. It can be the promotion's rules,
|
||||
or its application method's buy or target rules. That depends on the rule type
|
||||
you specify as a parameter.
|
||||
|
||||
This method sends a request to the
|
||||
[List Rules of a Promotion API Route](https://docs.medusajs.com/api/admin#promotions\_getpromotionsidrule\_type)
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
sdk.admin.promotion.listRules("promo_123", "rules")
|
||||
.then(({ rules }) => {
|
||||
console.log(rules)
|
||||
})
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<TypeList types={[{"name":"id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"ruleType","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[AdminGetPromotionRuleParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminGetPromotionRuleParams/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"promotion_type","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"application_method_type","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="listRules"/>
|
||||
<TypeList types={[{"name":"id","type":"`null` \\| `string`","description":"The promotion's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"ruleType","type":"`string`","description":"The type of rules to retrieve. Can be `rules`, `buy-rules`, or `target-rules`.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[AdminGetPromotionRuleParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminGetPromotionRuleParams/page.mdx)","description":"Configure the fields to retrieve in the rules.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"promotion_type","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"application_method_type","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="listRules"/>
|
||||
|
||||
## Returns
|
||||
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[AdminRuleAttributeOptionsListResponse](../../../../../types/HttpTypes/types/types.HttpTypes.AdminRuleAttributeOptionsListResponse/page.mdx)>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"attributes","type":"[AdminRuleAttributeOption](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminRuleAttributeOption/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"label","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"operators","type":"[BaseRuleOperatorOptions](../../../../../types/interfaces/types.BaseRuleOperatorOptions/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="listRules"/>
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[AdminPromotionRuleListResponse](../../../../../types/HttpTypes/types/types.HttpTypes.AdminPromotionRuleListResponse/page.mdx)>","optional":false,"defaultValue":"","description":"The promotion's rules.","expandable":false,"children":[{"name":"rules","type":"[AdminPromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionRule/page.mdx)[]","description":"The list of promotion rules.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The rule's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"values","type":"[BasePromotionRuleValue](../../../../../types/interfaces/types.BasePromotionRuleValue/page.mdx)[]","description":"The values to compare against when checking whether a promotion can be applied on a cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"The rule's description.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"attribute","type":"`string`","description":"The attribute to compare against when checking whether a promotion can be applied on a cart.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"operator","type":"[PromotionRuleOperatorValues](../../../../../promotion/types/promotion.PromotionRuleOperatorValues/page.mdx)","description":"The operator used to check whether the buy rule applies on a cart. \nFor example, `eq` means that the cart's value for the specified attribute \nmust match the specified value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="listRules"/>
|
||||
+24
-2
@@ -2,10 +2,32 @@ import { TypeList } from "docs-ui"
|
||||
|
||||
# removeRules
|
||||
|
||||
This method removes rules from a promotion. It can be the promotion's rules,
|
||||
or its application method's buy or target rules. That depends on the rule type
|
||||
you specify as a parameter.
|
||||
|
||||
- If you set the `ruleType` to `rules`, the method sends a request to the
|
||||
[Manage Promotion's Rules API Route](https://docs.medusajs.com/api/admin#promotions\_postpromotionsidrulesbatch).
|
||||
- If you set the `ruleType` to `buy-rules`, the method sends a request to the
|
||||
[Manage Promotion's Buy Rules API Route](https://docs.medusajs.com/api/admin#promotions\_postpromotionsidbuyrulesbatch).
|
||||
- If you set the `ruleType` to `target-rules`, the method sends a request to the
|
||||
[Manage Promotion's Target Rules API Route](https://docs.medusajs.com/api/admin#promotions\_postpromotionsidtargetrulesbatch).
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
sdk.admin.promotion.removeRules("promo_123", "rules", {
|
||||
rule_ids: ["rule_123"]
|
||||
})
|
||||
.then(({ promotion }) => {
|
||||
console.log(promotion)
|
||||
})
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<TypeList types={[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"ruleType","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[BatchRemovePromotionRulesReq](../../../../../types/HttpTypes/interfaces/types.HttpTypes.BatchRemovePromotionRulesReq/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"rule_ids","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="removeRules"/>
|
||||
<TypeList types={[{"name":"id","type":"`string`","description":"The promotion's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"ruleType","type":"`string`","description":"The type of rules to remove.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[BatchRemovePromotionRulesReq](../../../../../types/HttpTypes/interfaces/types.HttpTypes.BatchRemovePromotionRulesReq/page.mdx)","description":"The rules to remove.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"rule_ids","type":"`string`[]","description":"The IDs of the rules to remove.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="removeRules"/>
|
||||
|
||||
## Returns
|
||||
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[AdminPromotionResponse](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionResponse/page.mdx)>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"promotion","type":"[AdminPromotion](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"application_method","type":"[AdminApplicationMethod](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminApplicationMethod/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rules","type":"[AdminPromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionRule/page.mdx)[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[PromotionTypeValues](../../../../../promotion/types/promotion.PromotionTypeValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_automatic","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PromotionStatusValues](../../../../../promotion/types/promotion.PromotionStatusValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_id","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign","type":"[AdminCampaign](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCampaign/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="removeRules"/>
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[AdminPromotionResponse](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionResponse/page.mdx)>","optional":false,"defaultValue":"","description":"The promotion's details.","expandable":false,"children":[{"name":"promotion","type":"[AdminPromotion](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotion/page.mdx)","description":"The promotion's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"application_method","type":"[AdminApplicationMethod](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminApplicationMethod/page.mdx)","description":"The promotion's application method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rules","type":"[AdminPromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionRule/page.mdx)[]","description":"The rules for the promotion.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[PromotionTypeValues](../../../../../promotion/types/promotion.PromotionTypeValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_automatic","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PromotionStatusValues](../../../../../promotion/types/promotion.PromotionStatusValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_id","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign","type":"[AdminCampaign](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCampaign/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="removeRules"/>
|
||||
+30
-2
@@ -2,10 +2,38 @@ import { TypeList } from "docs-ui"
|
||||
|
||||
# retrieve
|
||||
|
||||
This method retrieves a promotion by its ID. It sends a request to the
|
||||
[Retrieve Promotion](https://docs.medusajs.com/api/admin#promotions\_getpromotionsid)
|
||||
API route.
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a promotion by its ID:
|
||||
|
||||
```ts
|
||||
sdk.admin.promotion.retrieve("promo_123")
|
||||
.then(({ promotion }) => {
|
||||
console.log(promotion)
|
||||
})
|
||||
```
|
||||
|
||||
To specify the fields and relations to retrieve:
|
||||
|
||||
```ts
|
||||
sdk.admin.promotion.retrieve("promo_123", {
|
||||
fields: "id,*application_method"
|
||||
})
|
||||
.then(({ promotion }) => {
|
||||
console.log(promotion)
|
||||
})
|
||||
```
|
||||
|
||||
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
|
||||
## Parameters
|
||||
|
||||
<TypeList types={[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[AdminGetPromotionParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminGetPromotionParams/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"The fields and relations to retrieve separated by commas.\n\nLearn more in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="retrieve"/>
|
||||
<TypeList types={[{"name":"id","type":"`string`","description":"The promotion's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[AdminGetPromotionParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminGetPromotionParams/page.mdx)","description":"Configure the fields to retrieve in the promotion.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"The fields and relations to retrieve separated by commas.\n\nLearn more in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="retrieve"/>
|
||||
|
||||
## Returns
|
||||
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[AdminPromotionResponse](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionResponse/page.mdx)>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"promotion","type":"[AdminPromotion](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"application_method","type":"[AdminApplicationMethod](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminApplicationMethod/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rules","type":"[AdminPromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionRule/page.mdx)[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[PromotionTypeValues](../../../../../promotion/types/promotion.PromotionTypeValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_automatic","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PromotionStatusValues](../../../../../promotion/types/promotion.PromotionStatusValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_id","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign","type":"[AdminCampaign](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCampaign/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="retrieve"/>
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[AdminPromotionResponse](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionResponse/page.mdx)>","optional":false,"defaultValue":"","description":"The promotion's details.","expandable":false,"children":[{"name":"promotion","type":"[AdminPromotion](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotion/page.mdx)","description":"The promotion's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"application_method","type":"[AdminApplicationMethod](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminApplicationMethod/page.mdx)","description":"The promotion's application method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rules","type":"[AdminPromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionRule/page.mdx)[]","description":"The rules for the promotion.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[PromotionTypeValues](../../../../../promotion/types/promotion.PromotionTypeValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_automatic","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PromotionStatusValues](../../../../../promotion/types/promotion.PromotionStatusValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_id","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign","type":"[AdminCampaign](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCampaign/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="retrieve"/>
|
||||
+17
-2
@@ -2,10 +2,25 @@ import { TypeList } from "docs-ui"
|
||||
|
||||
# update
|
||||
|
||||
This method updates a promotion. It sends a request to the
|
||||
[Update Promotion](https://docs.medusajs.com/api/admin#promotions\_postpromotionsid)
|
||||
API route.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
sdk.admin.promotion.update("promo_123", {
|
||||
code: "PROMO123",
|
||||
})
|
||||
.then(({ promotion }) => {
|
||||
console.log(promotion)
|
||||
})
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<TypeList types={[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminUpdatePromotion](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminUpdatePromotion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_automatic","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[PromotionTypeValues](../../../../../promotion/types/promotion.PromotionTypeValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PromotionStatusValues](../../../../../promotion/types/promotion.PromotionStatusValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_id","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign","type":"[AdminCreateCampaign](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCreateCampaign/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"The campaign's name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The campaign's description.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"currency","type":"`null` \\| `string`","description":"The campaign's currency code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_identifier","type":"`string`","description":"The campaign's identifier.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"starts_at","type":"`null` \\| `Date`","description":"The date the campaign and its promotions start at.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ends_at","type":"`null` \\| `Date`","description":"The date the campaign and its promotions end at.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"budget","type":"`null` \\| `object`","description":"The campaign's budget.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"application_method","type":"[AdminUpdateApplicationMethod](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminUpdateApplicationMethod/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"description","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"max_quantity","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ApplicationMethodTypeValues](../../../../../promotion/types/promotion.ApplicationMethodTypeValues/page.mdx)","description":"The application method's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"target_type","type":"[ApplicationMethodTargetTypeValues](../../../../../promotion/types/promotion.ApplicationMethodTargetTypeValues/page.mdx)","description":"The application method's possible target types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"allocation","type":"[ApplicationMethodAllocationValues](../../../../../promotion/types/promotion.ApplicationMethodAllocationValues/page.mdx)","description":"The application method's possible allocation values.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"target_rules","type":"[AdminCreatePromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCreatePromotionRule/page.mdx)[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"buy_rules","type":"[AdminCreatePromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCreatePromotionRule/page.mdx)[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"apply_to_quantity","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"buy_rules_min_quantity","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"rules","type":"[AdminCreatePromotionRule](../../../../../typLine truncated
|
||||
<TypeList types={[{"name":"id","type":"`string`","description":"The promotion's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminUpdatePromotion](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminUpdatePromotion/page.mdx)","description":"The details to update in the promotion.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The promotion's code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_automatic","type":"`boolean`","description":"Whether the promotion is applied automatically \nor requires the customer to manually apply it\nby entering the code at checkout.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[PromotionTypeValues](../../../../../promotion/types/promotion.PromotionTypeValues/page.mdx)","description":"The type of promotion.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PromotionStatusValues](../../../../../promotion/types/promotion.PromotionStatusValues/page.mdx)","description":"The status of the promotion.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_id","type":"`null` \\| `string`","description":"The ID of the campaign that the promotion belongs to.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign","type":"[AdminCreateCampaign](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCreateCampaign/page.mdx)","description":"The campaign that the promotion belongs to.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"The campaign's name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The campaign's description.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"currency","type":"`null` \\| `string`","description":"The campaign's currency code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_identifier","type":"`string`","description":"The campaign's identifier.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"starts_at","type":"`null` \\| `Date`","description":"The date the campaign and its promotions start at.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ends_at","type":"`null` \\| `Date`","description":"The date the campaign and its promotions end at.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"budget","type":"`null` \\| `object`","description":"The campaign's budget.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"application_method","type":"[AdminUpdateApplicationMethod](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminUpdateApplicationMethod/page.mdx)","description":"The application method of the promotion.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"description","type":"`null` \\| `string`","description":"The description of the application method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`number`","description":"The value of the application method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"max_quantity","type":"`null` \\| `number`","description":"The max quantity allowed in the cart for the associated promotion to be applied.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`null` \\| `string`","description":"The currency code of the application method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ApplicationMethodTypeValues](../../../../../promotion/types/promotion.ApplicationMethodTypeValues/page.mdx)","description":"The type of the application method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"target_type","type":"[ApplicationMethodTargetTypeValues](../../../../../promotion/types/promotion.ApplicationMethodTargetTypeValues/page.mdx)","description":"The target type of the application method indicating whether the associated promotion is applied \nto the cart's items, shipping methods, or the whole order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"allocation","type":"[ApplicationMethodAllocationValues](../../../../../promotion/types/promotion.ApplicationMethodAllocationValues/page.mdx)","description":"The allocation value that indicates whether the associated promotion is applied on each \nitem in a cart or split between the items in the cart.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"target_rules","type":"[AdminCreatePromotionRule](../../../../../types/HttpTypes/interfaces/typeLine truncated
|
||||
|
||||
## Returns
|
||||
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[AdminPromotionResponse](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionResponse/page.mdx)>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"promotion","type":"[AdminPromotion](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"application_method","type":"[AdminApplicationMethod](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminApplicationMethod/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rules","type":"[AdminPromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionRule/page.mdx)[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[PromotionTypeValues](../../../../../promotion/types/promotion.PromotionTypeValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_automatic","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PromotionStatusValues](../../../../../promotion/types/promotion.PromotionStatusValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_id","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign","type":"[AdminCampaign](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCampaign/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="update"/>
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[AdminPromotionResponse](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionResponse/page.mdx)>","optional":false,"defaultValue":"","description":"The promotion's details.","expandable":false,"children":[{"name":"promotion","type":"[AdminPromotion](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotion/page.mdx)","description":"The promotion's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"application_method","type":"[AdminApplicationMethod](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminApplicationMethod/page.mdx)","description":"The promotion's application method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rules","type":"[AdminPromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionRule/page.mdx)[]","description":"The rules for the promotion.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[PromotionTypeValues](../../../../../promotion/types/promotion.PromotionTypeValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_automatic","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PromotionStatusValues](../../../../../promotion/types/promotion.PromotionStatusValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_id","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign","type":"[AdminCampaign](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCampaign/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="update"/>
|
||||
+29
-2
@@ -2,10 +2,37 @@ import { TypeList } from "docs-ui"
|
||||
|
||||
# updateRules
|
||||
|
||||
This method updates the rules of a promotion. It can be the promotion's rules,
|
||||
or its application method's buy or target rules. That depends on the rule type
|
||||
you specify as a parameter.
|
||||
|
||||
- If you set the `ruleType` to `rules`, the method sends a request to the
|
||||
[Manage Promotion's Rules API Route](https://docs.medusajs.com/api/admin#promotions\_postpromotionsidrulesbatch).
|
||||
- If you set the `ruleType` to `buy-rules`, the method sends a request to the
|
||||
[Manage Promotion's Buy Rules API Route](https://docs.medusajs.com/api/admin#promotions\_postpromotionsidbuyrulesbatch).
|
||||
- If you set the `ruleType` to `target-rules`, the method sends a request to the
|
||||
[Manage Promotion's Target Rules API Route](https://docs.medusajs.com/api/admin#promotions\_postpromotionsidtargetrulesbatch).
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
sdk.admin.promotion.updateRules("promo_123", "rules", {
|
||||
rules: [
|
||||
{
|
||||
id: "rule_123",
|
||||
operator: "ne",
|
||||
}
|
||||
]
|
||||
})
|
||||
.then(({ promotion }) => {
|
||||
console.log(promotion)
|
||||
})
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<TypeList types={[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"ruleType","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[BatchUpdatePromotionRulesReq](../../../../../types/HttpTypes/interfaces/types.HttpTypes.BatchUpdatePromotionRulesReq/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"rules","type":"[AdminUpdatePromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminUpdatePromotionRule/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"values","type":"`string` \\| `string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"operator","type":"[PromotionRuleOperatorValues](../../../../../promotion/types/promotion.PromotionRuleOperatorValues/page.mdx)","description":"The possible operators to use in a promotion rule.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"attribute","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="updateRules"/>
|
||||
<TypeList types={[{"name":"id","type":"`string`","description":"The promotion's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"ruleType","type":"`string`","description":"The type of rules to update.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[BatchUpdatePromotionRulesReq](../../../../../types/HttpTypes/interfaces/types.HttpTypes.BatchUpdatePromotionRulesReq/page.mdx)","description":"The rules to update.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"rules","type":"[AdminUpdatePromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminUpdatePromotionRule/page.mdx)[]","description":"The rules to update.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"values","type":"`string` \\| `string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"operator","type":"[PromotionRuleOperatorValues](../../../../../promotion/types/promotion.PromotionRuleOperatorValues/page.mdx)","description":"The possible operators to use in a promotion rule.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"attribute","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="updateRules"/>
|
||||
|
||||
## Returns
|
||||
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[AdminPromotionResponse](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionResponse/page.mdx)>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"promotion","type":"[AdminPromotion](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"application_method","type":"[AdminApplicationMethod](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminApplicationMethod/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rules","type":"[AdminPromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionRule/page.mdx)[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[PromotionTypeValues](../../../../../promotion/types/promotion.PromotionTypeValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_automatic","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PromotionStatusValues](../../../../../promotion/types/promotion.PromotionStatusValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_id","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign","type":"[AdminCampaign](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCampaign/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="updateRules"/>
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[AdminPromotionResponse](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionResponse/page.mdx)>","optional":false,"defaultValue":"","description":"The promotion's details.","expandable":false,"children":[{"name":"promotion","type":"[AdminPromotion](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotion/page.mdx)","description":"The promotion's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"application_method","type":"[AdminApplicationMethod](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminApplicationMethod/page.mdx)","description":"The promotion's application method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rules","type":"[AdminPromotionRule](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminPromotionRule/page.mdx)[]","description":"The rules for the promotion.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[PromotionTypeValues](../../../../../promotion/types/promotion.PromotionTypeValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_automatic","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PromotionStatusValues](../../../../../promotion/types/promotion.PromotionStatusValues/page.mdx)","description":"The promotion's possible types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_id","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign","type":"[AdminCampaign](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCampaign/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="updateRules"/>
|
||||
Reference in new issue
Block a user