Auctions for WooCommerceAuctions for WooCommerce
Buy Now
View Demo
  • Getting Started

    • Introduction
    • Quick Start
    • Features
    • Installation
    • First-Time Setup
    • Onboarding Tour
  • Admin Guide

    • Admin Overview
    • Dashboard
    • All Auctions
    • Add / Edit Auction
    • Bids
    • Reports
    • Events
    • Wallet
    • Disputes
    • Blocked Users
    • Fraud Detection
    • Tools (Import / Export)
    • Settings
    • Design Studio
    • Pending Review
    • Audit Log
  • Auction Mechanics

    • Auction Types
    • Bidding Engine
    • Anti-Sniping
    • Bid Increments
    • Reserve & Buy Now
    • Auto-Relist
    • Watchlist
  • Customer Experience

    • Customer Overview
    • My Auctions
    • My Wallet
    • Withdrawal
    • Single Auction Page
    • Notifications
  • Wallet & Payments

    • Wallet System
    • Auto-Charge
    • Stripe Connect
    • Monetization Fees
  • Multi-Vendor & Integrations

    • Multi-Vendor Compatibility
    • Twilio SMS
    • Firebase Push
    • Two-Factor Auth
    • Captcha
    • Social Login
    • Subscription Gate
    • Elementor & Gutenberg
  • Premium Features

    • Smart Features
    • Psychology Triggers
    • Gamification
    • Fraud Detection
    • Compliance
    • Social Sharing
    • Email Notifications
  • Developer

    • REST API
    • Hooks & Filters
    • JS Events
    • Database Schema
    • Shortcodes
    • Options Reference
    • WP-CLI
  • Help

    • Troubleshooting
    • FAQ
    • Glossary
    • Changelog
Support
Buy Now
View Demo
  • Getting Started

    • Introduction
    • Quick Start
    • Features
    • Installation
    • First-Time Setup
    • Onboarding Tour
  • Admin Guide

    • Admin Overview
    • Dashboard
    • All Auctions
    • Add / Edit Auction
    • Bids
    • Reports
    • Events
    • Wallet
    • Disputes
    • Blocked Users
    • Fraud Detection
    • Tools (Import / Export)
    • Settings
    • Design Studio
    • Pending Review
    • Audit Log
  • Auction Mechanics

    • Auction Types
    • Bidding Engine
    • Anti-Sniping
    • Bid Increments
    • Reserve & Buy Now
    • Auto-Relist
    • Watchlist
  • Customer Experience

    • Customer Overview
    • My Auctions
    • My Wallet
    • Withdrawal
    • Single Auction Page
    • Notifications
  • Wallet & Payments

    • Wallet System
    • Auto-Charge
    • Stripe Connect
    • Monetization Fees
  • Multi-Vendor & Integrations

    • Multi-Vendor Compatibility
    • Twilio SMS
    • Firebase Push
    • Two-Factor Auth
    • Captcha
    • Social Login
    • Subscription Gate
    • Elementor & Gutenberg
  • Premium Features

    • Smart Features
    • Psychology Triggers
    • Gamification
    • Fraud Detection
    • Compliance
    • Social Sharing
    • Email Notifications
  • Developer

    • REST API
    • Hooks & Filters
    • JS Events
    • Database Schema
    • Shortcodes
    • Options Reference
    • WP-CLI
  • Help

    • Troubleshooting
    • FAQ
    • Glossary
    • Changelog
Support
  • Getting Started

    • Introduction
    • Quick Start
    • Feature Catalog
    • Installation
    • First-Time Setup
    • Onboarding Tour
  • Admin Guide

    • Admin Overview
    • Dashboard
    • All Auctions
    • Add / Edit Auction
    • Bids
    • Reports
    • Events
    • Wallet (Admin)
    • Disputes
    • Blocked Users
    • Fraud Detection
    • Tools
    • Settings
    • Design Studio
    • Pending Review
    • Audit Log
  • Auction Mechanics

    • Auction Types
    • Bidding Engine
    • Anti-Sniping (Soft Close)
    • Bid Increments
    • Reserve & Buy Now
    • Auto-Relist
    • Watchlist
  • Customer Experience

    • Customer Experience Overview
    • My Auctions
    • My Wallet
    • Withdrawal
    • Single Auction Page
    • Customer Notifications
  • Wallet & Payments

    • Wallet System
    • Wallet Auto-Charge
    • Stripe Connect
    • Monetization
  • Multi-Vendor & Integrations

    • Multi-Vendor Compatibility
    • Twilio SMS
    • Firebase (Push Notifications)
    • Two-Factor Authentication
    • Captcha
    • Social Login
    • Subscription Gate
    • Elementor & Gutenberg
  • Premium Features

    • Smart Features
    • Psychology Triggers
    • Gamification
    • Fraud Detection
    • Compliance
    • Social Sharing
    • Email Notifications
  • Developer

    • REST API
    • Hooks & Filters
    • JavaScript Events
    • Database Schema
    • Shortcodes
    • Options Reference
    • WP-CLI
  • Help

    • Troubleshooting
    • FAQ
    • Glossary
    • Changelog

JavaScript Events

