From 290d0c626dc87e432faab4bdc2130655c7ae70eb Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Wed, 14 Oct 2026 10:20:08 +0200 Subject: [PATCH 01/11] Add doc for RL public sharing --- .../containers/requisition-list-form.mdx | 3 + .../containers/requisition-list-grid.mdx | 3 + .../containers/requisition-list-header.mdx | 12 +- .../share-requisition-list-content.mdx | 27 ++- .../containers/shared-requisition-list.mdx | 48 ++++- .../requisition-list/dictionary.mdx | 21 +- .../requisition-list/functions.mdx | 197 +++++++++++++++++- .../dropins-b2b/requisition-list/index.mdx | 3 + .../dropins-b2b/requisition-list/styles.mdx | 2 + 9 files changed, 305 insertions(+), 11 deletions(-) diff --git a/src/content/docs/dropins-b2b/requisition-list/containers/requisition-list-form.mdx b/src/content/docs/dropins-b2b/requisition-list/containers/requisition-list-form.mdx index 3301ee0bf..063dabb20 100644 --- a/src/content/docs/dropins-b2b/requisition-list/containers/requisition-list-form.mdx +++ b/src/content/docs/dropins-b2b/requisition-list/containers/requisition-list-form.mdx @@ -47,3 +47,6 @@ await provider.render(RequisitionListForm, { })(block); ``` + diff --git a/src/content/docs/dropins-b2b/requisition-list/containers/requisition-list-grid.mdx b/src/content/docs/dropins-b2b/requisition-list/containers/requisition-list-grid.mdx index e76cc24d6..52db8f07f 100644 --- a/src/content/docs/dropins-b2b/requisition-list/containers/requisition-list-grid.mdx +++ b/src/content/docs/dropins-b2b/requisition-list/containers/requisition-list-grid.mdx @@ -52,3 +52,6 @@ await provider.render(RequisitionListGrid, { })(block); ``` + diff --git a/src/content/docs/dropins-b2b/requisition-list/containers/requisition-list-header.mdx b/src/content/docs/dropins-b2b/requisition-list/containers/requisition-list-header.mdx index d6f3b861d..5770b1632 100644 --- a/src/content/docs/dropins-b2b/requisition-list/containers/requisition-list-header.mdx +++ b/src/content/docs/dropins-b2b/requisition-list/containers/requisition-list-header.mdx @@ -24,7 +24,7 @@ The `RequisitionListHeader` container provides the following configuration optio | `onAlert` | `function` | No | Callback function to handle alert notifications when alerts are displayed. | | `enrichConfigurableProducts` | `function` | No | Enriches the configurable products contained in requisition list items. Takes an array of items and returns the same array with configured product data attached. | | `currentCustomerEmail` | `string` | No | Email address of the currently authenticated customer. When provided, this user is excluded from the list of selectable share recipients inside the share modal. | -| `routeSharedRequisitionList` | `(relativeUrl: string) => string` | No | Called with the relative share URL to format the final share link. The URL is built as `/?requisition_id=`, using the `requisition_list_share_storefront_path` store configuration (default: `customer/requisition-list-sharing`). Sharing is available only when `requisition_list_sharing_enabled` is `true`. Use this callback to prepend the domain, modify the path, or apply custom formatting. By default, the relative URL is used as-is. Example: `(url) => window.location.origin + url` for absolute URLs, or `(url) => url` to keep relative URLs. | +| `routeSharedRequisitionList` | `(relativeUrl: string) => string` | No | Called with the relative share URL to format the final share link. The URL is built as `/?requisition_id=`, using the `requisition_list_share_storefront_path` store configuration (default: `customer/requisition-list-sharing`). Sharing is available only when `requisition_list_sharing_enabled` is `true`. Use this callback to prepend the domain, modify the path, or apply custom formatting. By default, the relative URL is used as-is. Example: `(url) => window.location.origin + url` for absolute URLs, or `(url) => url` to keep relative URLs. For public lists, the URL uses `requisition_list_public_share_storefront_path` instead, and sharing is available only when `requisition_list_public_sharing_enabled` is `true`. | @@ -49,3 +49,13 @@ await provider.render(RequisitionListHeader, { })(block); ``` + diff --git a/src/content/docs/dropins-b2b/requisition-list/containers/share-requisition-list-content.mdx b/src/content/docs/dropins-b2b/requisition-list/containers/share-requisition-list-content.mdx index 03081a092..b13064cef 100644 --- a/src/content/docs/dropins-b2b/requisition-list/containers/share-requisition-list-content.mdx +++ b/src/content/docs/dropins-b2b/requisition-list/containers/share-requisition-list-content.mdx @@ -11,15 +11,18 @@ import Term from '@components/Term.astro'; The `ShareRequisitionListContent` container renders the share UI for a requisition list. You can share by email (select company colleagues as recipients) or by copy link (generate a URL recipients use to import the list). +For public lists, set `isPublic` to `true`. The container then shows a free-text email field for any recipient and a reusable public link. Recipients do not need an account, and they preview the list and add items to a cart instead of importing it. + ## Configuration | Parameter | Type | Req? | Description | |---|---|---|---| -| `requisitionListUid` | `string` | Yes | UID of the requisition list to share. The container calls [`shareRequisitionListByToken`](/dropins-b2b/requisition-list/functions/#sharerequisitionlistbytoken) to build the copy-link URL and passes this UID to `onSubmit` for the email flow. | +| `requisitionListUid` | `string` | Yes | UID of the requisition list to share. For company shares, the container calls [`shareRequisitionListByToken`](/dropins-b2b/requisition-list/functions/#sharerequisitionlistbytoken) to build the copy-link URL. For public shares, it calls [`getPublicRequisitionListToken`](/dropins-b2b/requisition-list/functions/#getpublicrequisitionlisttoken) instead. The container passes this UID to `onSubmit` for the email flow. | +| `isPublic` | `boolean` | No | Set to `true` to share a public list. The container replaces the company-user selector with a free-text field for comma-separated email addresses, validates each address, and enforces `requisition_list_public_share_max_recipients`. It also builds the link from `requisition_list_public_share_storefront_path` and the owner's public token. Defaults to `false`. | | `isSubmitting` | `boolean` | Yes | Controls the submitting state of the form. Set to `true` while the share-by-email request is in progress to disable the submit button and prevent duplicate submissions. | -| `onSubmit` | `(customerUids: string[]) => Promise \| null>` | Yes | Called when the user clicks **Submit** with the selected recipient UIDs. Return `null` on success or an array of error objects on failure. Typically wraps [`shareRequisitionListByEmail`](/dropins-b2b/requisition-list/functions/#sharerequisitionlistbyemail). | +| `onSubmit` | `(customerUids: string[]) => Promise \| null>` | Yes | Called when the user clicks **Submit** with the selected recipient UIDs. Return `null` on success or an array of error objects on failure. Typically wraps [`shareRequisitionListByEmail`](/dropins-b2b/requisition-list/functions/#sharerequisitionlistbyemail). When `isPublic` is `true`, the array contains the entered email addresses instead of user UIDs, and the callback typically wraps [`sharePublicRequisitionList`](/dropins-b2b/requisition-list/functions/#sharepublicrequisitionlist). | | `currentCustomerEmail` | `string` | No | Email address of the currently authenticated customer. When provided, the container excludes this address from the selectable company recipients so the sender cannot share with themselves. | | `routeSharedRequisitionList` | `(relativeUrl: string) => string` | No | Receives the relative share URL (for example, `/customer/requisition-list-sharing?requisition_id=` from `requisition_list_share_storefront_path`) and returns the final URL to display. Use this to convert the relative URL to an absolute URL. If you omit this prop, the container uses the relative URL as-is. Example: `(relativeUrl) => window.location.origin + relativeUrl` | @@ -53,6 +56,24 @@ await provider.render(ShareRequisitionListContent, { Replace `YOUR_LIST_UID` with the UID of the list you want to share. +To share a public list, pass `isPublic: true` and wrap `sharePublicRequisitionList`: + +```js +import { sharePublicRequisitionList } from '@dropins/storefront-requisition-list/api.js'; + +await provider.render(ShareRequisitionListContent, { + requisitionListUid: 'YOUR_LIST_UID', + isPublic: true, + isSubmitting: false, + onSubmit: async (emails) => { + return sharePublicRequisitionList('YOUR_LIST_UID', emails); + }, + routeSharedRequisitionList: (relativeUrl) => window.location.origin + relativeUrl, +})(block); +``` + +The list must already be public. If it is not, the share request returns a `NOT_PUBLIC` error. + diff --git a/src/content/docs/dropins-b2b/requisition-list/containers/shared-requisition-list.mdx b/src/content/docs/dropins-b2b/requisition-list/containers/shared-requisition-list.mdx index 02063d4ce..cbd5f1f3e 100644 --- a/src/content/docs/dropins-b2b/requisition-list/containers/shared-requisition-list.mdx +++ b/src/content/docs/dropins-b2b/requisition-list/containers/shared-requisition-list.mdx @@ -10,13 +10,22 @@ import TableWrapper from '@components/TableWrapper.astro'; The `SharedRequisitionList` container handles the recipient side of requisition list sharing. When a shopper opens a shared link with a `requisition_id` token, render this container to show a read-only preview. The shopper imports the list only after they choose the import action. +The container supports two kinds of links: + +- **Company share links** (default): the recipient signs in as a company user and can import the list into their account. +- **Public share links**: set `isPublic` to `true`. Guests and signed-in customers can preview the list and add items to a cart. They cannot import the list. + ## Configuration | Parameter | Type | Req? | Description | |---|---|---|---| -| `token` | `string` | Yes | The share token from the URL query parameter (for example, `?requisition_id=`). The container loads preview data with [`getSharedRequisitionList`](/dropins-b2b/requisition-list/functions/#getsharedrequisitionlist) on mount and calls [`importSharedRequisitionList`](/dropins-b2b/requisition-list/functions/#importsharedrequisitionlist) only when the recipient confirms import. | +| `token` | `string` | Yes | The share token from the URL query parameter (for example, `?requisition_id=`). The container loads preview data with [`getSharedRequisitionList`](/dropins-b2b/requisition-list/functions/#getsharedrequisitionlist) on mount and calls [`importSharedRequisitionList`](/dropins-b2b/requisition-list/functions/#importsharedrequisitionlist) only when the recipient confirms import. When `isPublic` is `true`, the container loads the preview with [`getPublicRequisitionList`](/dropins-b2b/requisition-list/functions/#getpublicrequisitionlist) instead, and the token is the owner's public share token. | +| `isPublic` | `boolean` | No | Set to `true` to render a public share preview. The container shows the owner's name, the product name and image for each item, item checkboxes, and pagination. It offers **Add All to Cart** and **Add Selected to Cart** actions instead of the import action. Defaults to `false`. | +| `getCartId` | `() => string \| Promise` | No | Returns the ID of the cart that receives the items. Required for public previews to enable the add-to-cart buttons. Return the guest or customer cart ID, creating a cart first if none exists. If you omit it, the buttons stay disabled. The container then calls [`addPublicRequisitionListItemsToCart`](/dropins-b2b/requisition-list/functions/#addpublicrequisitionlistitemstocart) with this ID. | +| `onCartUpdated` | `() => void \| Promise` | No | Called after the add-to-cart request finishes. Use it to refresh the mini cart or other cart UI. | +| `routeProduct` | `(urlKey: string, sku: string) => string` | No | Builds the product detail page (PDP) URL for an item. The `sku` is the resolved variant SKU shown in the SKU column, so configurable items link to the correct variant. The product name and image render as links only when this callback and the item's `url_key` are both available. Otherwise they render as plain text and an image. | | `routeRequisitionList` | `(uid: string, listName: string) => string \| void` | No | Called with the imported list UID and name after a successful import. Use this callback to navigate to the list detail page. If you omit it, the container shows an inline success alert instead. Pass a stable reference (module-level function or `useCallback` with no dependencies) because the container captures this callback at mount time. | @@ -67,3 +76,40 @@ await provider.render(SharedRequisitionList, { }, })(block); ``` + +### Render a public share preview + +To let guests and customers preview a public list and add items to a cart, create a page at the path set in `requisition_list_public_share_storefront_path`. Pass `isPublic: true` and a `getCartId` callback. The following example uses the Cart drop-in to reuse the shopper's cart or create a guest cart. + +```js +import { render as provider } from '@dropins/storefront-requisition-list/render.js'; +import { SharedRequisitionList } from '@dropins/storefront-requisition-list/containers/SharedRequisitionList.js'; +import * as cart from '@dropins/storefront-cart/api.js'; + +const params = new URLSearchParams(window.location.search); +const token = params.get('requisition_id') ?? ''; + +await provider.render(SharedRequisitionList, { + token, + isPublic: true, + getCartId: async () => { + const data = await cart.getCartData(); + if (data?.id) return data.id; + const guestCart = await cart.createGuestCart(); + return guestCart?.id; + }, + onCartUpdated: () => console.log('Items added to cart'), + routeProduct: (urlKey, sku) => + `/products/${encodeURIComponent(urlKey)}/${encodeURIComponent(sku)}`, +})(block); +``` + +The important lines are: + +- `isPublic: true` switches the container from the company flow to the public flow. +- `getCartId` returns the cart that receives the items. A public list does not belong to the shopper, so the container cannot look up a cart for them. +- `routeProduct` turns each item's `url_key` and variant SKU into a product page link. Change the path to match your storefront routes. + + diff --git a/src/content/docs/dropins-b2b/requisition-list/dictionary.mdx b/src/content/docs/dropins-b2b/requisition-list/dictionary.mdx index f826ce66b..d2f7a5cfb 100644 --- a/src/content/docs/dropins-b2b/requisition-list/dictionary.mdx +++ b/src/content/docs/dropins-b2b/requisition-list/dictionary.mdx @@ -77,7 +77,8 @@ Below are the default English (`en_US`) strings provided by the **Requisition Li "label": "Description", "updateTitle": "Update Requisition List", "createTitle": "Create Requisition List", - "addToRequisitionList": "Add to Requisition List" + "addToRequisitionList": "Add to Requisition List", + "markPublicLabel": "Make this requisition list public" }, "RequisitionListSelector": { "addToNewRequisitionList": "Add to New Requisition List", @@ -120,7 +121,15 @@ Below are the default English (`en_US`) strings provided by the **Requisition Li "errorPreview": "Unable to load the shared requisition list.", "skuHeader": "SKU", "qtyHeader": "Qty", - "optionsHeader": "Options" + "optionsHeader": "Options", + "addToCart": "Add All to Cart", + "addSelectedToCart": "Add Selected to Cart", + "addingToCart": "Adding to Cart...", + "cartSuccess": "Items added to your cart.", + "cartError": "Unable to add items to your cart.", + "selectItem": "Select item", + "previousPage": "Previous", + "nextPage": "Next" }, "RequisitionListView": { "actionDelete": "Delete", @@ -148,6 +157,9 @@ Below are the default English (`en_US`) strings provided by the **Requisition Li "copyToListConfirm": "Copy to requisition list", "actionRename": "Rename", "actionDeleteList": "Delete List", + "actionMakePublic": "Make Public", + "actionMakePrivate": "Make Private", + "statusPublic": "Public", "actionShare": "Share", "shareDisabledReason": "You cannot share an empty requisition list.", "shareDisabledNoCompany": "Sharing is available only for company account users.", @@ -182,12 +194,17 @@ Below are the default English (`en_US`) strings provided by the **Requisition Li "emailInstruction": "Select below the email addresses of the people with whom you'd like to share your list. Your name, email address and the details of your list will be shared with recipients. You can send your list with multiple recipients. Please note only registered users will be able to import lists.", "emailLabel": "Email addresses", "emailPlaceholder": "Select company users", + "publicEmailPlaceholder": "recipient1@example.com, recipient2@example.com", + "publicEmailInstruction": "Enter below the email addresses of the people with whom you'd like to share your list, separated by commas. Your name, email address and the details of your list will be shared with recipients. You can send your list with multiple recipients.", + "publicLinkInstruction": "Copy the link below and send it to people with whom you'd like to share your list.", + "invalidEmail": "Enter valid email addresses.", "submitLabel": "Submit", "linkInstruction": "Copy the link below and send it to people with whom you'd like to share your list. Please note only registered users will be able to import lists.", "copyLink": "Copy Link", "linkCopied": "Copied!", "loadingUsers": "Loading users...", "loadingLink": "Generating share link...", + "sharingInProgress": "Sharing your list...", "noUsersAvailable": "No company colleagues available to share with.", "usersLoadError": "Unable to load company users. Please try again.", "maxRecipientsValidation": "You can select up to {max} recipients.", diff --git a/src/content/docs/dropins-b2b/requisition-list/functions.mdx b/src/content/docs/dropins-b2b/requisition-list/functions.mdx index b3be844b1..95256a2b6 100644 --- a/src/content/docs/dropins-b2b/requisition-list/functions.mdx +++ b/src/content/docs/dropins-b2b/requisition-list/functions.mdx @@ -13,7 +13,7 @@ import TableWrapper from '@components/TableWrapper.astro'; import Link from '@components/Link.astro'; import { Aside } from '@astrojs/starlight/components'; -The Requisition List drop-in provides **18 API functions** for managing requisition lists and their items, including creating lists, adding/removing products, managing list metadata, and sharing lists with company colleagues. +The Requisition List drop-in provides **22 API functions** for managing requisition lists and their items, including creating lists, adding/removing products, managing list metadata, sharing lists with company colleagues, and sharing public lists with anyone by email or link. @@ -37,6 +37,10 @@ The Requisition List drop-in provides **18 API functions** for managing requisit | [`importSharedRequisitionList`](#importsharedrequisitionlist) | Imports a shared requisition list into the current customer's account using a share token. | | [`shareRequisitionListByEmail`](#sharerequisitionlistbyemail) | Shares a requisition list with one or more company users by email. | | [`shareRequisitionListByToken`](#sharerequisitionlistbytoken) | Generates a shareable token for a requisition list. | +| [`getPublicRequisitionList`](#getpublicrequisitionlist) | Retrieves a public requisition list by its share token, without requiring authentication. | +| [`getPublicRequisitionListToken`](#getpublicrequisitionlisttoken) | Retrieves the owner's reusable public share token for a requisition list. | +| [`sharePublicRequisitionList`](#sharepublicrequisitionlist) | Emails the public share link of a requisition list to any email addresses. | +| [`addPublicRequisitionListItemsToCart`](#addpublicrequisitionlistitemstocart) | Adds items from a public requisition list to a guest or customer cart. | @@ -103,7 +107,8 @@ Creates a new requisition list with the name and description provided for the lo ```ts const createRequisitionList = async ( name: string, - description?: string + description?: string, + isPublic?: boolean ): Promise ``` @@ -113,6 +118,7 @@ const createRequisitionList = async ( |---|---|---|---| | `name` | `string` | Yes | The display name for the new requisition list. This helps users identify and organize their lists (for example, `Office Supplies Q1`, `Weekly Inventory Restock`). | | `description` | `string` | No | An optional text description providing additional context about the requisition list's purpose or contents (for example, `Monthly recurring orders for maintenance supplies`). | +| `isPublic` | `boolean` | No | Marks the new list as public so that it can be shared with anyone by link or email. Use it only when `requisition_list_public_sharing_enabled` is `true` in the store configuration. | @@ -298,7 +304,7 @@ Does not emit any drop-in events. ### Returns -Returns `void`. +Returns [`StoreConfig`](#storeconfig). If the configuration query returns errors or the request fails, the function returns the default configuration, in which every feature flag is off. If the backend does not support `is_requisition_list_active` or `company_enabled`, it returns `false`. ## updateRequisitionList @@ -311,7 +317,8 @@ const updateRequisitionList = async ( description?: string, pageSize?: number, currentPage?: number, - enrichConfigurableProducts?: (items: Item[]) => Promise + enrichConfigurableProducts?: (items: Item[]) => Promise, + isPublic?: boolean ): Promise ``` @@ -325,6 +332,7 @@ const updateRequisitionList = async ( | `pageSize` | `number` | No | The number of items to return per page in the updated requisition list response. | | `currentPage` | `number` | No | The page number for pagination (1-indexed) in the updated requisition list response. | | `enrichConfigurableProducts` | `items: Item[]` | No | See function signature above | +| `isPublic` | `boolean` | No | Sets whether the list is public. Pass `true` to make the list public and `false` to make it private. Use it only when `requisition_list_public_sharing_enabled` is `true` in the store configuration. To set it, pass `undefined` for the optional parameters that come before it. | @@ -622,6 +630,166 @@ interface ShareRequisitionListByTokenResult { } ``` +## getPublicRequisitionList + +Retrieves a public requisition list by its share token. Unlike [`getSharedRequisitionList`](#getsharedrequisitionlist), the caller does not need to be signed in or belong to a company. Anyone who has the token can view the list. Returns the owner's display name alongside the read-only requisition list data, including the product name, thumbnail, and `url_key` for each item. + +```ts +const getPublicRequisitionList = async ( + token: string, + currentPage?: number, + pageSize?: number, + enrichConfigurableProducts?: (items: Item[]) => Promise +): Promise +``` + + + +| Parameter | Type | Req? | Description | +|---|---|---|---| +| `token` | `string` | Yes | The public share token from the URL (for example, from `?requisition_id=`). | +| `currentPage` | `number` | No | The page number for pagination (1-indexed). Defaults to page 1 if not specified. | +| `pageSize` | `number` | No | The number of items to return per page. | +| `enrichConfigurableProducts` | `(items: Item[]) => Promise` | No | Optional function to enrich configurable product items with variant data before returning. | + + + +### Events + +Does not emit any drop-in events. + +### Returns + +Returns `SharedRequisitionListResult | null`. Returns `null` if the token is valid but the requisition list cannot be resolved. Throws an error if the server returns GraphQL errors, for example when the token is invalid or the list is no longer public. + +```ts +interface SharedRequisitionListResult { + senderName: string; + requisitionList: RequisitionList; +} +``` + +## getPublicRequisitionListToken + +Retrieves the signed-in owner's reusable public share token for a requisition list. The same token is used for the share link, the share email, and the add-to-cart action. Use it to build a public share link or to reopen the sharing modal. + +```ts +const getPublicRequisitionListToken = async ( + requisitionListUid: string +): Promise +``` + + + +| Parameter | Type | Req? | Description | +|---|---|---|---| +| `requisitionListUid` | `string` | Yes | The unique identifier of the requisition list to get the public share token for. | + + + +### Events + +Does not emit any drop-in events. + +### Returns + +Returns `GetPublicRequisitionListTokenResult`. The function never throws. It catches GraphQL and network errors and returns them in `errorMessage`. The `token` is `null` when the list has no public token yet, for example when it is not marked public. + +```ts +interface GetPublicRequisitionListTokenResult { + token: string | null; + errorMessage: string | null; +} +``` + +## sharePublicRequisitionList + +Emails the public share link of a requisition list to any email addresses. Unlike [`shareRequisitionListByEmail`](#sharerequisitionlistbyemail), recipients do not need to be registered company users. Only the list owner can call this function. + +```ts +const sharePublicRequisitionList = async ( + requisitionListUid: string, + emails: string[] +): Promise +``` + + + +| Parameter | Type | Req? | Description | +|---|---|---|---| +| `requisitionListUid` | `string` | Yes | The unique identifier of the public requisition list to share. | +| `emails` | `string[]` | Yes | The email addresses that receive the share link. | + + + +### Events + +Does not emit any drop-in events. + +### Returns + +Returns `null` when the share succeeds. Otherwise returns an array of `PublicRequisitionListUserError` objects, for example with the code `NOT_PUBLIC` when the list is not marked public. Throws an error if the server returns GraphQL errors. If the response is malformed, the array contains an entry with the code `UNKNOWN_ERROR`. + +```ts +interface PublicRequisitionListUserError { + code: string; + message: string; +} +``` + +## addPublicRequisitionListItemsToCart + +Adds items from a public requisition list to a cart. The function identifies the list by its share token and the cart by an explicit cart ID. Unlike [`addRequisitionListItemsToCart`](#addrequisitionlistitemstocart), it does not require authentication, so the cart can belong to a guest or a signed-in customer. + +```ts +const addPublicRequisitionListItemsToCart = async ( + token: string, + cartId: string, + itemUids?: string[] +): Promise +``` + + + +| Parameter | Type | Req? | Description | +|---|---|---|---| +| `token` | `string` | Yes | The public share token of the requisition list. | +| `cartId` | `string` | Yes | The ID of the cart that receives the items. | +| `itemUids` | `string[]` | No | The UIDs of the list items to add. Omit this parameter to add every item in the list. | + + + +### Events + +Does not emit any drop-in events. + +### Returns + +Returns `AddPublicRequisitionListItemsToCartResult`. An empty `userErrors` array means every item was added. Possible error codes include `NOT_PUBLIC`, `INVALID_TOKEN`, and `OUT_OF_STOCK`. Throws an error if the server returns GraphQL errors. If the response is malformed, `userErrors` contains an entry with the code `UNKNOWN_ERROR`. + +```ts +interface AddPublicRequisitionListItemsToCartResult { + cart: { id: string } | null; + userErrors: PublicRequisitionListUserError[]; +} +``` + +The following example adds only the selected items to a cart: + +```js +import { addPublicRequisitionListItemsToCart } from '@dropins/storefront-requisition-list/api.js'; + +const { userErrors } = await addPublicRequisitionListItemsToCart( + 'abc123token', + cartId, + ['item-uid-1', 'item-uid-2'] +); + +if (userErrors.length > 0) { + userErrors.forEach(({ code, message }) => console.error(code, message)); +} +``` + ## Data Models The following data models are used by functions in this drop-in. @@ -639,6 +807,27 @@ interface RequisitionList { items_count: number; items: Item[]; page_info?: PageInfo; + is_public?: boolean; +} +``` + +### StoreConfig + +The `StoreConfig` object is returned by the following functions: [`getStoreConfig`](#getstoreconfig). + +```ts +interface StoreConfig { + is_requisition_list_active?: string; + company_enabled?: boolean; + requisition_list_sharing_enabled?: boolean; + requisition_list_share_max_recipients?: number | null; + requisition_list_share_storefront_path?: string | null; + configurable_thumbnail_source?: string | null; + requisition_list_public_sharing_enabled?: boolean; + requisition_list_public_share_link_validity_days?: number | null; + requisition_list_public_share_max_recipients?: number | null; + requisition_list_public_share_storefront_path?: string | null; + [key: string]: any; } ``` diff --git a/src/content/docs/dropins-b2b/requisition-list/index.mdx b/src/content/docs/dropins-b2b/requisition-list/index.mdx index cf04c2be9..c3312d5d5 100644 --- a/src/content/docs/dropins-b2b/requisition-list/index.mdx +++ b/src/content/docs/dropins-b2b/requisition-list/index.mdx @@ -32,6 +32,9 @@ The following table provides an overview of the Adobe Commerce features that the | GraphQL API integration | | | Share requisition list via email | | | Share requisition list via link and import | | +| Mark requisition lists as public | | +| Share public requisition lists via email or link with signed-in or guest recipients | | +| Add public requisition list items to a guest or customer cart | |