Skip to main content

⚙️ GetPoliciesOptions Type

The getPolicies() function accepts an optional configuration object that lets you control which policies are fetched and how.

type GetPoliciesOptions = {
language?: string;
customHandles?: Record<string, string>;
policyTypes?: PolicyType[];
debug?: boolean;
};

🌍 language?: string

Sets the desired locale for fetching native policies.

language: "fr";

Shopify will attempt to return the translated body and url fields based on the language.


🛠️ customHandles?: Record<string, string>

A map of custom policy types to Shopify Page handles.

caution

Steps to Use customHandles

  1. Create a New Page in Shopify Admin:

    • Go to Online Store > Pages under the Sales Channels section.
  2. Set the URL Handle:

    • Scroll to the Search engine listing preview section at the bottom of the page.
    • Ensure the URL handle matches the string you provide in customHandles.

This ensures that the custom policy types map correctly to the pages you create.

This lets you fetch legal content not available via the native Storefront API — such as:

  • legalNotice
  • cookiePolicy
  • termsOfSale
customHandles: {
customPolicy: "page-url-handle",
legalNotice: "mentions-legales",
termsOfSale: "conditions-generales-de-vente"
}

These will override native policies of the same type.


🔠 policyTypes?: PolicyType[]

Controls which policies to return.

By default, this includes:

["privacyPolicy", "refundPolicy", "shippingPolicy", "termsOfService"];

This is merged with the keys in customHandles.

Use this if you want to restrict the types returned:

policyTypes: ["privacyPolicy", "legalNotice"];

🐞 debug?: boolean

Enables console logs for warnings or overrides.

Useful for debugging missing policies or unexpected Shopify behavior.

debug: true;

✅ Next: Result Types →