Skip to content
Tutorials Center
My learning

Topics

Lesson 38 of 39 ยท Practice and Review

WooCommerce Interview Questions

Prepare for a WooCommerce developer interview: concise answers on architecture, hooks, HPOS, checkout, payments, security, performance and scaling, with two runnable stand-ins.

A WooCommerce interview mixes concept questions ("what is HPOS?") with judgment questions ("a customer reports double charges; where do you look first?"). Good answers are short, name the right API, and show that you know the trade-offs. Interviewers also listen for what you would not do, such as editing core files or reading order data with get_post_meta().

This page collects common questions grouped by topic, each linked to the lesson that teaches the idea in depth. WooCommerce cannot run on this site, so the code is read-only, and the two runnable examples at the end are plain-PHP stand-ins that demonstrate the reasoning, not WooCommerce code. Cover the answers, say yours aloud, then compare. Some details depend on the WooCommerce version, so the answers say so where it matters.

flowchart TD
    Q["Interview topics"] --> A["Architecture<br/>and hooks"]
    Q --> B["Data<br/>CRUD and HPOS"]
    Q --> C["Cart and checkout"]
    Q --> D["Payments<br/>and security"]
    Q --> E["Performance<br/>and scaling"]

Five areas that cover most WooCommerce interviews.

Architecture and hooks

What is WooCommerce, technically?

A WordPress plugin. It adds product, order and coupon data, a cart and checkout, REST endpoints and an admin interface on top of WordPress. It relies on WordPress for users, hooks, options, the REST API and the admin. See How WooCommerce Is Built.

Where do you put customizations?

In your own plugin (or a child theme for presentation), never in WooCommerce core or in the parent theme. Core changes are overwritten on update. Use hooks for behavior and template overrides for markup.

Action versus filter?

An action lets you run code at a point and returns nothing. A filter receives a value, must return a (possibly changed) value, and is how you alter data such as prices or field lists. Forgetting to return from a filter is a classic bug. See The WooCommerce Hook Map.

How do you find the right hook?

Look in the template that renders the area (hooks are called with do_action()), search the WooCommerce source for the function that outputs it, or use a debugging plugin that lists hooks on the page. Then check the priority: to remove a core callback, you need the same hook, callback and priority.

How do you override a template safely?

Copy only the file you need into yourtheme/woocommerce/, keep the structure, and watch the version comment: the status report warns about outdated copies. Prefer a hook when the change is small, because a hook cannot go out of date the way a copied file does. See Template Overrides and Plugin Templates.

What does WC() return?

The main WooCommerce instance (a singleton). Through it you reach the cart, session, customer and similar services: WC()->cart, WC()->session. These objects may be null in contexts such as admin pages or REST requests, so check before use.

Data and HPOS

Why use CRUD classes instead of post meta?

Product, order and coupon classes (WC_Product, WC_Order, WC_Coupon) hide where data lives. They validate, track changes, fire hooks and let WooCommerce swap storage. Direct update_post_meta() calls skip all of that and break when storage changes. See CRUD Classes and Data Stores.

What is HPOS?

High-Performance Order Storage stores orders in dedicated tables instead of the posts and postmeta tables. It scales better because order queries use proper columns and indexes. Plugins must declare compatibility and must use the order API. See Orders and High-Performance Order Storage.

How do you declare HPOS compatibility?

On before_woocommerce_init, call FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ) (guard with class_exists). The declaration is a promise; it does not make code compatible by itself.

PHP
add_action( 'before_woocommerce_init', function (): void {
    if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
        \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
    }
} );

What is wrong with get_post_meta( $order_id, '_billing_email' )?

Under HPOS the order is not a post, so the call returns nothing. Use $order->get_billing_email() or $order->get_meta( 'key' ), and $order->save() after writing.

Product, variable product and variation?

A simple product has one price and stock. A variable product groups variations; each variation is a child object with its own SKU, price and stock, chosen by attribute values. See Variations, Attributes and Taxonomies.

How would you query orders?

With wc_get_orders( $args ), which works with both storage modes. Avoid WP_Query and raw SQL on order data. Request IDs only ('return' => 'ids') when you do not need full objects.

Cart and checkout

How does WooCommerce identify a cart line?

By a cart item key: a hash of product ID, variation ID, variation attributes and cart item data. The same inputs merge into one line; different custom data makes a new line. See The Cart and Session.

How do you apply a custom price?

