Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

How to check for logged in status?

Solved

How to check for logged in status?

pmb88
Shopify Partner
5 0 0

I've recently started on a custom checkout extensibility that adds a new text box and edits an attribute. That is working and can see the data changing. Is there a way for it to only show that box if the customer is logged in?

Accepted Solution (1)

sg84
Shopify Partner
1 1 2

This is an accepted solution.

I've done it with the useCustomer hook. Not sure if there is a simpler way.

View solution in original post

Replies 2 (2)

sg84
Shopify Partner
1 1 2

This is an accepted solution.

I've done it with the useCustomer hook. Not sure if there is a simpler way.

pmb88
Shopify Partner
5 0 0

Thank you for the answer.

 

So for example it would be something like this:

 

import {
  reactExtension,
  Banner,
  BlockStack,
  Checkbox,
  Text,
  TextField,
  useApi,
  useApplyAttributeChange,
  useInstructions,
  useTranslate,
  useApplyNoteChange,
  useAttributes,
useCustomer
} from "@shopify/ui-extensions-react/checkout";


function Extension() { 
  const { extension } = useApi();
  const c = useCustomer();
  if(!c){
//do customer only code.
 }

}

I'm new to React.