# Managing line items

## Getting all line items from a cart

You can use the Line Items resource to [get all line items from a cart](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/cart/line-items), including products, pricing, and tax information.

{% tabs %}
{% tab title="cURL" %}

```http
curl --location --request GET 'https://api.digitalriver.com/v1/shoppers/me/carts/active/line-items' \
--header 'authorization: Basic ***\
...
```

{% endtab %}

{% tab title="200 OK response" %}

```json
{
    "lineItems": {
        "links": [
            {
                "rel": "self",
                "href": "https://api.digitalriver.com/v1/shoppers/me/carts/active/line-items"
            },
            {
                "rel": "cart",
                "href": "https://api.digitalriver.com/v1/shoppers/me/carts/active"
            },
            {
                "rel": "new",
                "href": "https://api.digitalriver.com/v1/shoppers/me/carts/active/line-items",
                "method": "post",
                "type": "application/json"
            }
        ],
        "entities": [
            {
                "name": "lineItem",
                "links": [
                    {
                        "rel": "lineitem",
                        "href": "https://api.digitalriver.com/v1/shoppers/me/carts/active/line-items/53820030082"
                    }
                ],
                "data": {
                    "id": 53820030082,
                    "quantity": 1,
                    "billingAgreementId": "39b40910-3267-4b38-a07d-a6b05807f227"
                },
                "entities": [
                    {
                        "name": "product",
                        "links": [
                            {
                                "rel": "product",
                                "href": "https://api.digitalriver.com/v1/shoppers/me/products/287271100",
                                "title": "Subscription Physical"
                            }
                        ],
                        "data": {
                            "displayName": "Subscription Physical",
                            "thumbnailImage": null
                        }
                    },
                    {
                        "name": "pricing",
                        "data": {
                            "listPrice": {
                                "currency": "USD",
                                "value": 100
                            },
                            "listPriceWithQuantity": {
                                "currency": "USD",
                                "value": 100
                            },
                            "salePriceWithQuantity": {
                                "currency": "USD",
                                "value": 100
                            },
                            "formattedListPrice": "$100.00",
                            "formattedListPriceWithQuantity": "$100.00",
                            "formattedSalePriceWithQuantity": "$100.00",
                            "productTax": {
                                "currency": "USD",
                                "value": 8.53
                            },
                            "shippingTax": {
                                "currency": "USD",
                                "value": 0.01
                            },
                            "feeTax": {
                                "currency": "USD",
                                "value": 0
                            },
                            "taxRate": 0.08525,
                            "importTax": {
                                "currency": "USD",
                                "value": 0
                            },
                            "formattedImportTax": "$0.00",
                            "importDuty": {
                                "currency": "USD",
                                "value": 0
                            },
                            "formattedImportDuty": "$0.00"
                        }
                    }
                ]
            }
        ]
    }
}
```

{% endtab %}
{% endtabs %}

