Updates a Line Item
const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({line_item: {variant_id: '1', quantity: 2}})
};
fetch('http://{defaultHost}/api/v2/platform/line_items/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"data": {
"id": "30",
"type": "line_item",
"attributes": {
"quantity": 4,
"price": "10.0",
"created_at": "2022-11-08T19:34:21.508Z",
"updated_at": "2022-11-08T19:34:21.772Z",
"currency": "USD",
"cost_price": "17.0",
"adjustment_total": "0.0",
"additional_tax_total": "0.0",
"promo_total": "0.0",
"included_tax_total": "0.0",
"pre_tax_amount": "40.0",
"taxable_adjustment_total": "0.0",
"non_taxable_adjustment_total": "0.0",
"public_metadata": {},
"private_metadata": {},
"display_discounted_amount": "$40.00",
"display_amount": "$40.00",
"display_final_amount": "$40.00",
"display_subtotal": "$40.00",
"display_pre_tax_amount": "$40.00",
"display_price": "$10.00",
"display_adjustment_total": "$0.00",
"display_additional_tax_total": "$0.00",
"display_promo_total": "$0.00",
"display_total": "$40.00",
"display_included_tax_total": "$0.00"
},
"relationships": {
"order": {
"data": {
"id": "35",
"type": "order"
}
},
"tax_category": {
"data": {
"id": "75",
"type": "tax_category"
}
},
"variant": {
"data": {
"id": "192",
"type": "variant"
}
},
"adjustments": {
"data": []
},
"inventory_units": {
"data": []
},
"digital_links": {
"data": []
}
}
}
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Select which associated resources you would like to fetch, see: https://jsonapi.org/format/#fetching-includes
Show child attributes
Record updated
Show child attributes
Was this page helpful?
const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({line_item: {variant_id: '1', quantity: 2}})
};
fetch('http://{defaultHost}/api/v2/platform/line_items/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"data": {
"id": "30",
"type": "line_item",
"attributes": {
"quantity": 4,
"price": "10.0",
"created_at": "2022-11-08T19:34:21.508Z",
"updated_at": "2022-11-08T19:34:21.772Z",
"currency": "USD",
"cost_price": "17.0",
"adjustment_total": "0.0",
"additional_tax_total": "0.0",
"promo_total": "0.0",
"included_tax_total": "0.0",
"pre_tax_amount": "40.0",
"taxable_adjustment_total": "0.0",
"non_taxable_adjustment_total": "0.0",
"public_metadata": {},
"private_metadata": {},
"display_discounted_amount": "$40.00",
"display_amount": "$40.00",
"display_final_amount": "$40.00",
"display_subtotal": "$40.00",
"display_pre_tax_amount": "$40.00",
"display_price": "$10.00",
"display_adjustment_total": "$0.00",
"display_additional_tax_total": "$0.00",
"display_promo_total": "$0.00",
"display_total": "$40.00",
"display_included_tax_total": "$0.00"
},
"relationships": {
"order": {
"data": {
"id": "35",
"type": "order"
}
},
"tax_category": {
"data": {
"id": "75",
"type": "tax_category"
}
},
"variant": {
"data": {
"id": "192",
"type": "variant"
}
},
"adjustments": {
"data": []
},
"inventory_units": {
"data": []
},
"digital_links": {
"data": []
}
}
}
}