Skip to main content

Class: CartsResource

Hierarchy

  • Copy to Clipboard

    Copy to Clipboard

Properties

lineItems

lineItems: Copy to Clipboard

Defined in

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

Methods

addShippingMethod

addShippingMethod(Copy to Clipboard, Copy to Clipboard, Copy to Clipboard): Copy to Clipboard<Copy to Clipboard>

Adds a shipping method to cart

Parameters

NameTypeDescription
Copy to ClipboardCopy to ClipboardId of cart
Copy to ClipboardCopy to ClipboardContaing id of shipping option and optional data
Copy to ClipboardCopy to Clipboard<Copy to Clipboard, Copy to Clipboard>

Returns

Copy to Clipboard<Copy to Clipboard>

Defined in

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


complete

complete(Copy to Clipboard, Copy to Clipboard): Copy to Clipboard<Copy to Clipboard>

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
Copy to ClipboardCopy to Clipboardis required
Copy to ClipboardCopy to Clipboard<Copy to Clipboard, Copy to Clipboard>

Returns

Copy to Clipboard<Copy to Clipboard>

Defined in

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


create

create(Copy to Clipboard, Copy to Clipboard): Copy to Clipboard<Copy to Clipboard>

Creates a cart

Parameters

NameTypeDescription
Copy to ClipboardCopy to Clipboardis optional and can contain a region_id and items. The cart will contain the payload, if provided. Otherwise it will be empty
Copy to ClipboardCopy to Clipboard<Copy to Clipboard, Copy to Clipboard>

Returns

Copy to Clipboard<Copy to Clipboard>

Defined in

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


createPaymentSessions

createPaymentSessions(Copy to Clipboard, Copy to Clipboard): Copy to Clipboard<Copy to Clipboard>

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
Copy to ClipboardCopy to Clipboardis required
Copy to ClipboardCopy to Clipboard<Copy to Clipboard, Copy to Clipboard>

Returns

Copy to Clipboard<Copy to Clipboard>

Defined in

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


deleteDiscount

deleteDiscount(Copy to Clipboard, Copy to Clipboard, Copy to Clipboard): Copy to Clipboard<Copy to Clipboard>

Removes a discount from cart.

Parameters

NameTypeDescription
Copy to ClipboardCopy to Clipboardis required
Copy to ClipboardCopy to Clipboarddiscount code to remove
Copy to ClipboardCopy to Clipboard<Copy to Clipboard, Copy to Clipboard>

Returns

Copy to Clipboard<Copy to Clipboard>

Defined in

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


deletePaymentSession

deletePaymentSession(Copy to Clipboard, Copy to Clipboard, Copy to Clipboard): Copy to Clipboard<Copy to Clipboard>

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

Parameters

NameTypeDescription
Copy to ClipboardCopy to Clipboardis required
Copy to ClipboardCopy to Clipboardthe provider id of the session e.g. "stripe"
Copy to ClipboardCopy to Clipboard<Copy to Clipboard, Copy to Clipboard>

Returns

Copy to Clipboard<Copy to Clipboard>

Defined in

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


refreshPaymentSession

refreshPaymentSession(Copy to Clipboard, Copy to Clipboard, Copy to Clipboard): Copy to Clipboard<Copy to Clipboard>

Refreshes a payment session.

Parameters

NameTypeDescription
Copy to ClipboardCopy to Clipboardis required
Copy to ClipboardCopy to Clipboardthe provider id of the session e.g. "stripe"
Copy to ClipboardCopy to Clipboard<Copy to Clipboard, Copy to Clipboard>

Returns

Copy to Clipboard<Copy to Clipboard>

Defined in

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


retrieve

retrieve(Copy to Clipboard, Copy to Clipboard): Copy to Clipboard<Copy to Clipboard>

Retrieves a cart

Parameters

NameTypeDescription
Copy to ClipboardCopy to Clipboardis required
Copy to ClipboardCopy to Clipboard<Copy to Clipboard, Copy to Clipboard>

Returns

Copy to Clipboard<Copy to Clipboard>

Defined in

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


setPaymentSession

setPaymentSession(Copy to Clipboard, Copy to Clipboard, Copy to Clipboard): Copy to Clipboard<Copy to Clipboard>

Refreshes a payment session.

Parameters

NameTypeDescription
Copy to ClipboardCopy to Clipboardis required
Copy to ClipboardCopy to Clipboardthe provider id of the session e.g. "stripe"
Copy to ClipboardCopy to Clipboard<Copy to Clipboard, Copy to Clipboard>

Returns

Copy to Clipboard<Copy to Clipboard>

Defined in

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


update

update(Copy to Clipboard, Copy to Clipboard, Copy to Clipboard): Copy to Clipboard<Copy to Clipboard>

Updates a cart

Parameters

NameTypeDescription
Copy to ClipboardCopy to Clipboardis required
Copy to ClipboardCopy to Clipboardis required and can contain region_id, email, billing and shipping address
Copy to ClipboardCopy to Clipboard<Copy to Clipboard, Copy to Clipboard>

Returns

Copy to Clipboard<Copy to Clipboard>

Defined in

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


updatePaymentSession

updatePaymentSession(Copy to Clipboard, Copy to Clipboard, Copy to Clipboard, Copy to Clipboard): Copy to Clipboard<Copy to Clipboard>

Updates the payment method

Parameters

NameTypeDescription
Copy to ClipboardCopy to Clipboardis required
Copy to ClipboardCopy to Clipboardis required
Copy to ClipboardCopy to Clipboardis required
Copy to ClipboardCopy to Clipboard<Copy to Clipboard, Copy to Clipboard>

Returns

Copy to Clipboard<Copy to Clipboard>

Defined in

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