Files
medusa-store/www/apps/docs/content/references/services/classes/CartService.mdx
Shahed Nasser c51dce164d docs: general fixes to references (#5653)
* fixed typedoc plugin's escape strategy

* move props comments to the associated property

* regenerate references
2023-11-17 19:36:58 +02:00

2567 lines
53 KiB
Plaintext

---
displayed_sidebar: servicesSidebar
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# CartService
## Constructors
### constructor
`**new CartService**(«destructured»)`
#### Parameters
<ParameterTypes parameters={[
{
"name": "__namedParameters",
"type": "[InjectedDependencies](../types/InjectedDependencies-3.mdx)",
"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": "addressRepository_",
"type": "Repository&#60;[Address](Address.mdx)&#62;",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "cartRepository_",
"type": "Repository&#60;[Cart](Cart.mdx)&#62; & ``{ findOneWithRelations: Method findOneWithRelations ; findWithRelations: Method findWithRelations }``",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customShippingOptionService_",
"type": "[CustomShippingOptionService](CustomShippingOptionService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customerService_",
"type": "[CustomerService](CustomerService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "discountService_",
"type": "[DiscountService](DiscountService.mdx)",
"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": "giftCardService_",
"type": "[GiftCardService](GiftCardService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lineItemAdjustmentService_",
"type": "[LineItemAdjustmentService](LineItemAdjustmentService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lineItemRepository_",
"type": "Repository&#60;[LineItem](LineItem.mdx)&#62; & ``{ findByReturn: Method findByReturn }``",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lineItemService_",
"type": "[LineItemService](LineItemService.mdx)",
"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": "paymentProviderService_",
"type": "[PaymentProviderService](PaymentProviderService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "paymentSessionRepository_",
"type": "Repository&#60;[PaymentSession](PaymentSession.mdx)&#62;",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "priceSelectionStrategy_",
"type": "[IPriceSelectionStrategy](../interfaces/IPriceSelectionStrategy.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "pricingService_",
"type": "[PricingService](PricingService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "productService_",
"type": "[ProductService](ProductService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "productVariantInventoryService_",
"type": "[ProductVariantInventoryService](ProductVariantInventoryService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "productVariantService_",
"type": "[ProductVariantService](ProductVariantService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "regionService_",
"type": "[RegionService](RegionService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "salesChannelService_",
"type": "[SalesChannelService](SalesChannelService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shippingMethodRepository_",
"type": "Repository&#60;[ShippingMethod](ShippingMethod.mdx)&#62;",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shippingOptionService_",
"type": "[ShippingOptionService](ShippingOptionService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shippingProfileService_",
"type": "[ShippingProfileService](ShippingProfileService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "storeService_",
"type": "[StoreService](StoreService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "taxProviderService_",
"type": "[TaxProviderService](TaxProviderService.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": []
},
{
"name": "Events",
"type": "`object`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "Events.CREATED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"cart.created\"",
"expandable": false,
"children": []
},
{
"name": "Events.CUSTOMER_UPDATED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"cart.customer_updated\"",
"expandable": false,
"children": []
},
{
"name": "Events.UPDATED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"cart.updated\"",
"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
### addLineItem
`**addLineItem**(cartId, lineItem, config?): Promise&#60;void&#62;`
Adds a line item to the cart.
#### Parameters
<ParameterTypes parameters={[
{
"name": "cartId",
"type": "`string`",
"description": "the id of the cart that we will add to",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lineItem",
"type": "[LineItem](LineItem.mdx)",
"description": "the line item to add.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "config",
"type": "`object`",
"description": "validateSalesChannels - should check if product belongs to the same sales channel as cart (if cart has associated sales channel)",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "config.validateSalesChannels",
"type": "`boolean`",
"description": "",
"optional": false,
"defaultValue": "true",
"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 update operation",
"expandable": false,
"children": []
}
]} />
#### Deprecated
Use [addOrUpdateLineItems](CartService.mdx#addorupdatelineitems) instead.
___
### addOrUpdateLineItems
`**addOrUpdateLineItems**(cartId, lineItems, config?): Promise&#60;void&#62;`
Adds or update one or multiple line items to the cart. It also update all existing items in the cart
to have has\_shipping to false. Finally, the adjustments will be updated.
#### Parameters
<ParameterTypes parameters={[
{
"name": "cartId",
"type": "`string`",
"description": "the id of the cart that we will add to",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lineItems",
"type": "[LineItem](LineItem.mdx) \\| [LineItem](LineItem.mdx)[]",
"description": "the line items to add.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "config",
"type": "`object`",
"description": "validateSalesChannels - should check if product belongs to the same sales channel as cart (if cart has associated sales channel)",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "config.validateSalesChannels",
"type": "`boolean`",
"description": "",
"optional": false,
"defaultValue": "true",
"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 update operation",
"expandable": false,
"children": []
}
]} />
___
### addShippingMethod
`**addShippingMethod**(cartOrId, optionId, data?): Promise&#60;[Cart](Cart.mdx)&#62;`
Adds the shipping method to the list of shipping methods associated with
the cart. Shipping Methods are the ways that an order is shipped, whereas a
Shipping Option is a possible way to ship an order. Shipping Methods may
also have additional details in the data field such as an id for a package
shop.
#### Parameters
<ParameterTypes parameters={[
{
"name": "cartOrId",
"type": "`string` \\| [Cart](Cart.mdx)",
"description": "the id of the cart to add shipping method to",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "optionId",
"type": "`string`",
"description": "id of shipping option to add as valid method",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "data",
"type": "`Record<string, unknown>`",
"description": "the fulmillment data for the method",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Cart](Cart.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Cart](Cart.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "the result of the update operation",
"expandable": false,
"children": []
}
]} />
___
### adjustFreeShipping\_
`Protected **adjustFreeShipping_**(cart, shouldAdd): Promise&#60;void&#62;`
Ensures shipping total on cart is correct in regards to a potential free
shipping discount
If a free shipping is present, we set shipping methods price to 0
if a free shipping was present, we set shipping methods to original amount
#### Parameters
<ParameterTypes parameters={[
{
"name": "cart",
"type": "[Cart](Cart.mdx)",
"description": "the cart to adjust free shipping for",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shouldAdd",
"type": "`boolean`",
"description": "flag to indicate, if we should add or remove",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;void&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;void&#62;",
"optional": false,
"defaultValue": "",
"description": "void",
"expandable": false,
"children": []
}
]} />
___
### applyDiscount
`**applyDiscount**(cart, discountCode): Promise&#60;void&#62;`
Updates the cart's discounts.
If discount besides free shipping is already applied, this
will be overwritten
Throws if discount regions does not include the cart region
#### Parameters
<ParameterTypes parameters={[
{
"name": "cart",
"type": "[Cart](Cart.mdx)",
"description": "the cart to update",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "discountCode",
"type": "`string`",
"description": "the discount code",
"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": []
}
]} />
___
### applyDiscounts
`**applyDiscounts**(cart, discountCodes): Promise&#60;void&#62;`
Updates the cart's discounts.
If discount besides free shipping is already applied, this
will be overwritten
Throws if discount regions does not include the cart region
#### Parameters
<ParameterTypes parameters={[
{
"name": "cart",
"type": "[Cart](Cart.mdx)",
"description": "the cart to update",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "discountCodes",
"type": "`string`[]",
"description": "the discount code(s) to apply",
"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": []
}
]} />
___
### applyGiftCard\_
`Protected **applyGiftCard_**(cart, code): 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": "code",
"type": "`string`",
"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": []
}
]} />
___
### 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.
<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": []
}
]} />
___
### authorizePayment
`**authorizePayment**(cartId, context?): Promise&#60;[Cart](Cart.mdx)&#62;`
Authorizes a payment for a cart.
Will authorize with chosen payment provider. This will return
a payment object, that we will use to update our cart payment with.
Additionally, if the payment does not require more or fails, we will
set the payment on the cart.
#### Parameters
<ParameterTypes parameters={[
{
"name": "cartId",
"type": "`string`",
"description": "the id of the cart to authorize payment for",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "context",
"type": "`Record<string, unknown>` & ``{ cart_id: string }``",
"description": "object containing whatever is relevant for authorizing the payment with the payment provider. As an example, this could be IP address or similar for fraud handling.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Cart](Cart.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Cart](Cart.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "the resulting cart",
"expandable": false,
"children": []
}
]} />
___
### create
`**create**(data): Promise&#60;[Cart](Cart.mdx)&#62;`
Creates a cart.
#### Parameters
<ParameterTypes parameters={[
{
"name": "data",
"type": "[CartCreateProps](../types/CartCreateProps.mdx)",
"description": "the data to create the cart with",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Cart](Cart.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Cart](Cart.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "the result of the create operation",
"expandable": false,
"children": []
}
]} />
___
### createOrFetchGuestCustomerFromEmail\_
`Protected **createOrFetchGuestCustomerFromEmail_**(email): Promise&#60;[Customer](Customer.mdx)&#62;`
Creates or fetches a user based on an email.
#### Parameters
<ParameterTypes parameters={[
{
"name": "email",
"type": "`string`",
"description": "the email to use",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Customer](Customer.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Customer](Customer.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "the resultign customer object",
"expandable": false,
"children": []
}
]} />
___
### createTaxLines
`**createTaxLines**(cartOrId): Promise&#60;void&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "cartOrId",
"type": "`string` \\| [Cart](Cart.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": []
}
]} />
___
### decorateTotals
`**decorateTotals**(cart, totalsConfig?): Promise&#60;[WithRequiredProperty](../types/WithRequiredProperty.mdx)&#60;[Cart](Cart.mdx), "total"&#62;&#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": "totalsConfig",
"type": "[TotalsConfig](../types/TotalsConfig.mdx)",
"description": "",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[WithRequiredProperty](../types/WithRequiredProperty.mdx)&#60;[Cart](Cart.mdx), "total"&#62;&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[WithRequiredProperty](../types/WithRequiredProperty.mdx)&#60;[Cart](Cart.mdx), \"total\"&#62;&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### decorateTotals\_
`Protected **decorateTotals_**(cart, totalsToSelect, options?): Promise&#60;[Cart](Cart.mdx)&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "cart",
"type": "[Cart](Cart.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "totalsToSelect",
"type": "[TotalField](../types/TotalField.mdx)[]",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "options",
"type": "[TotalsConfig](../types/TotalsConfig.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Cart](Cart.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Cart](Cart.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
#### Deprecated
Use decorateTotals instead
___
### delete
`**delete**(cartId): Promise&#60;[Cart](Cart.mdx)&#62;`
Deletes a cart from the database. Completed carts cannot be deleted.
#### Parameters
<ParameterTypes parameters={[
{
"name": "cartId",
"type": "`string`",
"description": "the id of the cart to delete",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Cart](Cart.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Cart](Cart.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "the deleted cart or undefined if the cart was not found.",
"expandable": false,
"children": []
}
]} />
___
### deletePaymentSession
`**deletePaymentSession**(cartId, providerId): Promise&#60;void&#62;`
Removes a payment session from the cart.
#### Parameters
<ParameterTypes parameters={[
{
"name": "cartId",
"type": "`string`",
"description": "the id of the cart to remove from",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "providerId",
"type": "`string`",
"description": "the id of the provider whose payment session should be removed.",
"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 resulting cart.",
"expandable": false,
"children": []
}
]} />
___
### deleteTaxLines
`**deleteTaxLines**(id): Promise&#60;void&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "id",
"type": "`string`",
"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": []
}
]} />
___
### findCustomShippingOption
`**findCustomShippingOption**(cartCustomShippingOptions, optionId): undefined \| [CustomShippingOption](CustomShippingOption.mdx)`
Finds the cart's custom shipping options based on the passed option id.
throws if custom options is not empty and no shipping option corresponds to optionId
#### Parameters
<ParameterTypes parameters={[
{
"name": "cartCustomShippingOptions",
"type": "[CustomShippingOption](CustomShippingOption.mdx)[]",
"description": "the cart's custom shipping options",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "optionId",
"type": "`string`",
"description": "id of the normal or custom shipping option to find in the cartCustomShippingOptions",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
`undefined` \| [CustomShippingOption](CustomShippingOption.mdx)
<ParameterTypes parameters={[
{
"name": "undefined \\| CustomShippingOption",
"type": "`undefined` \\| [CustomShippingOption](CustomShippingOption.mdx)",
"optional": true,
"defaultValue": "",
"description": "custom shipping option",
"expandable": false,
"children": []
}
]} />
___
### getTotalsRelations
`Private **getTotalsRelations**(config): string[]`
#### Parameters
<ParameterTypes parameters={[
{
"name": "config",
"type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[Cart](Cart.mdx)&#62;",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
`string`[]
<ParameterTypes parameters={[
{
"name": "string[]",
"type": "`string`[]",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### getValidatedSalesChannel
`Protected **getValidatedSalesChannel**(salesChannelId?): Promise&#60;[SalesChannel](SalesChannel.mdx)&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "salesChannelId",
"type": "`string`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[SalesChannel](SalesChannel.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[SalesChannel](SalesChannel.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### list
`**list**(selector, config?): Promise&#60;[Cart](Cart.mdx)[]&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "selector",
"type": "[FilterableCartProps](FilterableCartProps.mdx)",
"description": "the query object for find",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "config",
"type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[Cart](Cart.mdx)&#62;",
"description": "config object",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Cart](Cart.mdx)[]&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Cart](Cart.mdx)[]&#62;",
"optional": false,
"defaultValue": "",
"description": "the result of the find operation",
"expandable": false,
"children": []
}
]} />
___
### onSalesChannelChange
`Protected **onSalesChannelChange**(cart, newSalesChannelId): Promise&#60;void&#62;`
Remove the cart line item that does not belongs to the newly assigned sales channel
#### Parameters
<ParameterTypes parameters={[
{
"name": "cart",
"type": "[Cart](Cart.mdx)",
"description": "The cart being updated",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "newSalesChannelId",
"type": "`string`",
"description": "The new sales channel being assigned to the cart",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;void&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;void&#62;",
"optional": false,
"defaultValue": "",
"description": "void",
"expandable": false,
"children": []
}
]} />
___
### refreshAdjustments\_
`Protected **refreshAdjustments_**(cart): 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": []
}
]} />
#### Returns
Promise&#60;void&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;void&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### refreshPaymentSession
`**refreshPaymentSession**(cartId, providerId): Promise&#60;void&#62;`
Refreshes a payment session on a cart
#### Parameters
<ParameterTypes parameters={[
{
"name": "cartId",
"type": "`string`",
"description": "the id of the cart to remove from",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "providerId",
"type": "`string`",
"description": "the id of the provider whose payment session should be removed.",
"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 resulting cart.",
"expandable": false,
"children": []
}
]} />
___
### removeDiscount
`**removeDiscount**(cartId, discountCode): Promise&#60;[Cart](Cart.mdx)&#62;`
Removes a discount based on a discount code.
#### Parameters
<ParameterTypes parameters={[
{
"name": "cartId",
"type": "`string`",
"description": "the id of the cart to remove from",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "discountCode",
"type": "`string`",
"description": "the discount code to remove",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Cart](Cart.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Cart](Cart.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "the resulting cart",
"expandable": false,
"children": []
}
]} />
___
### removeLineItem
`**removeLineItem**(cartId, lineItemId): Promise&#60;[Cart](Cart.mdx)&#62;`
Removes a line item from the cart.
#### Parameters
<ParameterTypes parameters={[
{
"name": "cartId",
"type": "`string`",
"description": "the id of the cart that we will remove from",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lineItemId",
"type": "`string`",
"description": "the line item to remove.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Cart](Cart.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Cart](Cart.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "the result of the update operation",
"expandable": false,
"children": []
}
]} />
___
### retrieve
`**retrieve**(cartId, options?, totalsConfig?): Promise&#60;[Cart](Cart.mdx)&#62;`
Gets a cart by id.
#### Parameters
<ParameterTypes parameters={[
{
"name": "cartId",
"type": "`string`",
"description": "the id of the cart to get.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "options",
"type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[Cart](Cart.mdx)&#62;",
"description": "the options to get a cart",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
},
{
"name": "totalsConfig",
"type": "[TotalsConfig](../types/TotalsConfig.mdx)",
"description": "",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Cart](Cart.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Cart](Cart.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "the cart document.",
"expandable": false,
"children": []
}
]} />
___
### retrieveLegacy
`Protected **retrieveLegacy**(cartId, options?, totalsConfig?): Promise&#60;[Cart](Cart.mdx)&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "cartId",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "options",
"type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[Cart](Cart.mdx)&#62;",
"description": "",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
},
{
"name": "totalsConfig",
"type": "[TotalsConfig](../types/TotalsConfig.mdx)",
"description": "",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Cart](Cart.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Cart](Cart.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
#### Deprecated
___
### retrieveWithTotals
`**retrieveWithTotals**(cartId, options?, totalsConfig?): Promise&#60;[WithRequiredProperty](../types/WithRequiredProperty.mdx)&#60;[Cart](Cart.mdx), "total"&#62;&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "cartId",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "options",
"type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[Cart](Cart.mdx)&#62;",
"description": "",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
},
{
"name": "totalsConfig",
"type": "[TotalsConfig](../types/TotalsConfig.mdx)",
"description": "",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[WithRequiredProperty](../types/WithRequiredProperty.mdx)&#60;[Cart](Cart.mdx), "total"&#62;&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[WithRequiredProperty](../types/WithRequiredProperty.mdx)&#60;[Cart](Cart.mdx), \"total\"&#62;&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### setMetadata
`**setMetadata**(cartId, key, value): Promise&#60;[Cart](Cart.mdx)&#62;`
Dedicated method to set metadata for a cart.
To ensure that plugins does not overwrite each
others metadata fields, setMetadata is provided.
#### Parameters
<ParameterTypes parameters={[
{
"name": "cartId",
"type": "`string`",
"description": "the cart to apply metadata to.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "key",
"type": "`string`",
"description": "key for metadata field",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "value",
"type": "`string` \\| `number`",
"description": "value for metadata field.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Cart](Cart.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Cart](Cart.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "resolves to the updated result.",
"expandable": false,
"children": []
}
]} />
___
### setPaymentSession
`**setPaymentSession**(cartId, providerId): Promise&#60;void&#62;`
Selects a payment session for a cart and creates a payment object in the external provider system
#### Parameters
<ParameterTypes parameters={[
{
"name": "cartId",
"type": "`string`",
"description": "the id of the cart to add payment method to",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "providerId",
"type": "`string`",
"description": "the id of the provider to be set to the cart",
"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": []
}
]} />
___
### setPaymentSessions
`**setPaymentSessions**(cartOrCartId): Promise&#60;void&#62;`
Creates, updates and sets payment sessions associated with the cart. The
first time the method is called payment sessions will be created for each
provider. Additional calls will ensure that payment sessions have correct
amounts, currencies, etc. as well as make sure to filter payment sessions
that are not available for the cart's region.
#### Parameters
<ParameterTypes parameters={[
{
"name": "cartOrCartId",
"type": "`string` \\| [Cart](Cart.mdx)",
"description": "the id of the cart to set payment session for",
"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 update operation.",
"expandable": false,
"children": []
}
]} />
___
### setRegion\_
`Protected **setRegion_**(cart, regionId, countryCode): Promise&#60;void&#62;`
Set's the region of a cart.
#### Parameters
<ParameterTypes parameters={[
{
"name": "cart",
"type": "[Cart](Cart.mdx)",
"description": "the cart to set region on",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "regionId",
"type": "`string`",
"description": "the id of the region to set the region to",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "countryCode",
"type": "`null` \\| `string`",
"description": "the country code to set the country to",
"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 update operation",
"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": []
}
]} />
___
### transformQueryForTotals\_
`Protected **transformQueryForTotals_**(config): [FindConfig](../interfaces/FindConfig.mdx)&#60;[Cart](Cart.mdx)&#62; & &#123; totalsToSelect: [TotalField](../types/TotalField.mdx)[] &#125;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "config",
"type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[Cart](Cart.mdx)&#62;",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
[FindConfig](../interfaces/FindConfig.mdx)&#60;[Cart](Cart.mdx)&#62; & ``{ totalsToSelect: [TotalField](../types/TotalField.mdx)[] }``
<ParameterTypes parameters={[
{
"name": "FindConfig&#60;Cart&#62; & &#123; totalsToSelect: TotalField[] &#125;",
"type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[Cart](Cart.mdx)&#62; & ``{ totalsToSelect: [TotalField](../types/TotalField.mdx)[] }``",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### update
`**update**(cartOrId, data): Promise&#60;[Cart](Cart.mdx)&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "cartOrId",
"type": "`string` \\| [Cart](Cart.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "data",
"type": "[CartUpdateProps](../types/CartUpdateProps.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Cart](Cart.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Cart](Cart.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### updateBillingAddress\_
`Protected **updateBillingAddress_**(cart, addressOrId, addrRepo): Promise&#60;void&#62;`
Updates the cart's billing address.
#### Parameters
<ParameterTypes parameters={[
{
"name": "cart",
"type": "[Cart](Cart.mdx)",
"description": "the cart to update",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "addressOrId",
"type": "`string` \\| [AddressPayload](AddressPayload.mdx) \\| [Partial](../types/Partial.mdx)&#60;[Address](Address.mdx)&#62;",
"description": "the value to set the billing address to",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "addrRepo",
"type": "Repository&#60;[Address](Address.mdx)&#62;",
"description": "the repository to use for address updates",
"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 update operation",
"expandable": false,
"children": []
}
]} />
___
### updateCustomerId\_
`Protected **updateCustomerId_**(cart, customerId): Promise&#60;void&#62;`
Sets the customer id of a cart
#### Parameters
<ParameterTypes parameters={[
{
"name": "cart",
"type": "[Cart](Cart.mdx)",
"description": "the cart to add email to",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customerId",
"type": "`string`",
"description": "the customer to add to cart",
"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 update operation",
"expandable": false,
"children": []
}
]} />
___
### updateLineItem
`**updateLineItem**(cartId, lineItemId, update): Promise&#60;[Cart](Cart.mdx)&#62;`
Updates a cart's existing line item.
#### Parameters
<ParameterTypes parameters={[
{
"name": "cartId",
"type": "`string`",
"description": "the id of the cart to update",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lineItemId",
"type": "`string`",
"description": "the id of the line item to update.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "update",
"type": "[LineItemUpdate](../types/LineItemUpdate.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Cart](Cart.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Cart](Cart.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "the result of the update operation",
"expandable": false,
"children": []
}
]} />
___
### updatePaymentSession
`**updatePaymentSession**(cartId, update): Promise&#60;[Cart](Cart.mdx)&#62;`
Updates the currently selected payment session.
#### Parameters
<ParameterTypes parameters={[
{
"name": "cartId",
"type": "`string`",
"description": "the id of the cart to update the payment session for",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "update",
"type": "`Record<string, unknown>`",
"description": "the data to update the payment session with",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Cart](Cart.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Cart](Cart.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "the resulting cart",
"expandable": false,
"children": []
}
]} />
___
### updateShippingAddress\_
`Protected **updateShippingAddress_**(cart, addressOrId, addrRepo): Promise&#60;void&#62;`
Updates the cart's shipping address.
#### Parameters
<ParameterTypes parameters={[
{
"name": "cart",
"type": "[Cart](Cart.mdx)",
"description": "the cart to update",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "addressOrId",
"type": "`string` \\| [AddressPayload](AddressPayload.mdx) \\| [Partial](../types/Partial.mdx)&#60;[Address](Address.mdx)&#62;",
"description": "the value to set the shipping address to",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "addrRepo",
"type": "Repository&#60;[Address](Address.mdx)&#62;",
"description": "the repository to use for address updates",
"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 update operation",
"expandable": false,
"children": []
}
]} />
___
### updateUnitPrices\_
`Protected **updateUnitPrices_**(cart, regionId?, customer_id?): 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": "regionId",
"type": "`string`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customer_id",
"type": "`string`",
"description": "",
"optional": true,
"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": []
}
]} />
___
### validateLineItem
`Protected **validateLineItem**(sales_channel_id, lineItem): Promise&#60;boolean&#62;`
Check if line item's variant belongs to the cart's sales channel.
#### Parameters
<ParameterTypes parameters={[
{
"name": "sales_channel_id",
"type": "`object`",
"description": "the cart for the line item",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "sales_channel_id.sales_channel_id",
"type": "`null` \\| `string`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lineItem",
"type": "[LineItemValidateData](../types/LineItemValidateData.mdx)",
"description": "the line item being added",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;boolean&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;boolean&#62;",
"optional": false,
"defaultValue": "",
"description": "a boolean indicating validation result",
"expandable": false,
"children": []
}
]} />
___
### validateLineItemShipping\_
`Protected **validateLineItemShipping_**(shippingMethods, lineItemShippingProfiledId): boolean`
Checks if a given line item has a shipping method that can fulfill it.
Returns true if all products in the cart can be fulfilled with the current
shipping methods.
#### Parameters
<ParameterTypes parameters={[
{
"name": "shippingMethods",
"type": "[ShippingMethod](ShippingMethod.mdx)[]",
"description": "the set of shipping methods to check from",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lineItemShippingProfiledId",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
`boolean`
<ParameterTypes parameters={[
{
"name": "boolean",
"type": "`boolean`",
"optional": true,
"defaultValue": "",
"description": "boolean representing whether shipping method is validated",
"expandable": false,
"children": []
}
]} />
___
### withTransaction
`**withTransaction**(transactionManager?): [CartService](CartService.mdx)`
#### Parameters
<ParameterTypes parameters={[
{
"name": "transactionManager",
"type": "EntityManager",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
[CartService](CartService.mdx)
<ParameterTypes parameters={[
{
"name": "CartService",
"type": "[CartService](CartService.mdx)",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />