Back to Medusa

registerUsage - Promotion Module Reference

www/apps/resources/references/promotion/IPromotionModuleService/methods/promotion.IPromotionModuleService.registerUsage/page.mdx

2.14.23.1 KB
Original Source

import { TypeList } from "docs-ui"

registerUsage - Promotion Module Reference

This documentation provides a reference to the registerUsage method. This belongs to the Promotion Module.

<Note>

You should only use this methods when implementing complex customizations. For common cases, check out available workflows instead.

</Note>

This method adjusts the budget for each campaign associated with the promotions' specified computed actions. It adjusts the used property of a CampaignBudget to account for the adjustment amounts in the specified associated computed actions.

Example

ts
await promotionModuleService.registerUsage([
  {
    amount: 50,
    code: "50OFF",
  },
  {
    amount: 5000,
    code: "FREESHIPPING",
  },
])

Parameters

<TypeList types={[{"name":"computedActions","type":"UsageComputedActions[]","description":"The computed actions to adjust their promotion's campaign budget.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"amount","type":"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","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","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":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="registerUsage"/>

Returns

<TypeList types={[{"name":"Promise","type":"Promise<void>","optional":false,"defaultValue":"","description":"Resolves when the campaign budgets have been adjusted successfully.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="registerUsage"/>