Files
medusa-store/www/apps/docs/content/references/services/classes/LineItem.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

477 lines
12 KiB
Plaintext

---
displayed_sidebar: servicesSidebar
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# LineItem
Line Items are created when a product is added to a Cart. When Line Items are purchased they will get copied to the resulting order, swap, or claim, and can eventually be referenced in Fulfillments and Returns. Line items may also be used for order edits.
## Constructors
### constructor
`**new LineItem**()`
Line Items are created when a product is added to a Cart. When Line Items are purchased they will get copied to the resulting order, swap, or claim, and can eventually be referenced in Fulfillments and Returns. Line items may also be used for order edits.
## Properties
<ParameterTypes parameters={[
{
"name": "adjustments",
"type": "[LineItemAdjustment](LineItemAdjustment.mdx)[]",
"description": "The details of the item's adjustments, which are available when a discount is applied on the item.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "allow_discounts",
"type": "`boolean`",
"description": "Flag to indicate if the Line Item should be included when doing discount calculations.",
"optional": false,
"defaultValue": "true",
"expandable": false,
"children": []
},
{
"name": "cart",
"type": "[Cart](Cart.mdx)",
"description": "The details of the cart that the line item may belongs to.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "cart_id",
"type": "`string`",
"description": "The ID of the cart that the line item may belongs to.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "claim_order",
"type": "[ClaimOrder](ClaimOrder.mdx)",
"description": "The details of the claim that the line item may belong to.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "claim_order_id",
"type": "`string`",
"description": "The ID of the claim that the line item may belong to.",
"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": "description",
"type": "`null` \\| `string`",
"description": "A more detailed description of the contents of the Line Item.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "discount_total",
"type": "`null` \\| `number`",
"description": "The total of discount of the line item rounded",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "fulfilled_quantity",
"type": "`null` \\| `number`",
"description": "The quantity of the Line Item that has been fulfilled.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gift_card_total",
"type": "`null` \\| `number`",
"description": "The total of the gift card of the line item",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "has_shipping",
"type": "`null` \\| `boolean`",
"description": "Flag to indicate if the Line Item has fulfillment associated with it.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The line item's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "includes_tax",
"type": "`boolean`",
"description": "Indicates if the line item unit\\_price include tax",
"optional": false,
"defaultValue": "false",
"expandable": false,
"featureFlag": "tax_inclusive_pricing",
"children": []
},
{
"name": "is_giftcard",
"type": "`boolean`",
"description": "Flag to indicate if the Line Item is a Gift Card.",
"optional": false,
"defaultValue": "false",
"expandable": false,
"children": []
},
{
"name": "is_return",
"type": "`boolean`",
"description": "Is the item being returned",
"optional": false,
"defaultValue": "false",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "order",
"type": "[Order](Order.mdx)",
"description": "The details of the order that the line item may belongs to.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "order_edit",
"type": "`null` \\| [OrderEdit](OrderEdit.mdx)",
"description": "The details of the order edit.",
"optional": true,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "order_edit_id",
"type": "`null` \\| `string`",
"description": "The ID of the order edit that the item may belong to.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "order_id",
"type": "`null` \\| `string`",
"description": "The ID of the order that the line item may belongs to.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "original_item_id",
"type": "`null` \\| `string`",
"description": "The ID of the original line item. This is useful if the line item belongs to a resource that references an order, such as a return or an order edit.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "original_tax_total",
"type": "`null` \\| `number`",
"description": "The original tax total amount of the line item",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "original_total",
"type": "`null` \\| `number`",
"description": "The original total amount of the line item",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "product_id",
"type": "`null` \\| `string`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "quantity",
"type": "`number`",
"description": "The quantity of the content in the Line Item.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "raw_discount_total",
"type": "`null` \\| `number`",
"description": "The total of discount of the line item",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "refundable",
"type": "`null` \\| `number`",
"description": "The amount that can be refunded from the given Line Item. Takes taxes and discounts into consideration.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "returned_quantity",
"type": "`null` \\| `number`",
"description": "The quantity of the Line Item that has been returned.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shipped_quantity",
"type": "`null` \\| `number`",
"description": "The quantity of the Line Item that has been shipped.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "should_merge",
"type": "`boolean`",
"description": "Flag to indicate if new Line Items with the same variant should be merged or added as an additional Line Item.",
"optional": false,
"defaultValue": "true",
"expandable": false,
"children": []
},
{
"name": "subtotal",
"type": "`null` \\| `number`",
"description": "The subtotal of the line item",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "swap",
"type": "[Swap](Swap.mdx)",
"description": "The details of the swap that the line item may belong to.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "swap_id",
"type": "`string`",
"description": "The ID of the swap that the line item may belong to.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tax_lines",
"type": "[LineItemTaxLine](LineItemTaxLine.mdx)[]",
"description": "The details of the item's tax lines.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "tax_total",
"type": "`null` \\| `number`",
"description": "The total of tax of the line item",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "thumbnail",
"type": "`null` \\| `string`",
"description": "A URL string to a small image of the contents of the Line Item.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "title",
"type": "`string`",
"description": "The title of the Line Item.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "total",
"type": "`null` \\| `number`",
"description": "The total amount of the line item",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "unit_price",
"type": "`number`",
"description": "The price of one unit of the content in the Line Item. This should be in the currency defined by the Cart/Order/Swap/Claim that the Line Item belongs to.",
"optional": false,
"defaultValue": "",
"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": []
},
{
"name": "variant",
"type": "[ProductVariant](ProductVariant.mdx)",
"description": "The details of the product variant that this item was created from.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "variant_id",
"type": "`null` \\| `string`",
"description": "The id of the Product Variant contained in the Line Item.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
## Methods
### afterUpdateOrLoad
`**afterUpdateOrLoad**(): void`
#### Returns
`void`
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### beforeInsert
`Private **beforeInsert**(): void`
#### Returns
`void`
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### beforeUpdate
`**beforeUpdate**(): void`
#### Returns
`void`
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />