Storefront API CustomerCreate when customer accounts are disabled

Storefront API CustomerCreate when customer accounts are disabled

GIEDRE_KAVALIUN
Shopify Partner
1 0 0

Hi,

I encountered this problem when trying to add a customer email with Storefront API. Customer accounts are disabled in the store but customer contact data is added in the checkout or by filling the form in the bottom of the page: https://linenfox.com.

However when trying to add customer email using the Storefront API with Graphql query like this

mutation {
    customerCreate( input: {
         email: "customer@email.com",
         password: "customerpassword",
         acceptsMarketing: true
    }) {
      userErrors {
          field
          message
    }
    customer {
          id
     }
}}

response from the API is like this {"data":{"customerCreate":null},"errors":[{"message":"Customer accounts are disabled.","locations":[{"line":2,"column":23}],"path":["customerCreate"]}]}

If I query the API without the password then the the API returns an error that input object is invalid. 

Is there a way to add a customer email to the store using the Storefront API when customer accounts are disabled?

Thank you.

Replies 2 (2)

Alex
Shopify Staff
1561 81 342

customerCreate exists to create customer accounts seeing how it takes a password input. The form on the bottom of the page I assume (the site isn't currently loading) is a mailing list sign up and the email on the checkout field can be populated with the checkoutCreate mutation and its applicable CheckoutCreateInput.

Remember this API is meant to emulate a storefront, you won't be able to behave as if you're an admin API client using this API. You can't create products either for example. customerCreate is meant to simulate a customer signing up on the storefront, so it makes sense that this only creates customers with accounts provided that's enabled, and you wouldn't be able to do this on the storefront with that feature turned off using the storefront API.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

diaz_philip
Shopify Partner
1 0 0

Hi @GIEDRE_KAVALIUN ,

 

We are on both the same page. So, I am confident to provide you the precise answer. It happens to me the same. The solution is your settings>checkout customer is currently set to don't use account on checkout. Make it sure switch it to optional or required to make this work.

 

Cheers 🙂