Create a Cart and Cart Item with Custom Fields in a Commerce Store
Create a cart with a cart item using custom fields for a buyer or guest user in your Commerce store.
Custom fields are optional and must be previously defined for the WebCart and CartItem sObjects. See Create Custom Fields. Field-level security rules from the shopper profile are applied to the WebCart and CartItem custom fields. The rules are applied for registered shoppers and for the guest shopper profile.
To create a cart with custom fields, call createCart(webstoreId, cartInput). Specify your custom fields using the customFields property of cartInput. The type for customFields is List<SObject>, where the sObject is a WebCart.
Then, to add an item to the cart, call addItemToCart(webstoreId, effectiveAccountId, activeCartOrId, cartItemInput, currencyIsoCode). You can specify custom fields using the customFields property of cartItemInput. Again, the type of customFields is List<SObject>, but the sObject must be a CartItem.
In this scenario we assume that further customization sets a custom field within the Cart Calculate API flow onto the cart item for further use.