Skip to main content

useAddAddress

NameTypeDescription
isEditAddressBooleanIs the address being edited
formDataObjectForm data ( eg: email,phone,firstname,lastname )
updateFormDataFunctionUpdates the form data
updateFormFunctionUpdates the form
statesListArrayList of states
countriesListFnFunctionList of countries
addNewAddressFunctionAdds a new address
isAddAddressLoadingBooleanLoading 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 });