See the [query parameters](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/cart/line-items#v1-shoppers-me-carts-active-line-items) for more information.

## Getting a specific line item from a cart

You can use the Line Items resource to [get a specific line item](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/cart/line-items#v1-shoppers-me-carts-active-line-items-lineitemsid) from a cart, including products, pricing, and tax information.

{% tabs %}
{% tab title="cURL" %}

<pre class="language-http"><code class="lang-http">curl --location --request GET 'https://api.digitalriver.com/v1/shoppers/me/carts/active/line-items/{lineItesId}' \
--header 'authorization: Basic <a data-footnote-ref href="#user-content-fn-1"> </a>***\
...
</code></pre>

{% endtab %}

{% tab title="200 OK response" %}

````json
{
    "lineItem": {
        "links": [
            {
                "rel": "self",
                "href": "https://api.digitalriver.com/v1/shoppers/me/carts/active/line-items/53820030082"
            },
            {
                "rel": "save",
                "href": "https://api.digitalriver.com/v1/shoppers/me/carts/active/line-items/53820030082",
                "method": "POST",
                "type": "application/json"
            }
        ],
        "data": {
            "id": 53820030082,
            "quantity": 1,
            "billingAgreementId": "39b40910-3267-4b38-a07d-a6b05807f227"
        },
        "entities": [
            {
                "name": "product",
                "links": [
                    {
                        "rel": "product",
                        "href": "https://api.digitalriver.com/v1/shoppers/me/products/287271100",
                        "title": "Subscription Physical"
                    }
                ],
                "data": {
                    "displayName": "Subscription Physical",
                    "thumbnailImage": null
                }
            },
            {
                "name": "pricing",
                "data": {
                    "listPrice": {
                        "currency": "USD",
                        "value": 100
                    },
                    "listPriceWithQuantity": {
                        "currency": "USD",
                        "value": 100
                    },
                    "salePriceWithQuantity": {
                        "currency": "USD",
                        "value": 100
                    },
                    "formattedListPrice": "$100.00",
                    "formattedListPriceWithQuantity": "$100.00",
                    "formattedSalePriceWithQuantity": "$100.00",
                    "productTax": {
                        "currency": "USD",
                        "value": 8.53
                    },
                    "shippingTax": {
                        "currency": "USD",
                        "value": 0.01
                    },
                    "feeTax": {
                        "currency": "USD",
                        "value": 0
                    },
                    "taxRate": 0.08525,
                    "importTax": {
                        "currency": "USD",
                        "value": 0
                    },
                    "formattedImportTax": "$0.00",
                    "importDuty": {
                        "currency": "USD",
                        "value": 0
                    },
                    "formattedImportDuty": "$0.00"
                }
            }
        ]
    }
}
```
````

{% endtab %}
{% endtabs %}

See the [query parameters](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/cart/line-items#v1-shoppers-me-carts-active-line-items-lineitemsid) for more information.

## Getting line items for an order

You can [get all line items for an order](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/cart/line-items#v1-shoppers-me-orders-orderid-line-items) when you specify the `orderId`.

{% tabs %}
{% tab title="cURL" %}

```http
curl --location --request GET 'https://api.digitalriver.com/v1/shoppers/me/orders/{orderId}/line-items' \
--header 'authorization: Basic ***\
...
```

{% endtab %}

{% tab title="200 OK response" %}

```json
{
  "uri": "https://api.digitalriver.com/v1/shoppers/me/orders/47276010023/line-items",
  "lineItem": [
    {
      "uri": "https://api.digitalriver.com/v1/shoppers/me/orders/47276010023/line-items/488822300023",
      "id": "488822300023",
      "quantity": 1,
      "product": {
        "uri": "https://api.digitalriver.com/v1/shoppers/me/products/5112133200",
        "displayName": "Good Product",
        "thumbnailImage": "string"
      },
      "lineItemState": "Complete",
      "lineItemStateDetails": {
        "description": "Downloadable - 1",
        "backOrdered": 0,
        "shipped": 0,
        "returned": 0,
        "pendingReturn": 0
      },
      "pricing": {
        "listPrice": {
          "currency": "USD",
          "value": 101
        },
        "listPriceWithQuantity": {
          "currency": "USD",
          "value": 1010
        },
        "salePriceWithQuantity": {
          "currency": "USD",
          "value": 959.5
        },
        "formattedListPrice": "101.00USD",
        "formattedListPriceWithQuantity": "1010.00USD",
        "formattedSalePriceWithQuantity": "959.50USD",
        "formattedCommitmentPrice": "$240.00",
        "commitmentPrice": {
          "currency": "USD",
          "value": "240.00"
        },
        "productTax": {
          "currency": "USD",
          "value": "1.35"
        },
        "shippingTax": {
          "currency": "USD",
          "value": "0.65"
        },
        "feeTax": {
          "currency": "USD",
          "value": "2.00"
        },
        "taxRate": "0.1111",
        "importTax": {
          "currency": "USD",
          "value": 0
        },
        "formattedImportTax": "0.00USD",
        "importDuty": {
          "currency": "USD",
          "value": 0
        },
        "formattedImportDuty": "0.00USD"
      },
      "downloads": {
        "downloadUri": [
          "https://wgtsysot12.digitalriver.com/wgt/9B5A4FCEF11DA80C/171F14235882A3D349C4DF3E9F68F51B28573D6CB50E888238DC305C96D769176F6A4F895B77C58CF0F67A3572E1FE49934F924414F2486E45C01D39B94ADFA2E0920C4390CBA6042FE0C88CD46AAEA99C060E2044E521050A7DE0793B014624647C638FDE4F6D4D/demosft1/WaterLilies.jpg"
        ]
      },
      "digitalRights": {
        "serialNumber": {}
      },
      "billingAgreementId": "fc86a666-9f2f-4294-b591-468ae34122ff",
      "subscriptionIds": [
        "[15564325189,15564325289]"
      ]
    }
  ]
}
```

{% endtab %}
{% endtabs %}

See the [query parameters](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/cart/line-items#v1-shoppers-me-orders-orderid-line-items) for more information.

## Getting a specific line item for an order

You can [get a specific line item for an order](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/cart/line-items#v1-shoppers-me-orders-orderid-line-items-lineitemid) when you specify the `orderId`.

{% tabs %}
{% tab title="cURL" %}

```http
curl --location --request GET 'https://api.digitalriver.com/v1/shoppers/me/orders/{orderId}/line-items/[lineItemId]' \
--header 'authorization: Basic ***\
...
```

{% endtab %}

{% tab title="200 OK response" %}

```json
{
  "uri": "https://api.digitalriver.com/v1/shoppers/me/orders/47276010023/line-items/488822300023",
  "id": "488822300023",
  "quantity": 1,
  "product": {
    "uri": "https://api.digitalriver.com/v1/shoppers/me/products/5112133200",
    "displayName": "Good Product",
    "thumbnailImage": "string"
  },
  "lineItemState": "Complete",
  "lineItemStateDetails": {
    "description": "Downloadable - 1",
    "backOrdered": 0,
    "shipped": 0,
    "returned": 0,
    "pendingReturn": 0
  },
  "pricing": {
    "listPrice": {
      "currency": "USD",
      "value": 101
    },
    "listPriceWithQuantity": {
      "currency": "USD",
      "value": 1010
    },
    "salePriceWithQuantity": {
      "currency": "USD",
      "value": 959.5
    },
    "formattedListPrice": "101.00USD",
    "formattedListPriceWithQuantity": "1010.00USD",
    "formattedSalePriceWithQuantity": "959.50USD",
    "formattedCommitmentPrice": "$240.00",
    "commitmentPrice": {
      "currency": "USD",
      "value": "240.00"
    },
    "productTax": {
      "currency": "USD",
      "value": "1.35"
    },
    "shippingTax": {
      "currency": "USD",
      "value": "0.65"
    },
    "feeTax": {
      "currency": "USD",
      "value": "2.00"
    },
    "taxRate": "0.1111",
    "importTax": {
      "currency": "USD",
      "value": 0
    },
    "formattedImportTax": "0.00USD",
    "importDuty": {
      "currency": "USD",
      "value": 0
    },
    "formattedImportDuty": "0.00USD"
  },
  "downloads": {
    "downloadUri": [
      "https://wgtsysot12.digitalriver.com/wgt/9B5A4FCEF11DA80C/171F14235882A3D349C4DF3E9F68F51B28573D6CB50E888238DC305C96D769176F6A4F895B77C58CF0F67A3572E1FE49934F924414F2486E45C01D39B94ADFA2E0920C4390CBA6042FE0C88CD46AAEA99C060E2044E521050A7DE0793B014624647C638FDE4F6D4D/demosft1/WaterLilies.jpg"
    ]
  },
  "digitalRights": {
    "serialNumber": {}
  },
  "billingAgreementId": "fc86a666-9f2f-4294-b591-468ae34122ff",
  "subscriptionIds": [
    "[15564325189,15564325289]"
  ]
}
```

{% endtab %}
{% endtabs %}

See the [query parameters](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/cart/line-items#v1-shoppers-me-orders-orderid-line-items-lineitemid) for more information.

## Adding line items to a cart

You can [add one or more line items to a cart](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/cart/line-items#v1-shoppers-me-carts-active-line-items-1).'

{% tabs %}
{% tab title="cURL" %}

```http
curl --location --request POST 'https://api.digitalriver.com/shoppers/v1/shoppers/me/carts/active/line-items' \
--header 'authorization: Basic ***\
...
--data-raw '{
  "lineItems": {
    "lineItem": {
      "id": "991101014",
      "quantity": "1",
      "product": {
        "id": 1234
      },
      "pricing": {
        "salePrice": {
          "currency": "USD",
          "value": "10.99"
        }
      },
      "customAttributes": {
        "attribute": [
          {
            "name": "name",
            "value": "string",
            "type": "string"
          }
        ]
      }
    }
  }
}'
```

{% endtab %}

{% tab title="200 OK response" %}

```json
{
  "uri": "https://api.digitalriver.com/v1/shoppers/me/carts/active/line-items",
  "lineItems": [
    {
      "uri": "https://api.digitalriver.com/v1/shoppers/me/carts/active/line-items/488822300023",
      "id": "488822300023",
      "quantity": "1",
      "product": {
        "uri": "https://api.digitalriver.com/v1/shoppers/me/products/64578500",
        "parentProduct": {
          "uri": "https://api.digitalriver.com/v1/shoppers/me/products/64358200"
        },
        "id": "64578500",
        "name": "Class I",
        "displayName": "Class I",
        "shortDescription": "Class I is the perfect GPS waypoint and route manager for the beginning or occasional GPS user.",
        "longDescription": "Class I is the fast and easy way to create, edit, and transfer waypoints and routes between your computer and your Garmin, Magellan, or Lowrance GPS. Using Class I, you can manage all of your waypoints and routes, and display them in lists sorted by name, elevation, or distance. Class I connects your GPS to the best mapping and information sites on the Internet, giving you one-click access to street and topo maps, aerial photos, weather forecasts, and nearby attractions.",
        "productType": "DOWNLOAD",
        "sku": "Class I",
        "externalReferenceId": "Test External Reference Number",
        "companyId": "demosft1",
        "displayableProduct": "true",
        "purchasable": "true",
        "manufacturerName": "Test Manufacturer Name",
        "manufacturerPartNumber": "Test Manufacturer Part Number",
        "thumbnailImage": "https://drh-int-ora.img.digitalriver.com/Storefront/Company/demosft1/images/product/thumbnail/classIThumb.jpg",
        "productImage": "https://drh-int-ora.img.digitalriver.com/Storefront/Company/demosft1/images/product/detail/classIBox.jpg",
        "keywords": "testKeyword",
        "customAttributes": {
          "attribute": [
            {
              "name": "name",
              "value": "string",
              "type": "string"
            }
          ]
        }
      },
      "pricing": {
        "listPrice": {
          "currency": "USD",
          "value": 101
        },
        "listPriceWithQuantity": {
          "currency": "USD",
          "value": 1010
        },
        "salePriceWithQuantity": {
          "currency": "USD",
          "value": 959.5
        },
        "formattedListPrice": "101.00USD",
        "formattedListPriceWithQuantity": "1010.00USD",
        "formattedSalePriceWithQuantity": "959.50USD",
        "formattedCommitmentPrice": "$240.00",
        "commitmentPrice": {
          "currency": "USD",
          "value": "240.00"
        },
        "productTax": {
          "currency": "USD",
          "value": "1.35"
        },
        "shippingTax": {
          "currency": "USD",
          "value": "0.65"
        },
        "feeTax": {
          "currency": "USD",
          "value": "2.00"
        },
        "taxRate": "0.1111",
        "importTax": {
          "currency": "USD",
          "value": 0
        },
        "formattedImportTax": "0.00USD",
        "importDuty": {
          "currency": "USD",
          "value": 0
        },
        "formattedImportDuty": "0.00USD"
      }
    }
  ]
}
```

{% endtab %}
{% endtabs %}

See the [`query parameters`](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/cart/line-items#v1-shoppers-me-carts-active-line-items-1) for more information.

## Updating one or more line items to a cart

You can [update one or more line items to a cart](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/cart/line-items#v1-shoppers-me-carts-active-line-items-lineitemsid-1). If the product is a product combination, the combined product information appears under the `lineItem` object, and component information appears under the `component` object.

{% tabs %}
{% tab title="cURL" %}

```http
curl --location --request POST 'https://api.digitalriver.com/shoppers/v1/shoppers/me/carts/active/line-items/{lineItemId}?format=json*action=add&=quantity=2' \
--header 'authorization: Basic  ***\
...
```

{% endtab %}

{% tab title="200 OK response" %}

```json
{

	"uri": https://api.digitalriver.com/v1/shoppers/me/carts/active/line-items/488822300023,

	"id": "488822300023",
	"quantity": "1",
	"product": {
		"uri": "http://localhost:3335/integration/api/v1/shoppers/me/products/6207217700",
		"categories": {
			"uri": "http://localhost:3335/integration/api/v1/shoppers/me/products/6207217700/categories"
		},
		"familyAttributes": {
			"uri": "http://localhost:3335/integration/api/v1/shoppers/me/products/6207217700/family-attributes"
		},
		"id": 6207217700,
		"name": "Test Combination Product with Subs",
		"displayName": "Test Combination Product with Subs",
		"shortDescription": null,
		"longDescription": null,
		"productType": "OTHER",
		"sku": "12345",
		"externalReferenceId": null,
		"companyId": "paytest",
		"displayableProduct": "true",
		"purchasable": "true",
		"manufacturerName": null,
		"manufacturerPartNumber": "Digital Test",
		"minimumQuantity": null,
		"maximumQuantity": null,
		"thumbnailImage": null,
		"productImage": null,
		"keywords": null,
		"baseProduct": "false",
		"pricing": {
			"uri": "http://localhost:3335/integration/api/v1/shoppers/me/products/6207217700/pricing",
			"listPrice": {
			"currency": "USD",
			"value": 458.2
		},
		"salePriceWithQuantity": {
			"currency": "USD",
			"value": 358.2
		},
		"formattedListPrice": "$458.20",
		"formattedSalePriceWithQuantity": "$358.20",
		"listPriceIncludesTax": "false",
		"msrpPrice": null,
		"formattedMsrpPrice": null
	},
	"addProductToCart": {
		"uri": "http://localhost:3335/integration/api/v1/shoppers/me/carts/active/line-items?productId=6207217700",
		"cartUri": "http://localhost:3335/integration/api/v1/shoppers/me/carts/active?productId=6207217700"
	},
	////New Block /////
	"components": [
		{
			"product": {
				"id": "<Component Product ID>",
				"displayName": "<Component Product Site Name>",
				"productType": "DOWNLOAD"
				"sku": "Class II",
			},
			"pricing": {
				"listPrice": {
					"currency": "USD",
					"value": 300
				}
			},
			"subscription": true,
			"subscriptionInfo": {
				"autoRenewal": true,
				"termUnit": "year",
				"termLength": 2
			}
		},
		{
		"product": {
			"id": "<Component Product ID>",
			"displayName": "<Component Product Site Name>",
			"productType": "PHYSICAL"
			"sku": "Class III",
		},
		"pricing": {
			"listPrice": {
				"currency": "USD",
				"value": 58.2
			}
		},
		"subscription": false
			}
		]
	}
}
```

{% endtab %}
{% endtabs %}

See the [query parameters](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/cart/line-items#v1-shoppers-me-carts-active-line-items-lineitemsid-1) for more information.

## Deleting all line items from a cart

You can clear a cart by [deleting all line items from a cart](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/cart/line-items#v1-shoppers-me-carts-active-line-items-2).

{% tabs %}
{% tab title="cURL" %}

```http
curl --location --request DELETE 'https://api.digitalriver.com/shoppers/v1/shoppers/me/carts/active/line-items' \
--header 'authorization: Basic ***\
...
```

{% endtab %}
{% endtabs %}

You will get a `204 No Content` response. See the [query parameters](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/cart/line-items#v1-shoppers-me-carts-active-line-items-2) for more information.

## Deleting a specific line item from a cart

You can [delete a specific line item from a cart](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/cart/line-items#v1-shoppers-me-carts-active-line-items-lineitemsid-2).

{% tabs %}
{% tab title="cURL" %}

```http
curl --location --request DELETE 'https://api.digitalriver.com/shoppers/v1/shoppers/me/carts/active/line-items/{lineItemId}' \
--header 'authorization: Basic ***\
...
```

{% endtab %}
{% endtabs %}

You will get a `204 No Content` response. See the [query parameters](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/cart/line-items#v1-shoppers-me-carts-active-line-items-lineitemsid-2) for more information.

[^1]:
