useLineItemAttributes
This hook manages custom line item attributes (cart item properties) on the product detail page. It reads and writes to the page state, allowing you to attach custom key-value pairs to cart line items.
Import
import { useLineItemAttributes } from '@appmaker-xyz/shopify';
Basic Usage
const [value, setValue] = useLineItemAttributes('engraving_text');
// Read the current value
console.log(value); // ''
// Set a new value
setValue('Hello World');
Parameters
| Parameter | Type | Description |
|---|---|---|
fieldName | string | The attribute key name to manage. |
Return Value
Returns a tuple [value, setValue]:
| Index | Type | Description |
|---|---|---|
0 | string | The current value of the attribute (empty string if not set). |
1 | Function | Setter function to update the attribute value. Signature: (newValue: string) => void. |