diff --git a/src/content/docs/dropins/checkout/checkout-functions.mdx b/src/content/docs/dropins/checkout/checkout-functions.mdx index 79870f964..7f0d0041f 100644 --- a/src/content/docs/dropins/checkout/checkout-functions.mdx +++ b/src/content/docs/dropins/checkout/checkout-functions.mdx @@ -11,9 +11,38 @@ import OptionsTable from '@components/OptionsTable.astro'; This topic provides the details and instructions you need to use the functions provided by the Checkout dropin. +## authenticateCustomer + +The `authenticateCustomer` function manages the authentication state of a customer, either by fetching customer data using the [`getCustomer`](#getcustomer) function when authenticated or resetting the customer data when not authenticated. + +```ts +export const authenticateCustomer: () => Promise +``` + +### Returns + +The function does not return any value explicitly; it performs side effects by fetching data and logging errors. + +### Usage + +See the following example for usage details: + +```ts +import { authenticateCustomer } from '@/checkout/api/authenticateCustomer'; + +async function authenticate() { + try { + await authenticateCustomer(); + console.log('Customer authenticated successfully.'); + } catch (error) { + console.error('Error authenticating customer:', error); + } +} +``` + ## estimateShippingMethods -This function fetches and displays available shipping methods based on a customer's address information. It can take a combination of fields as `criteria`: country, region, region identifier, and postal code. +The `estimateShippingMethods` function fetches and displays available shipping methods based on a customer's address information. It can take a combination of fields as `criteria`: country, region, region identifier, and postal code. It uses a utility function to call an [`estimateShippingMethods`](https://developer.adobe.com/commerce/webapi/graphql/schema/cart/mutations/estimate-shipping-methods/) mutation. @@ -660,4 +689,26 @@ setShippingMethodsOnCart([ method_code: 'flatrate', }, ]); +``` + +## synchronizeCheckout + +The `synchronizeCheckout` function synchronizes the checkout state with the current cart information. It ensures that the checkout process is properly initialized, reset, or updated based on the cart data. It uses the [`getCart`](#getcart) function to fetch the necessary cart details. + +```ts +export const synchronizeCheckout: () => void +``` + +### Returns + +The function does not return any value explicitly; it performs side effects by fetching data and logging errors. + +### Usage + +See the following example for usage details: + +```ts +import { synchronizeCheckout } from '@/checkout/api/synchronizeCheckout'; + +synchronizeCheckout('IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG'); ``` \ No newline at end of file