Hook woocommerce_before_calculate_totals, loop over $cart->get_cart() and call set_price() on each $item['data']. Calculate from the stored base price so repeated runs do not stack. Remember that price filters on single product pages need separate handling. See Dynamic Pricing, Fees and Discounts.

How do you add a checkout field?

In the classic checkout, filter woocommerce_checkout_fields, validate in woocommerce_checkout_process, and save to the order in a checkout order hook. Block checkout uses a different mechanism (the additional checkout fields API and Store API extensions). See Classic Checkout Fields and Validation and Cart and Checkout Blocks Extensibility.

Classic checkout or block checkout?

New stores default to the block-based checkout. Classic shortcode hooks do not all apply to blocks, so a plugin that targets both needs two integrations. Say which one your client uses before promising a feature.

When is stock reduced?

When the order reaches a stock-reducing state (usually payment complete or processing, depending on flow). Reducing in two places causes double deductions, so use WooCommerce's functions and check the order's recorded flag. See Order Statuses and the Order Lifecycle.

Payments and security

What does process_payment() return?

An array: result (success or failure) and redirect. On success the gateway calls payment_complete() (direct flows) or leaves the order pending or on hold and waits for confirmation (redirect flows). See Building a Payment Gateway.

The customer was charged twice. Where do you look?

At idempotency: did a retry or double submit send two charge requests with different keys? Then at webhooks: are duplicate events handled once? Then at the order notes and logs. Fix with a stable idempotency key and an event ID store.

How do you verify a webhook?

Compute an HMAC of the raw request body with the shared secret, compare it with the signature header using hash_equals(), reject old timestamps if the provider supplies them, and remember event IDs to ignore replays. See Webhooks, Signatures and Payment Security.

How do you reduce PCI scope?

Never let card numbers touch your server: use hosted fields or a redirect to the provider so you only handle tokens. Never log secrets or full payloads.

Which security habits do you apply to every extension?

Capability checks (manage_woocommerce) for admin actions, nonces for forms, sanitize input (wc_clean, sanitize_text_field), escape output (esc_html, esc_attr), $wpdb->prepare() for SQL, and a real permission_callback on every REST route. Never trust a price or total sent by the browser. See Security for WooCommerce Extensions.

Performance and scaling

What typically slows a WooCommerce store?

Heavy product queries, too many autoloaded options, big session tables, plugins that run queries in loops (N+1), uncached remote calls on every page and unindexed meta queries. Measure with a profiler such as Query Monitor before guessing. See Performance and Scaling Large Stores.

How do you avoid the N+1 problem on order lists?

Fetch the needed rows in one batched query and index them by ID, or use APIs that preload related data. Do not call a database-hitting function inside a loop over hundreds of orders.

Why not rely on WP-Cron for store jobs?

WP-Cron fires on page visits and has no retry, claim or visibility. Action Scheduler (bundled with WooCommerce) stores jobs in tables, supports retries and claims, and shows status in the admin. See Background Processing With Action Scheduler.

What breaks with full-page caching?

Anything user-specific: cart fragments, nonces, mini carts, prices that depend on role. Exclude the cart, checkout and account pages, use the cookies WooCommerce sets for cache bypass, and load personal data with uncached requests.

Two runnable stand-ins

These demonstrate answers given above. They are not WooCommerce code.

PHP Replay guard: handle each event once

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with fgets(STDIN)), it gets the next line from this box.

PHP N+1 versus a batched query

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with fgets(STDIN)), it gets the next line from this box.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why should a plugin avoid get_post_meta() for orders?

    HPOS keeps orders in dedicated tables. The order object works with either storage.
  2. 2. A filter callback forgets to return a value. What happens?

    Filters pass a value along a chain. A missing return passes null to the next callback and to the caller.
  3. 3. Which approach best prevents duplicate webhook processing?

    Providers retry and may deliver twice. Recording event IDs makes handling idempotent.
  4. 4. Why choose Action Scheduler over WP-Cron for store jobs?

    Action Scheduler gives visibility and reliability that plain WP-Cron lacks.

Summary

  • Customize through hooks, template overrides and your own plugin; never edit core.
  • Use CRUD objects and the order API so code survives storage changes such as HPOS.
  • Cart lines are keyed by product, variation and item data; recalculate prices from the base price.
  • Make payments and webhooks idempotent, verify signatures over the raw body, and keep card data off your server.
  • Measure first, remove N+1 queries, use Action Scheduler for background work, and keep personal data out of cached pages.

Next: WooCommerce Cheat Sheet