---
title: "line_item"

doc_type: static
doc_category: static
doc_version: v20260901
source_url:
  html: 'https://developer.shopline.com/zh-hans-cn/docs/handlebars/objects/line-item'
  md: 'https://developer.shopline.com/zh-hans-cn/docs/handlebars/objects/line-item.md'
---


# line_item

<div className="code-flex">
  <div>
    <ObjectSummary>
      购物车、结帐或订单中的每一行商品数据详情。
    </ObjectSummary>
    #### 属性

    <ObjectProperty name="discount_allocations" types={[<Mdx>array of [discount_allocation](https://developer.shopline.com/zh-hans-cn/docs/handlebars/objects/discount-allocation.md)</Mdx>]}>
      <ObjectSummary>
        商品行的折扣分配。
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="final_line_price" types={["string"]}>
      <ObjectSummary>
        商品行的价格合计。这包括了所有商品行级别折扣优惠。

        此值等于 `line_item.final_price` 与 `line_item.quantity` 的乘积。
                > **Tip**
>
> 使用 [货币格式化hepler](https://developer.shopline.com/zh-hans-cn/docs/handlebars/helpers/money/money-with-currency.md) 格式化金额。
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="final_price" types={["string"]}>
      <ObjectSummary>
        商品行的商品单价。这包括了所有商品行级别折扣优惠。

                > **Tip**
>
> 使用 [货币格式化hepler](https://developer.shopline.com/zh-hans-cn/docs/handlebars/helpers/money/money-with-currency.md) 格式化金额。
      </ObjectSummary>
    </ObjectProperty>
    <ObjectProperty name="fulfillments" types={[<Mdx>array of fulfillment</Mdx>]}>
      <ObjectSummary>
        商品行的履约信息。
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="gift_card" types={["boolean"]}>
      <ObjectSummary>
        如果与商品行关联的产品支持礼品卡，则返回 `true`。如果不是，则返回 `false`。
      </ObjectSummary>
    </ObjectProperty>

    {/* <ObjectProperty name="grams" types={["string"]}>
      <ObjectSummary>
        The weight of the line item in the store's [default weight unit]().
      </ObjectSummary>
    </ObjectProperty> */}

     {/* <ObjectProperty name="id" types={["number"]}>
      <ObjectSummary>
        The ID of the line item.
      </ObjectSummary>
    </ObjectProperty> */}

    <ObjectProperty name="image" types={[<Mdx>[image](https://developer.shopline.com/zh-hans-cn/docs/handlebars/objects/image.md)</Mdx>]}>
      <ObjectSummary>
        商品行的图片。

        图片可以来自一下资源：
          - 与商品行关联的商品SKU图片。
          - 与商品行关联的商品特色图片（如果没有商品SKU图片）。
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="key" types={["string"]}>
      <ObjectSummary>
        商品行的key。

        商品行的key是唯一标识符，由以下用冒号分隔的组件组成：
          - 与商品行关联的商品SKU ID。
          - 商品行的哈希值。
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="line_level_discount_allocations" types={[<Mdx>array of [discount_allocations](/docsv2/ec20/hdwvcvrgnfcjf4gq/ypzegcbfs6ugf5vys)</Mdx>]}>
      <ObjectSummary>
        直接应用于商品行的折扣。
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="line_level_total_discount" types={["number"]}>
      <ObjectSummary>
        商品行的折扣总额。

        > **Tip**
>
> 使用 [货币格式化hepler](https://developer.shopline.com/zh-hans-cn/docs/handlebars/helpers/money/money-with-currency.md) 格式化金额。
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="options_with_values">
      <ObjectSummary>
      商品行关联的变体的每个选项的名称和值。

      > **Note**
>
> 此数组永远不为空，因为尽管商品变体没有选项也会存在一个默认选项。基于此，你应该使用`line_item.product.has_only_default_variant`判断是否展示这些内容。
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="original_line_price" types={["string"]}>
      <ObjectSummary>
        应用折扣前的商品行的价格合计。

        此值等于 `line_item.original_price` 与 `line_item.quantity` 的乘积。
        > **Tip**
>
> 使用 [货币格式化hepler](https://developer.shopline.com/zh-hans-cn/docs/handlebars/helpers/money/money-with-currency.md) 格式化金额。
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="original_price" types={["string"]}>
      <ObjectSummary>
        应用折扣前的商品行单价。

                        > **Tip**
>
> 使用 [货币格式化hepler](https://developer.shopline.com/zh-hans-cn/docs/handlebars/helpers/money/money-with-currency.md) 格式化金额。
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="product" types={[<Mdx>[product](https://developer.shopline.com/zh-hans-cn/docs/handlebars/objects/product.md)</Mdx>]}>
      <ObjectSummary>
        商品行关联的商品。
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="product_id" types={["string"]}>
      <ObjectSummary>
        商品行的[商品ID](https://developer.shopline.com/zh-hans-cn/docs/handlebars/objects/product.md#id)。
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="properties">
    {/* TODO 补充使用方法 */}
      <ObjectSummary>
        商品行的属性。

        您可以手动添加或者让客户在商品行中添加自定义信息。

        商品行属性由名称和值对组成. 可以使用以下方法捕获它们：
        - 在商品表单中添加自定义的input
        - 购物车 AJAX API
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="quantity" types={["number"]}>
      <ObjectSummary>
        商品行的数量。
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="requires_shipping" types={["boolean"]}>
      <ObjectSummary>
        如果与商品行关联的变体需要运费，则返回`true`。如果不是，则返回 `false`。
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="selling_plan_allocation" types={[<Mdx>selling_plan_allocation</Mdx>]}>
      {/* TODO 接口返回不是null 是属性每个undefined */}
      {/* TODO 补充可用性 */}
      <ObjectSummary>
        商品行关联的销售计划。如果没有则返回`null`。
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="sku" types={["string"]}>
      <ObjectSummary>
        与商品行关联的变体的[sku](https://developer.shopline.com/zh-hans-cn/docs/handlebars/objects/variant.md)。
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="successfully_fulfilled_quantity" types={["number"]}>
      <ObjectSummary>
        商品行中已成功履约数量。
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="taxable" types={["boolean"]}>
      <ObjectSummary>
        如果商品需要税费则返回`true`,否则返回`false`。
      </ObjectSummary>
    </ObjectProperty>

    {/* <ObjectProperty name="title" types={["string"]}>
      <ObjectSummary>
        The title of the line item. The title is a combination of `line_item.product.title` and `line_item.variant.title`, separated by a hyphen.
      </ObjectSummary>
    </ObjectProperty> */}

    <ObjectProperty name="url" types={["string"]}>
      <ObjectSummary>
        与商品行关联的商品的相对 URL
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="url_to_remove" types={["string"]}>
      <ObjectSummary>
        用于从购物车中删除商品行的 URL。
        {/* TODO 补充最佳实践跳转 */}
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="variant" types={["variant"]}>
      <ObjectSummary>
        商品行关联的商品变体。
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="variant_id" types={["string"]}>
      <ObjectSummary>
        商品行关联的[商品变体 ID](https://developer.shopline.com/zh-hans-cn/docs/handlebars/objects/variant.md)
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="vendor" types={["string"]}>
      <ObjectSummary>
        与商品行关联的商品供应商。
      </ObjectSummary>
    </ObjectProperty>
  </div>

  <div>
    <ObjectAccess
      object="line_item"
      global={false}
      parents={[
        { object: 'cart.items', link: '/docsv2/ec20/hdwvcvrgnfcjf4gq/rmhen6uapsz6pyu4#items' },
        { object: 'checkout.line_items', link: '/docsv2/ec20/hdwvcvrgnfcjf4gq/8ufgwg6esxkwtg35#line_items' },
      ]}
    />
  </div>
</div>
