---
displayed_sidebar: servicesSidebar
---

import ParameterTypes from "@site/src/components/ParameterTypes"

# DiscountService

Provides layer to manipulate discounts.

## Implements

## constructor

`**new DiscountService**(«destructured»)`

### Parameters

<ParameterTypes parameters={[
  {
    "name": "__namedParameters",
    "type": "`Object`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

___

## Properties

<ParameterTypes parameters={[
  {
    "name": "__configModule__",
    "type": "`Record<string, unknown>`",
    "description": "",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "__container__",
    "type": "`any`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "__moduleDeclaration__",
    "type": "`Record<string, unknown>`",
    "description": "",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "customerService_",
    "type": "[CustomerService](CustomerService.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "discountConditionRepository_",
    "type": "Repository&#60;[DiscountCondition](DiscountCondition.mdx)&#62; & ``{ addConditionResources: Method addConditionResources ; canApplyForCustomer: Method canApplyForCustomer ; findOneWithDiscount: Method findOneWithDiscount ; getJoinTableResourceIdentifiers: Method getJoinTableResourceIdentifiers ; isValidForProduct: Method isValidForProduct ; queryConditionTable: Method queryConditionTable ; removeConditionResources: Method removeConditionResources  }``",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "discountConditionService_",
    "type": "[DiscountConditionService](DiscountConditionService.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "discountRepository_",
    "type": "Repository&#60;[Discount](Discount.mdx)&#62;",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "discountRuleRepository_",
    "type": "Repository&#60;[DiscountRule](DiscountRule.mdx)&#62;",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "eventBus_",
    "type": "[EventBusService](EventBusService.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "featureFlagRouter_",
    "type": "[FlagRouter](FlagRouter.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "giftCardRepository_",
    "type": "Repository&#60;[GiftCard](GiftCard.mdx)&#62; & ``{ listGiftCardsAndCount: Method listGiftCardsAndCount  }``",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "manager_",
    "type": "EntityManager",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "newTotalsService_",
    "type": "[NewTotalsService](NewTotalsService.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "productService_",
    "type": "[ProductService](ProductService.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "regionService_",
    "type": "[RegionService](RegionService.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "totalsService_",
    "type": "[TotalsService](TotalsService.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "transactionManager_",
    "type": "`undefined` \\| EntityManager",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

___

## Accessors

### activeManager\_

`Protected get**activeManager_**(): EntityManager`

#### Returns

EntityManager

<ParameterTypes parameters={[
  {
    "name": "EntityManager",
    "type": "EntityManager",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

## Methods

### addRegion

`**addRegion**(discountId, regionId): Promise&#60;[Discount](Discount.mdx)&#62;`

Adds a region to the discount regions array.

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "discountId",
    "type": "`string`",
    "description": "id of discount",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "regionId",
    "type": "`string`",
    "description": "id of region to add",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;[Discount](Discount.mdx)&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[Discount](Discount.mdx)&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "the result of the update operation",
    "expandable": false,
    "children": []
  }
]} />

___

### atomicPhase\_

`Protected **atomicPhase_**<TypeParameter TResult, TypeParameter TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise&#60;TResult&#62;`

Wraps some work within a transactional block. If the service already has
a transaction manager attached this will be reused, otherwise a new
transaction manager is created.

#### Type Parameters

<ParameterTypes parameters={[
  {
    "name": "TResult",
    "type": "`object`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "TError",
    "type": "`object`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "work",
    "type": "(`transactionManager`: EntityManager) => Promise&#60;TResult&#62;",
    "description": "the transactional work to be done",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "isolationOrErrorHandler",
    "type": "`IsolationLevel` \\| (`error`: `TError`) => Promise&#60;void \\| TResult&#62;",
    "description": "the isolation level to be used for the work.",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "maybeErrorHandlerOrDontFail",
    "type": "(`error`: `TError`) => Promise&#60;void \\| TResult&#62;",
    "description": "Potential error handler",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;TResult&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;TResult&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "the result of the transactional work",
    "expandable": false,
    "children": []
  }
]} />

___

### calculateDiscountForLineItem

`**calculateDiscountForLineItem**(discountId, lineItem, calculationContextData): Promise&#60;number&#62;`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "discountId",
    "type": "`string`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "lineItem",
    "type": "[LineItem](LineItem.mdx)",
    "description": "Line Items are created when a product is added to a Cart. When Line Items are purchased they will get copied to the resulting order, swap, or claim, and can eventually be referenced in Fulfillments and Returns. Line items may also be used for order edits.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "calculationContextData",
    "type": "[CalculationContextData](../types/CalculationContextData.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;number&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;number&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### canApplyForCustomer

`**canApplyForCustomer**(discountRuleId, customerId): Promise&#60;boolean&#62;`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "discountRuleId",
    "type": "`string`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "customerId",
    "type": "`undefined` \\| `string`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;boolean&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;boolean&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### create

`**create**(discount): Promise&#60;[Discount](Discount.mdx)&#62;`

Creates a discount with provided data given that the data is validated.
Normalizes discount code to uppercase.

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "discount",
    "type": "[CreateDiscountInput](../types/CreateDiscountInput.mdx)",
    "description": "the discount data to create",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;[Discount](Discount.mdx)&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[Discount](Discount.mdx)&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "the result of the create operation",
    "expandable": false,
    "children": []
  }
]} />

___

### createDynamicCode

`**createDynamicCode**(discountId, data): Promise&#60;[Discount](Discount.mdx)&#62;`

Creates a dynamic code for a discount id.

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "discountId",
    "type": "`string`",
    "description": "the id of the discount to create a code for",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "data",
    "type": "[CreateDynamicDiscountInput](../types/CreateDynamicDiscountInput.mdx)",
    "description": "the object containing a code to identify the discount by",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;[Discount](Discount.mdx)&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[Discount](Discount.mdx)&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "the newly created dynamic code",
    "expandable": false,
    "children": []
  }
]} />