The plugin's front-end emits DOM CustomEvents for every major bidding interaction. Listen and react to integrate with your own scripts.

Conventions

  • All events dispatch on document (bubble up — listen wherever)
  • Event prefix: wkafw:*
  • All payloads in event.detail

Event reference

Bid lifecycle

document.addEventListener('wkafw:bid_placed', (e) => {
  console.log('Bid:', e.detail);
  // { auctionId, bidId, amount, userId, placedAt }
});

document.addEventListener('wkafw:bid_failed', (e) => {
  console.log('Failed:', e.detail);
  // { auctionId, error: 'wkafw_bid_below_increment', message }
});

document.addEventListener('wkafw:outbid', (e) => {
  // user was outbid
  // { auctionId, newHighAmount, newHighBidder }
});

Auction state changes

document.addEventListener('wkafw:auction_started', (e) => {
  // scheduled → active
});

document.addEventListener('wkafw:auction_ended', (e) => {
  // ended (closed)
});

document.addEventListener('wkafw:auction_extended', (e) => {
  // anti-snipe extension fired
  // { auctionId, newEndDate, extensionSeconds }
});

Watchlist

document.addEventListener('wkafw:watch_added', (e) => {
  // { auctionId, userId }
});

document.addEventListener('wkafw:watch_removed', (e) => {
  // { auctionId, userId }
});

Polling

document.addEventListener('wkafw:poll_tick', (e) => {
  // every poll cycle
  // { auctionId, currentPrice, bidCount, secondsLeft, watchersCount }
});

document.addEventListener('wkafw:poll_started', (e) => {
  // polling activated
});

document.addEventListener('wkafw:poll_stopped', (e) => {
  // polling stopped (auction ended or dormant)
});

Wallet

document.addEventListener('wkafw:wallet_balance_changed', (e) => {
  // { newBalance, delta, reference }
});

UI

document.addEventListener('wkafw:countdown_color_change', (e) => {
  // { auctionId, oldColor, newColor }
});

document.addEventListener('wkafw:confetti', (e) => {
  // confetti burst started
});

Programmatic dispatch

The plugin exposes a global window.wkafw for programmatic interaction:

// Place a bid programmatically
window.wkafw.placeBid({
  auctionId: 123,
  amount: 5550.00,
  onSuccess: (bid) => console.log('Bid:', bid),
  onError: (err) => console.error('Error:', err),
});

// Toggle watchlist
window.wkafw.toggleWatch(123);

// Get current auction state
const state = window.wkafw.getAuctionState(123);
// { currentPrice, bidCount, secondsLeft, ... }

// Force a poll refresh
window.wkafw.refreshAuction(123);

// Get user's wallet balance
window.wkafw.getWalletBalance().then(balance => {
  console.log(balance);
});

Custom integrations

Show a custom toast on outbid

document.addEventListener('wkafw:outbid', (e) => {
  myCustomToast({
    title: 'Outbid!',
    body: `New high: $${e.detail.newHighAmount}`,
    action: { label: 'Bid again', url: `#auction-${e.detail.auctionId}` },
  });
});

Audio cues

const bidSound = new Audio('/path/to/bid.mp3');
const winSound = new Audio('/path/to/win.mp3');

document.addEventListener('wkafw:bid_placed', () => bidSound.play());
document.addEventListener('wkafw:auction_ended', (e) => {
  if (e.detail.youWon) winSound.play();
});

React-style integration

function useAuction(auctionId) {
  const [state, setState] = useState(window.wkafw.getAuctionState(auctionId));

  useEffect(() => {
    const handler = (e) => {
      if (e.detail.auctionId === auctionId) {
        setState(prev => ({ ...prev, ...e.detail }));
      }
    };
    document.addEventListener('wkafw:poll_tick', handler);
    return () => document.removeEventListener('wkafw:poll_tick', handler);
  }, [auctionId]);

  return state;
}

Server-sent events (SSE)

For very-low-latency real-time updates (instead of polling), the plugin can fall back to SSE if your server supports it:

const sse = new EventSource('/wp-json/wkafw/v1/stream/auction/123');
sse.addEventListener('bid_placed', (e) => {
  const bid = JSON.parse(e.data);
  console.log('SSE bid:', bid);
});

SSE auto-disabled by default (most shared hosting blocks it). Enable via:

update_option( 'wkafw_sse_enabled', 'yes' );

Polling configuration

The polling interval is controlled by:

window.wkafw.config = {
  pollIntervalNormal: 30,    // seconds
  pollIntervalEndgame: 3,    // seconds (last 2 minutes)
  endgameThreshold: 120,     // seconds (when to switch to fast polling)
  dormantThreshold: 1800,    // seconds (no bids = stop polling)
};

Override programmatically (before any auction page renders):

window.wkafwSettings = window.wkafwSettings || {};
window.wkafwSettings.pollIntervalNormal = 60; // slower polling

Debugging

Enable verbose logging:

localStorage.setItem('wkafw:debug', '1');

Then watch the browser console for every event, poll, and AJAX request.

Related

  • Hooks & Filters → — server-side equivalents
  • REST API → — for off-site JS
  • Builders → — block / widget reference
Prev
Hooks & Filters
Next
Database Schema