|
1
|
{"slug":"/references/promotion/registerUsage","title":"registerUsage - Promotion Module Reference","frontmatter":{"displayed_sidebar":"promotionReference","slug":"/references/promotion/registerUsage","sidebar_label":"registerUsage"},"toc":[{"title":"Example","id":"example","level":2},{"title":"Parameters","id":"registerusage-parameters","level":2},{"title":"Returns","id":"registerusage-returns","level":2}],"blocks":[{"kind":"markdown","html":"This documentation provides a reference to the `registerUsage` method. This belongs to the Promotion Module."},{"kind":"note","variant":"note","html":"You should only use this methods when implementing complex customizations. For common cases, check out [available workflows instead](/medusa-workflows-reference)."},{"kind":"markdown","html":"This method adjusts the budget for each campaign associated with the promotions' specified computed actions.\nIt adjusts the `used` property of a `CampaignBudget` to account for the adjustment amounts in the specified associated\ncomputed actions."},{"kind":"heading","level":2,"text":"Example","id":"example"},{"kind":"markdown","html":"```ts\nawait promotionModuleService.registerUsage([\n {\n amount: 50,\n code: \"50OFF\",\n },\n {\n amount: 5000,\n code: \"FREESHIPPING\",\n },\n])\n```"},{"kind":"heading","level":2,"text":"Parameters","id":"registerusage-parameters"},{"kind":"typeList","sectionTitle":"registerUsage","types":[{"name":"computedActions","type":"[UsageComputedActions](/references/promotion/types/promotion.UsageComputedActions)[]","description":"The computed actions to adjust their promotion's campaign budget.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"amount","type":"[BigNumberInput](/references/promotion/types/promotion.BigNumberInput)","description":"The amount (of usage or money) to adjust the campaign budget by.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](/references/promotion/types/promotion.BigNumberRawValue)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"code","type":"`string`","description":"The promotion's code.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"registrationContext","type":"[CampaignBudgetUsageContext](/references/promotion/types/promotion.CampaignBudgetUsageContext)","description":"The context of the campaign budget usage.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"customer_id","type":"`string` \\| `null`","description":"The ID of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_email","type":"`string` \\| `null`","description":"The email of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"kind":"heading","level":2,"text":"Returns","id":"registerusage-returns"},{"kind":"typeList","sectionTitle":"registerUsage","types":[{"name":"Promise","type":"Promise<void>","optional":false,"defaultValue":"","description":"Resolves when the campaign budgets have been adjusted successfully.","expandable":false,"children":[]}]}]} |