website logo
Navigate through spaces
⌘K
OVERVIEW
ORDER MANAGEMENT (OMS)
SHIPPING - SETUP
Shipping Methods
Shipping Zones
Shipping Method Setup Examples
TAXES - Setup
Tax Automation with Stripe Tax
Tax Automation with Avalara
CONTENT MANAGEMENT (CMS)
DATA
CUSTOMER LIFETIME REVENUE
Customer Lifetime Revenue Explanation
Customer Lifetime Revenue and Purchase Likelihood
Recency Frequency and Monetary
CLR and RFM Data Table Glossary
RFM and CLR in the Hub
LOOKER
Modifying a Dashboard
Timestamp differences between Looker, OMS and Shopify
How to create custom calculations in Looker
Looker and Shopify data models
Custom fields
How to 'Save and Schedule' reports
Creating Custom Reports or Look
Looks vs Dashboards
Login Looker FAQ
Looker Glossary
SEGMENT EVENT TRACKING
What are event tracking
Adding Tracking
What is the Tracking Plan?
The Chord Tracking Plan
The Shopify Tracking Plan
Event Tracking FAQ
EVENT UPDATES PAGE
Email Subscription Payment Event Update
Product Feed Setup
Getting Segment to Production
Consent Management
Installing in Next.js
Installing in Gatsby
Integrations
👩‍💻Developer Tools
Using Chord with Shopify
Docs powered by archbee 

useUser

13min

The useUser hook returns the current user and functions for managing a Shopify customer account. The customer must have an active authentication session (see useAuth) for these methods to work.

Example

useUser


Returns

The useUser hook returns an object with these properties:

Property

Description

user

An object representing the current user.

status

A string indicating whether the user's profile is currently being fetched.

createUserAddress

A function that adds a new address to the Shopify customer's address book.

loadUser

A function that loads information about the current order's associated user.

modifyUserAddress

A function that updates an address in the Shopify customer's address book.

modifyUserDefaultAddress

A function that updates which address is marked as the default address in the Shopify customer's address book.

removeUserAddress

A function that removes an address from the Shopify customer's address book.

Functions

createUserAddress

The createUserAddress function adds a new address to the Shopify customer's address book.

Arguments:

createUserAddress(address, isDefaultAddress)

Argument

Type

Description

address

Object

New address.

address.address1?

String

(Optional) First line of address.

address.address2?

String

(Optional) Second line of address.

address.city?

String

(Optional) City of address.

address.company?

String

(Optional) Company of address.

address.country?

String

(Optional) Country of address.

address.firstName?

String

(Optional) First name of address.

address.lastName?

String

(Optional) Last name of address.

address.phone?

String

(Optional) Phone number of address.

address.province?

String

(Optional) Province or state of address.

address.zip?

String

(Optional) Zip code of address.

isDefaultAddress?

Boolean

(Optional) Boolean indicating whether this address should be the default address for the user. Defaults to false.

Returns:

Promise<void>: A Promise that resolves when the user address has been added.

Example:

createUserAddress


loadUser

The loadUser function reloads the current user. This is automatically called on every page load and with every other useUser method.

Arguments:

None.

Returns:

Promise<void>: A Promise that resolves when the user object has been added to Redux.

Example:

loadUser


modifyUserAddress

The modifyUserAddress function updates an address in the Shopify customer's address book.

Arguments:

modifyUserAddress(addressId, address, isDefaultAddress)

Argument

Type

Description

addressId

String

Address ID.

address

Object

Modified address.

address.address1?

String

(Optional) First line of address.

address.address2?

String

(Optional) Second line of address.

address.city?

String

(Optional) City of address.

address.company?

String

(Optional) Company of address.

address.country?

String

(Optional) Country of address.

address.firstName?

String

(Optional) First name of address.

address.lastName?

String

(Optional) Last name of address.

address.phone?

String

(Optional) Phone number of address.

address.province?

String

(Optional) Province or state of address.

address.zip?

String

(Optional) Zip code of address.

isDefaultAddress?

Boolean

(Optional) Boolean indicating whether this address should be the default address for the user. Defaults to false.

Returns:

Promise<void>: A Promise that resolves when the user address has been modified.

Example:

modifyUserAddress


modifyUserDefaultAddress

The modifyUserDefaultAddress function updates which address is marked as the default address in the Shopify customer's address book.

Arguments:

modifyUserDefaultAddress(addressId)

Argument

Type

Description

addressId

String

Address ID.

Returns:

Promise<void>: A Promise that resolves when the user address has been modified.

Example:

modifyUserDefaultAddress


removeUserAddress

The removeUserAddress function removes an address from the Shopify customer's address book.

Arguments:

removeUserAddress(addressId)

Argument

Type

Description

addressId

String

Address ID.

Returns:

Promise<void>: A Promise that resolves when the user address has been removed.

Example:

removeUserAddress




Updated 03 Mar 2023
Did this page help you?
Yes
No
PREVIOUS
useTranslate
NEXT
Guides
Docs powered by archbee 
useUser