Skip to main content

Overview

Cart Utilities provide administrative functions for cart maintenance, analytics, and cleanup operations. These internal functions help maintain system performance and provide insights into customer behavior. Location: convex/customers/cartUtils.ts

Cleanup Abandoned Carts

daysOld
number
required
Age threshold in days
const result = await convex.mutation(api.customers.cartUtils.cleanupAbandonedCarts, {
  daysOld: 30
});

Get Cart Analytics

storeId
Id<'stores'>
Optional store filter
const analytics = await convex.query(api.customers.cartUtils.getCartAnalytics, {
  storeId: "j123456789"
});
{
  "totalCarts": 150,
  "totalItems": 450,
  "totalValue": 2250.75,
  "averageCartValue": 15.00,
  "averageItemsPerCart": 3.0,
  "topProducts": [
    {
      "productId": "p123456789",
      "productName": "Pizza Margherita",
      "quantityInCarts": 25,
      "timesAdded": 18
    }
  ]
}
These are internal administrative functions for system maintenance and analytics.