Skip to main content

useAddress

NameTypeDescription
addressListArrayList of addresses
userObjectShopify user object
selectAddressFunctionSelects an address
addNewAddressFunctionAdds a new address
formattedAddressListArrayFormatted address list
addressSelectLoadingBooleanLoading state of the address select
defaultAddressIDStringDefault address id
openAddAddressFunctionOpens the add address modal
isAddressModalVisibleBooleanIs the address modal visible
toggleAddressModalFunctionToggles the address modal
setAddressModalVisibleFunctionSets the address modal visible
openAddressModalFunctionOpens the address modal
closeAddressModalFunctionCloses the address modal

Usage:


import { useAddress } from '@appmaker-xyz/shopify';

const AddressDisplay = ({
attributes = {},
onPress,
blockData,
onAction,
coreDispatch,
}) => {
const {
addressList,
defaultAddressID,
openAddAddress,
isAddressModalVisible,
toggleAddressModal,
setAddressModalVisible,
openAddressModal,
selectAddress,
addressSelectLoading,
} = useAddress({
onAction,
});
};

To set selected address as default address, pass setDefault as true in the second param of selectAddress function Make sure to pass the second param as an object.

 selectAddress(addressData, { setDefault: true });