Skip to main content

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​

ParameterTypeDescription
fieldNamestringThe attribute key name to manage.

Return Value​

Returns a tuple [value, setValue]:

IndexTypeDescription
0stringThe current value of the attribute (empty string if not set).
1FunctionSetter function to update the attribute value. Signature: (newValue: string) => void.