Examples
Pagination, localized content, the order lifecycle, credits, storefront reads.
Paginated query#
const customers = getDropCoreAdmin().store.customers;
customers.where({ email: QueryObject.equalTo('alice@example.com') });
customers.limit(50);
customers.orderBy({ created_at: 'desc' });
await customers.load();
while (customers.items.length < customers['count']) {
await customers.loadMore();
}
Localized content document#
const store = getDropCoreAdmin().store;
const article = await store.content.document('articles', 'hello-world');
await article.load();
await article.set('en', { title: 'Hello world' });
await article.update('cs', { title: 'Ahoj světe' });
Order lifecycle#
const proc = getDropCoreProcess();
const { id } = await proc.order.make({ /* OrderInitEntity */ });
await proc.order.update(id, { customer: { email: 'a@b.c' } });
await proc.order.finalize(id, { /* extra fields */ });
// or cancel:
await proc.order.cancel(id, 'duplicate');
Pushing credits#
await getDropCorePromo().credits.push('user-123', 500, { record: 'topup' });
const balance = await getDropCorePromo().credits.value('user-123');
Public storefront read#
const pub = getDropCorePublic();
const store = await pub.store.get({ mask: ['name', 'locales'] });
const product = await pub.slug.get('/products/widget', { locale: 'en' });
const articles = await pub.content.list('articles', {
locale: 'en',
query: { published: QueryObject.equalTo(true) },
limit: 10,
order_by: { published_at: 'desc' },
});