___

### delete

`**delete**(discountId): Promise&#60;void&#62;`

Deletes a discount idempotently

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "discountId",
    "type": "`string`",
    "description": "id of discount to delete",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;void&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;void&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "the result of the delete operation",
    "expandable": false,
    "children": []
  }
]} />

___

### deleteDynamicCode

`**deleteDynamicCode**(discountId, code): Promise&#60;void&#62;`

Deletes a dynamic code for a discount id.

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "discountId",
    "type": "`string`",
    "description": "the id of the discount to create a code for",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "code",
    "type": "`string`",
    "description": "the code to identify the discount by",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;void&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;void&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "the newly created dynamic code",
    "expandable": false,
    "children": []
  }
]} />

___

### hasCustomersGroupCondition

`**hasCustomersGroupCondition**(discount): boolean`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "discount",
    "type": "[Discount](Discount.mdx)",
    "description": "A discount can be applied to a cart for promotional purposes.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

`boolean`

<ParameterTypes parameters={[
  {
    "name": "boolean",
    "type": "`boolean`",
    "optional": true,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### hasExpired

`**hasExpired**(discount): boolean`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "discount",
    "type": "[Discount](Discount.mdx)",
    "description": "A discount can be applied to a cart for promotional purposes.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

`boolean`

<ParameterTypes parameters={[
  {
    "name": "boolean",
    "type": "`boolean`",
    "optional": true,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### hasNotStarted

`**hasNotStarted**(discount): boolean`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "discount",
    "type": "[Discount](Discount.mdx)",
    "description": "A discount can be applied to a cart for promotional purposes.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

`boolean`

<ParameterTypes parameters={[
  {
    "name": "boolean",
    "type": "`boolean`",
    "optional": true,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### hasReachedLimit

`**hasReachedLimit**(discount): boolean`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "discount",
    "type": "[Discount](Discount.mdx)",
    "description": "A discount can be applied to a cart for promotional purposes.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

`boolean`

<ParameterTypes parameters={[
  {
    "name": "boolean",
    "type": "`boolean`",
    "optional": true,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### isDisabled

`**isDisabled**(discount): boolean`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "discount",
    "type": "[Discount](Discount.mdx)",
    "description": "A discount can be applied to a cart for promotional purposes.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

`boolean`

<ParameterTypes parameters={[
  {
    "name": "boolean",
    "type": "`boolean`",
    "optional": true,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### isValidForRegion

`**isValidForRegion**(discount, region_id): Promise&#60;boolean&#62;`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "discount",
    "type": "[Discount](Discount.mdx)",
    "description": "A discount can be applied to a cart for promotional purposes.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "region_id",
    "type": "`string`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;boolean&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;boolean&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### list

`**list**(selector?, config?): Promise&#60;[Discount](Discount.mdx)[]&#62;`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "selector",
    "type": "[FilterableDiscountProps](FilterableDiscountProps.mdx)",
    "description": "the query object for find",
    "optional": false,
    "defaultValue": "{}",
    "expandable": false,
    "children": []
  },
  {
    "name": "config",
    "type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[Discount](Discount.mdx)&#62;",
    "description": "the config object containing query settings",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;[Discount](Discount.mdx)[]&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[Discount](Discount.mdx)[]&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "the result of the find operation",
    "expandable": false,
    "children": []
  }
]} />

___

### listAndCount

`**listAndCount**(selector?, config?): Promise&#60;[[Discount](Discount.mdx)[], number]&#62;`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "selector",
    "type": "[FilterableDiscountProps](FilterableDiscountProps.mdx)",
    "description": "the query object for find",
    "optional": false,
    "defaultValue": "{}",
    "expandable": false,
    "children": []
  },
  {
    "name": "config",
    "type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[Discount](Discount.mdx)&#62;",
    "description": "the config object containing query settings",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;[[Discount](Discount.mdx)[], number]&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[[Discount](Discount.mdx)[], number]&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "the result of the find operation",
    "expandable": false,
    "children": []
  }
]} />

___

### listByCodes

`**listByCodes**(discountCodes, config?): Promise&#60;[Discount](Discount.mdx)[]&#62;`

List all the discounts corresponding to the given codes

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "discountCodes",
    "type": "`string`[]",
    "description": "discount codes of discounts to retrieve",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "config",
    "type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[Discount](Discount.mdx)&#62;",
    "description": "the config object containing query settings",
    "optional": false,
    "defaultValue": "{}",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;[Discount](Discount.mdx)[]&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[Discount](Discount.mdx)[]&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "the discounts",
    "expandable": false,
    "children": []
  }
]} />

___

### removeRegion

`**removeRegion**(discountId, regionId): Promise&#60;[Discount](Discount.mdx)&#62;`

Removes a region from the discount regions array.

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "discountId",
    "type": "`string`",
    "description": "id of discount",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "regionId",
    "type": "`string`",
    "description": "id of region to remove",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;[Discount](Discount.mdx)&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[Discount](Discount.mdx)&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "the result of the update operation",
    "expandable": false,
    "children": []
  }
]} />

___

### retrieve

`**retrieve**(discountId, config?): Promise&#60;[Discount](Discount.mdx)&#62;`

Gets a discount by id.

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "discountId",
    "type": "`string`",
    "description": "id of discount to retrieve",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "config",
    "type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[Discount](Discount.mdx)&#62;",
    "description": "the config object containing query settings",
    "optional": false,
    "defaultValue": "{}",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;[Discount](Discount.mdx)&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[Discount](Discount.mdx)&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "the discount",
    "expandable": false,
    "children": []
  }
]} />

___

### retrieveByCode

`**retrieveByCode**(discountCode, config?): Promise&#60;[Discount](Discount.mdx)&#62;`

Gets the discount by discount code.

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "discountCode",
    "type": "`string`",
    "description": "discount code of discount to retrieve",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "config",
    "type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[Discount](Discount.mdx)&#62;",
    "description": "the config object containing query settings",
    "optional": false,
    "defaultValue": "{}",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;[Discount](Discount.mdx)&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[Discount](Discount.mdx)&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "the discount",
    "expandable": false,
    "children": []
  }
]} />

___

### shouldRetryTransaction\_

`Protected **shouldRetryTransaction_**(err): boolean`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "err",
    "type": "`Record<string, unknown>` \\| ``{ code: string  }``",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

`boolean`

<ParameterTypes parameters={[
  {
    "name": "boolean",
    "type": "`boolean`",
    "optional": true,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### update

`**update**(discountId, update): Promise&#60;[Discount](Discount.mdx)&#62;`

Updates a discount.

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "discountId",
    "type": "`string`",
    "description": "discount id of discount to update",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "update",
    "type": "[UpdateDiscountInput](../types/UpdateDiscountInput.mdx)",
    "description": "the data to update the discount with",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;[Discount](Discount.mdx)&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[Discount](Discount.mdx)&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "the result of the update operation",
    "expandable": false,
    "children": []
  }
]} />

___

### validateDiscountForCartOrThrow

`**validateDiscountForCartOrThrow**(cart, discount): Promise&#60;void&#62;`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "cart",
    "type": "[Cart](Cart.mdx)",
    "description": "A cart represents a virtual shopping bag. It can be used to complete an order, a swap, or a claim.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "discount",
    "type": "[Discount](Discount.mdx) \\| [Discount](Discount.mdx)[]",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;void&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;void&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### validateDiscountForProduct

`**validateDiscountForProduct**(discountRuleId, productId?): Promise&#60;boolean&#62;`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "discountRuleId",
    "type": "`string`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "productId",
    "type": "`string`",
    "description": "",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;boolean&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;boolean&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### validateDiscountRule\_

`**validateDiscountRule_**<TypeParameter T>(discountRule): T`

Creates a discount rule with provided data given that the data is validated.

#### Type Parameters

<ParameterTypes parameters={[
  {
    "name": "T",
    "type": "`object`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "discountRule",
    "type": "`T`",
    "description": "the discount rule to create",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

`T`

<ParameterTypes parameters={[
  {
    "name": "T",
    "type": "`T`",
    "optional": false,
    "defaultValue": "",
    "description": "the result of the create operation",
    "expandable": false,
    "children": []
  }
]} />

___

### withTransaction

`**withTransaction**(transactionManager?): [DiscountService](DiscountService.mdx)`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "transactionManager",
    "type": "EntityManager",
    "description": "",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

[DiscountService](DiscountService.mdx)

<ParameterTypes parameters={[
  {
    "name": "DiscountService",
    "type": "[DiscountService](DiscountService.mdx)",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />
