Question:
Wix API returns empty custom fields in orders , even though it has valid value.
Product:
Wix Headless API
@wix/ecom
What are you trying to achieve:
I am trying to generate a report from my customer of his order, I have a pick up date, which is custom field.
I added this field in checkout form, and I can see it in orders in wix dashboard.
However when I fetch via wix-api, the value is missing and I get an empty array.
What have you already tried:
Tried reading documentation and searched in forums, but could not find a solution.
Additional information:
This is a code snippet.
import { orders } from “@wix/ecom”;
import { ApiKeyStrategy, createClient } from “@wix/sdk”;
import moment from “moment-timezone”;
import type { NextApiRequest, NextApiResponse } from ‘next’;
const myWixClient = createClient({
auth: ApiKeyStrategy({
apiKey: process.env.WIX_API_KEY || ‘’,
siteId: process.env.SITE_ID || ‘’,
accountId: process.env.ACCOUNT_ID || ‘’,
}),
modules: {
orders,
},
});
const ordersData = await myWixClient.orders.searchOrders({
search: {
filter: {
$and: [
{ createdDate: { $gte: formattedStartDate } },
{ createdDate: { $lte: formattedEndDate } }
]
}
},
});