useAddAddress
Name | Type | Description |
---|---|---|
isEditAddress | Boolean | Is the address being edited |
formData | Object | Form data ( eg: email,phone,firstname,lastname ) |
updateFormData | Function | Updates the form data |
updateForm | Function | Updates the form |
statesList | Array | List of states |
countriesListFn | Function | List of countries |
addNewAddress | Function | Adds a new address |
isAddAddressLoading | Boolean | Loading state of the add address |
Usage:
import { useAddAddress } from '@appmaker-xyz/shopify';
const ShopifyAddAddressWrapper = ({
pageData,
attributes,
BlocksView,
innerBlocks,
blockData,
BlockItem,
onAction,
...props
}) => {
const {
addNewAddress,
updateForm,
formData,
statesList,
countriesListFn,
isAddAddressLoading,
isEditAddress,
} = useAddAddress({
onAction,
address: blockData?.address,
});
};
To set address as default address, pass setDefault
as true in the second param of addNewAddress function
addNewAddress(formData, { setDefault: true });