use Apply Attribute Changehook
Returns a function to mutate the attributes
property of the checkout.
Anchor to useApplyAttributeChangeuse Apply Attribute Change()
UseApplyAttributeChangeGeneratedType
Returns a function to mutate the `attributes` property of the checkout.
(change: AttributeChange) => Promise<AttributeChangeResult>
export function useApplyAttributeChange<
ID extends RenderExtensionPoint = RenderExtensionPoint,
>(): (change: AttributeChange) => Promise<AttributeChangeResult> {
const api = useApi<ID>();
if ('applyAttributeChange' in api) {
return api.applyAttributeChange;
}
throw new ExtensionHasNoMethodError(
'applyAttributeChange',
api.extensionPoint,
);
}
AttributeChange
- type
The type of the `AttributeUpdateChange` API.
"updateAttribute"
- key
Key of the attribute to add or update
string
- value
Value for the attribute to add or update
string
AttributeUpdateChange
Attribute
- key
The key for the attribute.
string
- value
The value for the attribute.
string
export interface Attribute {
/**
* The key for the attribute.
*/
key: string;
/**
* The value for the attribute.
*/
value: string;
}
AttributeChangeResult
AttributeChangeResultSuccess | AttributeChangeResultError
AttributeChangeResultSuccess
The returned result of a successful update to an attribute.
- type
The type of the `AttributeChangeResultSuccess` API.
"success"
export interface AttributeChangeResultSuccess {
/**
* The type of the `AttributeChangeResultSuccess` API.
*/
type: 'success';
}
AttributeChangeResultError
The returned result of an unsuccessful update to an attribute with a message detailing the type of error that occurred.
- type
The type of the `AttributeChangeResultError` API.
"error"
- message
A message that explains the error. This message is useful for debugging. It is **not** localized, and therefore should not be presented directly to the buyer.
string
export interface AttributeChangeResultError {
/**
* The type of the `AttributeChangeResultError` API.
*/
type: 'error';
/**
* A message that explains the error. This message is useful for debugging.
* It is **not** localized, and therefore should not be presented directly
* to the buyer.
*/
message: string;
}