* fixed typedoc plugin's escape strategy * move props comments to the associated property * regenerate references
1379 lines
47 KiB
Plaintext
1379 lines
47 KiB
Plaintext
---
|
|
displayed_sidebar: jsClientSidebar
|
|
slug: /references/js-client/LineItemsResource
|
|
---
|
|
|
|
import ParameterTypes from "@site/src/components/ParameterTypes"
|
|
|
|
# LineItemsResource
|
|
|
|
This class is used to send requests to Line Item API Routes part of the [Store Cart API Routes](https://docs.medusajs.com/api/store#carts). All its method
|
|
are available in the JS Client under the `medusa.carts.lineItems` property.
|
|
|
|
## Methods
|
|
|
|
### create
|
|
|
|
Generates a Line Item with a given Product Variant and adds it to the Cart
|
|
|
|
#### Example
|
|
|
|
```ts
|
|
import Medusa from "@medusajs/medusa-js"
|
|
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
|
medusa.carts.lineItems
|
|
.create(cart_id, {
|
|
variant_id,
|
|
quantity: 1,
|
|
})
|
|
.then(({ cart }) => {
|
|
console.log(cart.id)
|
|
})
|
|
```
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "cart_id",
|
|
"type": "`string`",
|
|
"description": "The cart's ID.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "payload",
|
|
"type": "[StorePostCartsCartLineItemsReq](../internal/classes/internal.StorePostCartsCartLineItemsReq.mdx)",
|
|
"description": "The line item to be created.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "metadata",
|
|
"type": "`Record<string, unknown>`",
|
|
"description": "An optional key-value map with additional details about the Line Item.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "quantity",
|
|
"type": "`number`",
|
|
"description": "The quantity of the Product Variant to add to the Line Item.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "variant_id",
|
|
"type": "`string`",
|
|
"description": "The id of the Product Variant to generate the Line Item from.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "customHeaders",
|
|
"type": "`Record<string, any>`",
|
|
"description": "Custom headers to attach to the request.",
|
|
"optional": false,
|
|
"defaultValue": "{}",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
#### Returns
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "ResponsePromise",
|
|
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)<[StoreCartsRes](../internal/types/internal.StoreCartsRes.mdx)>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "Resolves to the associated cart's details.",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "StoreCartsRes",
|
|
"type": "`object`",
|
|
"description": "The cart's details.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "cart",
|
|
"type": "[Omit](../internal/types/internal.Omit.mdx)<[Cart](../internal/classes/internal.Cart.mdx), \"refundable_amount\" \\| \"refunded_total\">",
|
|
"description": "Cart details.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "billing_address",
|
|
"type": "[Address](../internal/classes/internal.Address.mdx)",
|
|
"description": "The details of the billing address associated with the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "billing_address_id",
|
|
"type": "`string`",
|
|
"description": "The billing address's ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "completed_at",
|
|
"type": "`Date`",
|
|
"description": "The date with timezone at which the cart was completed.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "context",
|
|
"type": "`Record<string, unknown>`",
|
|
"description": "The context of the cart which can include info like IP or user agent.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "created_at",
|
|
"type": "`Date`",
|
|
"description": "The date with timezone at which the resource was created.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "customer",
|
|
"type": "[Customer](../internal/classes/internal.Customer.mdx)",
|
|
"description": "The details of the customer the cart belongs to.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "customer_id",
|
|
"type": "`string`",
|
|
"description": "The customer's ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "deleted_at",
|
|
"type": "`null` \\| `Date`",
|
|
"description": "The date with timezone at which the resource was deleted.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "discount_total",
|
|
"type": "`number`",
|
|
"description": "The total of discount rounded",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "discounts",
|
|
"type": "[Discount](../internal/classes/internal.Discount-1.mdx)[]",
|
|
"description": "An array of details of all discounts applied to the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "email",
|
|
"type": "`string`",
|
|
"description": "The email associated with the cart",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "gift_card_tax_total",
|
|
"type": "`number`",
|
|
"description": "The total of gift cards with taxes",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "gift_card_total",
|
|
"type": "`number`",
|
|
"description": "The total of gift cards",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "gift_cards",
|
|
"type": "[GiftCard](../internal/classes/internal.GiftCard-1.mdx)[]",
|
|
"description": "An array of details of all gift cards applied to the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "id",
|
|
"type": "`string`",
|
|
"description": "The cart's ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "idempotency_key",
|
|
"type": "`string`",
|
|
"description": "Randomly generated key used to continue the completion of a cart in case of failure.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "item_tax_total",
|
|
"type": "`null` \\| `number`",
|
|
"description": "The total of items with taxes",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "items",
|
|
"type": "[LineItem](../internal/classes/internal.LineItem.mdx)[]",
|
|
"description": "The line items added to the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "metadata",
|
|
"type": "`Record<string, unknown>`",
|
|
"description": "An optional key-value map with additional details",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "payment",
|
|
"type": "[Payment](../internal/classes/internal.Payment.mdx)",
|
|
"description": "The details of the payment associated with the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "payment_authorized_at",
|
|
"type": "`Date`",
|
|
"description": "The date with timezone at which the payment was authorized.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "payment_id",
|
|
"type": "`string`",
|
|
"description": "The payment's ID if available",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "payment_session",
|
|
"type": "`null` \\| [PaymentSession](../internal/classes/internal.PaymentSession.mdx)",
|
|
"description": "The details of the selected payment session in the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "payment_sessions",
|
|
"type": "[PaymentSession](../internal/classes/internal.PaymentSession.mdx)[]",
|
|
"description": "The details of all payment sessions created on the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "raw_discount_total",
|
|
"type": "`number`",
|
|
"description": "The total of discount",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "region",
|
|
"type": "[Region](../internal/classes/internal.Region.mdx)",
|
|
"description": "The details of the region associated with the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "region_id",
|
|
"type": "`string`",
|
|
"description": "The region's ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "sales_channel",
|
|
"type": "[SalesChannel](../internal/classes/internal.SalesChannel.mdx)",
|
|
"description": "The details of the sales channel associated with the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "sales_channel_id",
|
|
"type": "`null` \\| `string`",
|
|
"description": "The sales channel ID the cart is associated with.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "shipping_address",
|
|
"type": "`null` \\| [Address](../internal/classes/internal.Address.mdx)",
|
|
"description": "The details of the shipping address associated with the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "shipping_address_id",
|
|
"type": "`string`",
|
|
"description": "The shipping address's ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "shipping_methods",
|
|
"type": "[ShippingMethod](../internal/classes/internal.ShippingMethod-4.mdx)[]",
|
|
"description": "The details of the shipping methods added to the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "shipping_tax_total",
|
|
"type": "`null` \\| `number`",
|
|
"description": "The total of shipping with taxes",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "shipping_total",
|
|
"type": "`number`",
|
|
"description": "The total of shipping",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "subtotal",
|
|
"type": "`number`",
|
|
"description": "The subtotal of the cart",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "tax_total",
|
|
"type": "`null` \\| `number`",
|
|
"description": "The total of tax",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "total",
|
|
"type": "`number`",
|
|
"description": "The total amount of the cart",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "type",
|
|
"type": "[CartType](../internal/enums/internal.CartType.mdx)",
|
|
"description": "The cart's type.",
|
|
"optional": false,
|
|
"defaultValue": "default",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "updated_at",
|
|
"type": "`Date`",
|
|
"description": "The date with timezone at which the resource was updated.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
### delete
|
|
|
|
Delete a line item from a cart. The payment sessions will be updated and the totals will be recalculated.
|
|
|
|
#### Example
|
|
|
|
```ts
|
|
import Medusa from "@medusajs/medusa-js"
|
|
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
|
medusa.carts.lineItems.delete(cartId, lineId).then(({ cart }) => {
|
|
console.log(cart.id)
|
|
})
|
|
```
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "cart_id",
|
|
"type": "`string`",
|
|
"description": "The ID of the line item's cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "line_id",
|
|
"type": "`string`",
|
|
"description": "The ID of the line item to delete.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "customHeaders",
|
|
"type": "`Record<string, any>`",
|
|
"description": "Custom headers to attach to the request.",
|
|
"optional": false,
|
|
"defaultValue": "{}",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
#### Returns
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "ResponsePromise",
|
|
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)<[StoreCartsRes](../internal/types/internal.StoreCartsRes.mdx)>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "Resolves to the associated cart's details.",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "StoreCartsRes",
|
|
"type": "`object`",
|
|
"description": "The cart's details.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "cart",
|
|
"type": "[Omit](../internal/types/internal.Omit.mdx)<[Cart](../internal/classes/internal.Cart.mdx), \"refundable_amount\" \\| \"refunded_total\">",
|
|
"description": "Cart details.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "billing_address",
|
|
"type": "[Address](../internal/classes/internal.Address.mdx)",
|
|
"description": "The details of the billing address associated with the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "billing_address_id",
|
|
"type": "`string`",
|
|
"description": "The billing address's ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "completed_at",
|
|
"type": "`Date`",
|
|
"description": "The date with timezone at which the cart was completed.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "context",
|
|
"type": "`Record<string, unknown>`",
|
|
"description": "The context of the cart which can include info like IP or user agent.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "created_at",
|
|
"type": "`Date`",
|
|
"description": "The date with timezone at which the resource was created.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "customer",
|
|
"type": "[Customer](../internal/classes/internal.Customer.mdx)",
|
|
"description": "The details of the customer the cart belongs to.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "customer_id",
|
|
"type": "`string`",
|
|
"description": "The customer's ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "deleted_at",
|
|
"type": "`null` \\| `Date`",
|
|
"description": "The date with timezone at which the resource was deleted.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "discount_total",
|
|
"type": "`number`",
|
|
"description": "The total of discount rounded",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "discounts",
|
|
"type": "[Discount](../internal/classes/internal.Discount-1.mdx)[]",
|
|
"description": "An array of details of all discounts applied to the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "email",
|
|
"type": "`string`",
|
|
"description": "The email associated with the cart",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "gift_card_tax_total",
|
|
"type": "`number`",
|
|
"description": "The total of gift cards with taxes",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "gift_card_total",
|
|
"type": "`number`",
|
|
"description": "The total of gift cards",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "gift_cards",
|
|
"type": "[GiftCard](../internal/classes/internal.GiftCard-1.mdx)[]",
|
|
"description": "An array of details of all gift cards applied to the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "id",
|
|
"type": "`string`",
|
|
"description": "The cart's ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "idempotency_key",
|
|
"type": "`string`",
|
|
"description": "Randomly generated key used to continue the completion of a cart in case of failure.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "item_tax_total",
|
|
"type": "`null` \\| `number`",
|
|
"description": "The total of items with taxes",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "items",
|
|
"type": "[LineItem](../internal/classes/internal.LineItem.mdx)[]",
|
|
"description": "The line items added to the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "metadata",
|
|
"type": "`Record<string, unknown>`",
|
|
"description": "An optional key-value map with additional details",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "payment",
|
|
"type": "[Payment](../internal/classes/internal.Payment.mdx)",
|
|
"description": "The details of the payment associated with the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "payment_authorized_at",
|
|
"type": "`Date`",
|
|
"description": "The date with timezone at which the payment was authorized.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "payment_id",
|
|
"type": "`string`",
|
|
"description": "The payment's ID if available",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "payment_session",
|
|
"type": "`null` \\| [PaymentSession](../internal/classes/internal.PaymentSession.mdx)",
|
|
"description": "The details of the selected payment session in the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "payment_sessions",
|
|
"type": "[PaymentSession](../internal/classes/internal.PaymentSession.mdx)[]",
|
|
"description": "The details of all payment sessions created on the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "raw_discount_total",
|
|
"type": "`number`",
|
|
"description": "The total of discount",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "region",
|
|
"type": "[Region](../internal/classes/internal.Region.mdx)",
|
|
"description": "The details of the region associated with the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "region_id",
|
|
"type": "`string`",
|
|
"description": "The region's ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "sales_channel",
|
|
"type": "[SalesChannel](../internal/classes/internal.SalesChannel.mdx)",
|
|
"description": "The details of the sales channel associated with the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "sales_channel_id",
|
|
"type": "`null` \\| `string`",
|
|
"description": "The sales channel ID the cart is associated with.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "shipping_address",
|
|
"type": "`null` \\| [Address](../internal/classes/internal.Address.mdx)",
|
|
"description": "The details of the shipping address associated with the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "shipping_address_id",
|
|
"type": "`string`",
|
|
"description": "The shipping address's ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "shipping_methods",
|
|
"type": "[ShippingMethod](../internal/classes/internal.ShippingMethod-4.mdx)[]",
|
|
"description": "The details of the shipping methods added to the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "shipping_tax_total",
|
|
"type": "`null` \\| `number`",
|
|
"description": "The total of shipping with taxes",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "shipping_total",
|
|
"type": "`number`",
|
|
"description": "The total of shipping",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "subtotal",
|
|
"type": "`number`",
|
|
"description": "The subtotal of the cart",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "tax_total",
|
|
"type": "`null` \\| `number`",
|
|
"description": "The total of tax",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "total",
|
|
"type": "`number`",
|
|
"description": "The total amount of the cart",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "type",
|
|
"type": "[CartType](../internal/enums/internal.CartType.mdx)",
|
|
"description": "The cart's type.",
|
|
"optional": false,
|
|
"defaultValue": "default",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "updated_at",
|
|
"type": "`Date`",
|
|
"description": "The date with timezone at which the resource was updated.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
### update
|
|
|
|
Update a line item's data.
|
|
|
|
#### Example
|
|
|
|
```ts
|
|
import Medusa from "@medusajs/medusa-js"
|
|
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
|
medusa.carts.lineItems
|
|
.update(cartId, lineId, {
|
|
quantity: 1,
|
|
})
|
|
.then(({ cart }) => {
|
|
console.log(cart.id)
|
|
})
|
|
```
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "cart_id",
|
|
"type": "`string`",
|
|
"description": "The ID of the line item's cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "line_id",
|
|
"type": "`string`",
|
|
"description": "The ID of the line item to update.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "payload",
|
|
"type": "[StorePostCartsCartLineItemsItemReq](../internal/classes/internal.StorePostCartsCartLineItemsItemReq.mdx)",
|
|
"description": "The data to update in the line item.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "metadata",
|
|
"type": "`Record<string, unknown>`",
|
|
"description": "An optional key-value map with additional details about the Line Item. If omitted, the metadata will remain unchanged.\"",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "quantity",
|
|
"type": "`number`",
|
|
"description": "The quantity of the line item in the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "customHeaders",
|
|
"type": "`Record<string, any>`",
|
|
"description": "Custom headers to attach to the request.",
|
|
"optional": false,
|
|
"defaultValue": "{}",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
#### Returns
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "ResponsePromise",
|
|
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)<[StoreCartsRes](../internal/types/internal.StoreCartsRes.mdx)>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "Resolves to the associated cart's details.",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "StoreCartsRes",
|
|
"type": "`object`",
|
|
"description": "The cart's details.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "cart",
|
|
"type": "[Omit](../internal/types/internal.Omit.mdx)<[Cart](../internal/classes/internal.Cart.mdx), \"refundable_amount\" \\| \"refunded_total\">",
|
|
"description": "Cart details.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "billing_address",
|
|
"type": "[Address](../internal/classes/internal.Address.mdx)",
|
|
"description": "The details of the billing address associated with the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "billing_address_id",
|
|
"type": "`string`",
|
|
"description": "The billing address's ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "completed_at",
|
|
"type": "`Date`",
|
|
"description": "The date with timezone at which the cart was completed.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "context",
|
|
"type": "`Record<string, unknown>`",
|
|
"description": "The context of the cart which can include info like IP or user agent.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "created_at",
|
|
"type": "`Date`",
|
|
"description": "The date with timezone at which the resource was created.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "customer",
|
|
"type": "[Customer](../internal/classes/internal.Customer.mdx)",
|
|
"description": "The details of the customer the cart belongs to.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "customer_id",
|
|
"type": "`string`",
|
|
"description": "The customer's ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "deleted_at",
|
|
"type": "`null` \\| `Date`",
|
|
"description": "The date with timezone at which the resource was deleted.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "discount_total",
|
|
"type": "`number`",
|
|
"description": "The total of discount rounded",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "discounts",
|
|
"type": "[Discount](../internal/classes/internal.Discount-1.mdx)[]",
|
|
"description": "An array of details of all discounts applied to the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "email",
|
|
"type": "`string`",
|
|
"description": "The email associated with the cart",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "gift_card_tax_total",
|
|
"type": "`number`",
|
|
"description": "The total of gift cards with taxes",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "gift_card_total",
|
|
"type": "`number`",
|
|
"description": "The total of gift cards",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "gift_cards",
|
|
"type": "[GiftCard](../internal/classes/internal.GiftCard-1.mdx)[]",
|
|
"description": "An array of details of all gift cards applied to the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "id",
|
|
"type": "`string`",
|
|
"description": "The cart's ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "idempotency_key",
|
|
"type": "`string`",
|
|
"description": "Randomly generated key used to continue the completion of a cart in case of failure.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "item_tax_total",
|
|
"type": "`null` \\| `number`",
|
|
"description": "The total of items with taxes",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "items",
|
|
"type": "[LineItem](../internal/classes/internal.LineItem.mdx)[]",
|
|
"description": "The line items added to the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "metadata",
|
|
"type": "`Record<string, unknown>`",
|
|
"description": "An optional key-value map with additional details",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "payment",
|
|
"type": "[Payment](../internal/classes/internal.Payment.mdx)",
|
|
"description": "The details of the payment associated with the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "payment_authorized_at",
|
|
"type": "`Date`",
|
|
"description": "The date with timezone at which the payment was authorized.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "payment_id",
|
|
"type": "`string`",
|
|
"description": "The payment's ID if available",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "payment_session",
|
|
"type": "`null` \\| [PaymentSession](../internal/classes/internal.PaymentSession.mdx)",
|
|
"description": "The details of the selected payment session in the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "payment_sessions",
|
|
"type": "[PaymentSession](../internal/classes/internal.PaymentSession.mdx)[]",
|
|
"description": "The details of all payment sessions created on the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "raw_discount_total",
|
|
"type": "`number`",
|
|
"description": "The total of discount",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "region",
|
|
"type": "[Region](../internal/classes/internal.Region.mdx)",
|
|
"description": "The details of the region associated with the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "region_id",
|
|
"type": "`string`",
|
|
"description": "The region's ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "sales_channel",
|
|
"type": "[SalesChannel](../internal/classes/internal.SalesChannel.mdx)",
|
|
"description": "The details of the sales channel associated with the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "sales_channel_id",
|
|
"type": "`null` \\| `string`",
|
|
"description": "The sales channel ID the cart is associated with.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "shipping_address",
|
|
"type": "`null` \\| [Address](../internal/classes/internal.Address.mdx)",
|
|
"description": "The details of the shipping address associated with the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "shipping_address_id",
|
|
"type": "`string`",
|
|
"description": "The shipping address's ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "shipping_methods",
|
|
"type": "[ShippingMethod](../internal/classes/internal.ShippingMethod-4.mdx)[]",
|
|
"description": "The details of the shipping methods added to the cart.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "shipping_tax_total",
|
|
"type": "`null` \\| `number`",
|
|
"description": "The total of shipping with taxes",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "shipping_total",
|
|
"type": "`number`",
|
|
"description": "The total of shipping",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "subtotal",
|
|
"type": "`number`",
|
|
"description": "The subtotal of the cart",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "tax_total",
|
|
"type": "`null` \\| `number`",
|
|
"description": "The total of tax",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "total",
|
|
"type": "`number`",
|
|
"description": "The total amount of the cart",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "type",
|
|
"type": "[CartType](../internal/enums/internal.CartType.mdx)",
|
|
"description": "The cart's type.",
|
|
"optional": false,
|
|
"defaultValue": "default",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "updated_at",
|
|
"type": "`Date`",
|
|
"description": "The date with timezone at which the resource was updated.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]} />
|