Vue Storefront is now Alokai! Learn More
RegisterCustomer

RegisterCustomer

Implements RegisterCustomer Unified Method.

Source

import { getNormalizers } from "@alokai/connect/integration-kit";

import { defineApi } from "@vsf-enterprise/unified-api-bigcommerce";

export const registerCustomer = defineApi.registerCustomer(async (context, args) => {
  const { email, firstName, lastName, password } = args;
  const { normalizeCustomer } = getNormalizers(context);

  const { api } = await context.getApiClient();
  const user = await api.createCustomer({
    accepts_product_review_abandoned_cart_emails: false,
    custom_fields: [],
    email: email,
    first_name: firstName,
    last_name: lastName,
    password: password,
  });

  return {
    customer: normalizeCustomer(user),
  };
});