Cron & Background Jobs

Background jobs refresh FX prices, run module reminders, and sync marketplaces. Authenticate with SHOP_TOKEN from shop settings — never expose it in themes or storefront JS.

Authentication

  • Token source: Settings::get('SHOP_TOKEN') (Admin settings)
  • Pass as query ?token=YOUR_SHOP_TOKEN or header X-Cron-Token: YOUR_SHOP_TOKEN
  • Invalid token → HTTP 403
Security: SHOP_TOKEN is for server crontab / backend callers only. Do not reuse it as a storefront CSRF token. See Constants & Variables and Storefront AJAX API.

Core cron — /api/cron.php

ActionPurpose
currency (alias doviz) Refresh product prices driven by FX / gold rates
abandoned-cart Send reminders if the abandoned-cart module is installed

Example:

curl -s "https://example.com/api/cron.php?action=currency&token=YOUR_SHOP_TOKEN"

Module crons

Register 'cron' => 'api/cron.php' in the module's $apiActions, then call:

/api/module.php?m={module}&action=cron&token=YOUR_SHOP_TOKEN

See Create New Module.

Marketplace cron

/api/marketplace.php?action=cron&type=orders|questions&platform=trendyol|hepsiburada|n11&token=...

  • type=orders (default) — pull / sync orders
  • type=questions (alias qna) — sync Q&A
  • Optional send=0 disables pushing stock/price to the marketplace for that run
Scheduling tip: Run currency refresh every 15–60 minutes via server crontab. Marketplace and abandoned-cart jobs can use a similar interval depending on volume.
cURL
# Currency / FX product price refresh
curl -s "https://example.com/api/cron.php?action=currency&token=YOUR_SHOP_TOKEN"

# Same via header
curl -s -H "X-Cron-Token: YOUR_SHOP_TOKEN" \
  "https://example.com/api/cron.php?action=currency"

# Abandoned-cart reminders (module must be installed)
curl -s "https://example.com/api/cron.php?action=abandoned-cart&token=YOUR_SHOP_TOKEN"

# Module cron (example: reviews invite job)
curl -s "https://example.com/api/module.php?m=reviews&action=cron&token=YOUR_SHOP_TOKEN"

# Marketplace order sync (Trendyol)
curl -s "https://example.com/api/marketplace.php?action=cron&type=orders&platform=trendyol&token=YOUR_SHOP_TOKEN"

# Marketplace Q&A sync (Hepsiburada), no stock push to marketplace
curl -s "https://example.com/api/marketplace.php?action=cron&type=questions&platform=hepsiburada&send=0&token=YOUR_SHOP_TOKEN"