Nera – Async Lottery Tickets WP Registry grade A-. Low-severity findings · 1 findingWP RegistryLow-severity findings · 1 findingOpen the reportA-
Install
Upload it under Plugins → Add New Plugin → Upload Plugin, then activate.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/nera-marketing/nera-lottery-async-tickets/releases/download/v1.0.6/nera-lottery-async-tickets-1.0.6.zipQueues Lottery for WooCommerce ticket creation and confirmation through WooCommerce Action Scheduler so checkout completes without synchronous ticket post creation.
Description
This extension removes synchronous LFW checkout hooks and runs ticket generation in the background via Action Scheduler group nera-lottery-async-tickets.
Requires: Lottery for WooCommerce, WooCommerce (Action Scheduler).
Feature flag (default off on install):
- Option:
nera_lty_async_enabled— set toyesto enable - Constant:
NERA_LTY_ASYNC_ENABLED— when defined inwp-config.php, overrides the option
If Action Scheduler is unavailable, the plugin leaves original LFW hooks in place and shows an admin notice (fail open).
Enable
-
Activate Nera – Async Lottery Tickets and Lottery for WooCommerce.
-
Enable async mode:
wp option update nera_lty_async_enabled yes --path=/path/to/wordpress
Or in
wp-config.php:define( 'NERA_LTY_ASYNC_ENABLED', true );
-
Configure server cron (see below) to process the queue.
Deployment / cron
Use a real server cron in production; WP-Cron is only a fallback.
Preferred runner (dedicated queue group):
wp action-scheduler run --group=nera-lottery-async-tickets --batch-size=10 --path=/path/to/wordpress
Run every 1–2 minutes with 1–2 concurrent runners max. Ticket generation is DB-heavy; per-product locks limit useful parallelism.
Alternative (runs all due WP cron hooks):
wp cron event run --due-now --path=/path/to/wordpress
Example crontab (every minute):
-
-
-
-
- cd /path/to/wordpress && wp action-scheduler run --group=nera-lottery-async-tickets --batch-size=10 >> /var/log/nera-lty-async.log 2>&1
-
-
-
Recovery
- Admin: WooCommerce order → Actions → “Generate lottery tickets now”
- WP-CLI:
wp nera-lty-async generate-order <order_id> --path=/path/to/wordpress - Watchdog: Hourly Action Scheduler job
nera_lty_watchdog_stuck_ordersre-queues orders stuck in pending/processing for 20+ minutes
Rollback
Disable async mode to restore synchronous LFW behavior:
wp option update nera_lty_async_enabled no
Or remove/unset NERA_LTY_ASYNC_ENABLED from wp-config.php.
Order meta
_nera_lty_ticket_generation_status— pending | processing | created_waiting_payment | completed | retrying | failed | skipped_nera_lty_ticket_generation_attempts_nera_lty_ticket_generation_last_error
B5: Pre-pick ticket numbers (bypasses LFW retry loop)
LFW's get_ticket_numbers() uses a collision-retry loop whose pass rate collapses
exponentially as the pool fills. Orders of 300+ tickets on a pool with existing
placed+held tickets effectively never complete.
B5 pre-populates _lty_lottery_tickets on each order item inside the async
worker's per-product lock, before calling LTY_Order_Handler::create_ticket_for_order_item().
LFW reads this item-meta at class-lty-order-handler.php:199 and skips its loop when
the value is non-empty.
Scope: automatic-ticket products only. Manual-ticket products are skipped so user-chosen numbers flow through LFW unchanged.
LFW version dependency: B5 reads internal LFW post-meta keys
(_lty_formatted_automatic_ticket_numbers, _lty_hold_tickets, _lty_ticket_number_type)
and item-meta (_lty_lottery_tickets). This site will NOT upgrade LFW; this coupling
is intentional and acceptable.
Filter — disable pre-pick per order/item:
add_filter( 'nera_lty_async_prepick_enabled', static function ( $enabled, $order, $item, $product ) { // Return false to fall back to LFW's original slow path for this item. return $enabled; }, 10, 4 );
For example, to disable via mu-plugin for testing:
// wp-content/mu-plugins/disable-prepick.php add_filter( 'nera_lty_async_prepick_enabled', '__return_false' );
Cron recommendation for high-qty orders:
Use a small batch-size so each 1500s runner slot handles at most a few orders:
-
-
-
-
- cd /path/to/wordpress && wp action-scheduler run --group=nera-lottery-async-tickets --batch-size=5 >/dev/null 2>&1
-
-
-
Manual test checklist
- [ ] Plugin activates with LFW + WooCommerce; feature flag defaults off (
wp option get nera_lty_async_enabled→no) - [ ] With flag off: classic checkout still creates tickets synchronously (LFW default)
- [ ] With flag on + cron runner: classic checkout completes quickly; order note “queued”; tickets appear after job runs
- [ ] Checkout Blocks (
woocommerce_store_api_checkout_order_processed) queues job - [ ] Thank you / My Account shows pending message until tickets exist
- [ ] Order reaches configured
lty_settings_lottery_complete_order_statuses→ worker calls confirmation; LFW confirmation email sends once - [ ] Cancel/refund/failed before worker: status
skippedor LFW cleanup still runs for existing tickets - [ ] Admin order action and
wp nera-lty-async generate-orderre-queue failed orders - [ ] Force worker error → retries with backoff notes; final failure emails admin
- [ ] Deactivate Action Scheduler functions (or WooCommerce inactive): admin notice; LFW sync hooks remain
- [ ] HPOS on/off: order meta and watchdog query still work
- [ ] REST API order (when LFW REST creation not prevented): queues via
woocommerce_after_order_object_save - [ ] Manual + automatic ticket products; instant-win lottery (results delayed until job completes)
- [ ] Load spot-check: parallel checkouts complete; Action Scheduler backlog drains without duplicate ticket numbers
Changelog
1.0.0
- Initial release: async enqueue, worker, locks, watchdog, WP-CLI, admin recovery.
- B1: Raise Action Scheduler runner time limit to 1500s (configurable via NERA_LTY_ASYNC_TIME_LIMIT).
- B2: Shutdown handler releases locks and re-queues order on AS time-limit kill or fatal.
- B3: schedule_retry() uses as_get_scheduled_actions(status=pending) to avoid false-positive dedupe on in-progress actions.
- B4: Watchdog checks STATUS_RETRYING in addition to pending/processing.
- B5: Pre-pick ticket numbers inside per-product lock before calling LFW; bypasses get_ticket_numbers() retry loop; lifts effective per-order cap from ~200 to product max (50k).
Releases
6 releases. Each count is every asset in that release; expand a row for the breakdown.