Function usePromotionsForCampaign

  • Handles get promotion by filter criteria. Returns an array of enabled promotions matching the specified filter criteria. In the request URL, you must provide a campaign_id parameter, and you can optionally specify a date range by providing start_date and end_date parameters. Both parameters are required to specify a date range, as omitting one causes the server to return a MissingParameterException fault. Each request returns only enabled promotions, since the server does not consider promotion qualifiers or schedules.

    Parameter

    apiOptions - Options to pass through to commerce-sdk-isomorphic, with null accepted for unset API parameters.

    Parameter

    queryOptions - TanStack Query query options, with enabled by default set to check that all required API parameters have been set.

    See

    Parameters

    • apiOptions: NullableParameters<{
          headers?: {
              [key: string]: string;
          };
          parameters: { campaignId: string; startDate?: string | undefined; endDate?: string | undefined; organizationId?: string | undefined; siteId?: string | undefined; currency?: string | undefined; };
      }>
    • queryOptions: ApiQueryOptions<{
          (options?): Promise<PromotionResult>;
          <T>(options?, rawResponse?): Promise<T extends true
              ? Response
              : PromotionResult>;
      }> = {}

    Returns UseQueryResult<PromotionResult, unknown>

    A TanStack Query query hook with data from the Shopper Promotions getPromotionsForCampaign endpoint.