SetCustomerEmail
Implements SetCustomerEmail
Unified Method.
Source
import { defineApi, getCartId, query } from "@vsf-enterprise/unified-api-magento";
import type { Cart } from "@vsf-enterprise/unified-api-magento/ecommerceTypes";
import { getNormalizers } from "@vsf-enterprise/unified-api-magento/udl";
export const setCustomerEmail = defineApi.setCustomerEmail(async (context, args) => {
const { email } = args;
const cartId = getCartId(context);
const { normalizeCart } = getNormalizers(context);
const data = await query(
context.api.setGuestEmailOnCart({
cart_id: cartId,
email,
}),
);
return normalizeCart(data.setGuestEmailOnCart?.cart as Cart);
});