How to get custom data in Shopify Cart & Checkout Validation Function.

Topic summary

A developer initially struggled to retrieve custom rule data from a database within Shopify Cart & Checkout Validation Functions, since these functions don’t support direct API requests—unlike Liquid templates.

Solution Found:

Context:
The app validates carts based on admin-defined rules (quantity/amount criteria) and restricts checkout when conditions are met. Server-side enforcement via Shopify Functions is required.

Status: Resolved—the original poster successfully implemented the solution and is now helping another developer with the same issue via direct message.

Summarized with AI on November 1. AI used: claude-sonnet-4-5-20250929.

I am new to Shopify app development and have created an app with the following features:

  • Admins can define rules to validate the cart based on quantity and amount.
  • If a rule is enabled and its criteria are met, the checkout button will be restricted, preventing users from proceeding.

As per Shopify’s documentation, Shopify Functions must be implemented for cart and checkout validation to enforce these rules on the server side. However, I am unable to retrieve rule data from the database, as Shopify Functions do not support API requests.

In Liquid, we can simply call an API to fetch data, but that approach does not work here.

If anyone knows an alternative way to retrieve and use rule data within Shopify Functions, please help.
Thanks in advance!

were you able to get custom data from DB?

yes Irzum i have get it.

can you help me out in it, am trying to do the same thing, get data from the server by calling an api

Yes of course,
To pass your database data to the cart and checkout validation function, you need to use metafields.
Refer to Shopify’s official guide here: https://shopify.dev/docs/apps/build/custom-data
If you have any questions, feel free to ask!

thanks, i just dm you, can you please look into it thanks.