useAddress
Name | Type | Description |
---|---|---|
addressList | Array | List of addresses |
user | Object | Shopify user object |
selectAddress | Function | Selects an address |
addNewAddress | Function | Adds a new address |
formattedAddressList | Array | Formatted address list |
addressSelectLoading | Boolean | Loading state of the address select |
defaultAddressID | String | Default address id |
openAddAddress | Function | Opens the add address modal |
isAddressModalVisible | Boolean | Is the address modal visible |
toggleAddressModal | Function | Toggles the address modal |
setAddressModalVisible | Function | Sets the address modal visible |
openAddressModal | Function | Opens the address modal |
closeAddressModal | Function | Closes 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 });