Skip to main content

Class: CartsResource

Hierarchy

  • default

    CartsResource

Properties

lineItems

lineItems: LineItemsResource

Defined in

medusa-js/src/resources/carts.ts:15

Methods

addShippingMethod

addShippingMethod(cart_id, payload, customHeaders?): ResponsePromise<StoreCartsRes>

Adds a shipping method to cart

Parameters

NameTypeDescription
cart_idstringId of cart
payloadStorePostCartsCartShippingMethodReqContaing id of shipping option and optional data
customHeadersRecord<string, any>

Returns

ResponsePromise<StoreCartsRes>

Defined in

medusa-js/src/resources/carts.ts:24


complete

complete(cart_id, customHeaders?): ResponsePromise<StoreCompleteCartRes>

Completes a cart. Payment authorization is attempted and if more work is required, we simply return the cart for further updates. If payment is authorized and order is not yet created, we make sure to do so. The completion of a cart can be performed idempotently with a provided header Idempotency-Key. If not provuided, we will generate one for the request.

Parameters

NameTypeDescription
cart_idstringis required
customHeadersRecord<string, any>

Returns

ResponsePromise<StoreCompleteCartRes>

Defined in

medusa-js/src/resources/carts.ts:43


create

create(payload?, customHeaders?): ResponsePromise<StoreCartsRes>

Creates a cart

Parameters

NameTypeDescription
payload?StorePostCartReqis optional and can contain a region_id and items. The cart will contain the payload, if provided. Otherwise it will be empty
customHeadersRecord<string, any>

Returns

ResponsePromise<StoreCartsRes>

Defined in

medusa-js/src/resources/carts.ts:58


createPaymentSessions

createPaymentSessions(cart_id, customHeaders?): ResponsePromise<StoreCartsRes>

Creates payment sessions. Initializes the payment sessions that can be used to pay for the items of the cart. This is usually called when a customer proceeds to checkout.

Parameters

NameTypeDescription
cart_idstringis required
customHeadersRecord<string, any>

Returns

ResponsePromise<StoreCartsRes>

Defined in

medusa-js/src/resources/carts.ts:74


deleteDiscount

deleteDiscount(cart_id, code, customHeaders?): ResponsePromise<StoreCartsRes>

Removes a discount from cart.

Parameters

NameTypeDescription
cart_idstringis required
codestringdiscount code to remove
customHeadersRecord<string, any>

Returns

ResponsePromise<StoreCartsRes>

Defined in

medusa-js/src/resources/carts.ts:89


deletePaymentSession

deletePaymentSession(cart_id, provider_id, customHeaders?): ResponsePromise<StoreCartsRes>

Removes a payment session from a cart. Can be useful in case a payment has failed

Parameters

NameTypeDescription
cart_idstringis required
provider_idstringthe provider id of the session e.g. "stripe"
customHeadersRecord<string, any>

Returns

ResponsePromise<StoreCartsRes>

Defined in

medusa-js/src/resources/carts.ts:106


refreshPaymentSession

refreshPaymentSession(cart_id, provider_id, customHeaders?): ResponsePromise<StoreCartsRes>

Refreshes a payment session.

Parameters

NameTypeDescription
cart_idstringis required
provider_idstringthe provider id of the session e.g. "stripe"
customHeadersRecord<string, any>

Returns

ResponsePromise<StoreCartsRes>

Defined in

medusa-js/src/resources/carts.ts:122


retrieve

retrieve(cart_id, customHeaders?): ResponsePromise<StoreCartsRes>

Retrieves a cart

Parameters

NameTypeDescription
cart_idstringis required
customHeadersRecord<string, any>

Returns

ResponsePromise<StoreCartsRes>

Defined in

medusa-js/src/resources/carts.ts:137


setPaymentSession

setPaymentSession(cart_id, payload, customHeaders?): ResponsePromise<StoreCartsRes>

Refreshes a payment session.

Parameters

NameTypeDescription
cart_idstringis required
payloadStorePostCartsCartPaymentSessionReqthe provider id of the session e.g. "stripe"
customHeadersRecord<string, any>

Returns

ResponsePromise<StoreCartsRes>

Defined in

medusa-js/src/resources/carts.ts:152


update

update(cart_id, payload, customHeaders?): ResponsePromise<StoreCartsRes>

Updates a cart

Parameters

NameTypeDescription
cart_idstringis required
payloadStorePostCartsCartReqis required and can contain region_id, email, billing and shipping address
customHeadersRecord<string, any>

Returns

ResponsePromise<StoreCartsRes>

Defined in

medusa-js/src/resources/carts.ts:168


updatePaymentSession

updatePaymentSession(cart_id, provider_id, payload, customHeaders?): ResponsePromise<StoreCartsRes>

Updates the payment method

Parameters

NameTypeDescription
cart_idstringis required
provider_idstringis required
payloadStorePostCartsCartPaymentSessionUpdateReqis required
customHeadersRecord<string, any>

Returns

ResponsePromise<StoreCartsRes>

Defined in

medusa-js/src/resources/carts.ts:185

Was this page helpful?