This complete WooCommerce Plugin Development tutorial covers 101 topics — from hooks and product/order CRUD to checkout fields, payment gateways, shipping, emails, REST, Blocks, HPOS, security, and release workflows.
Course roadmap
- Introduction to WooCommerce Plugin Development
- What is WooCommerce?
- WooCommerce Architecture
- WooCommerce Plugin Structure
- Creating Your First WooCommerce Plugin
- WooCommerce Plugin File Structure
- WooCommerce Hooks and Filters
- Actions vs Filters in WooCommerce
- WooCommerce Product Hooks
- WooCommerce Cart Hooks
- WooCommerce Checkout Hooks
- WooCommerce Order Hooks
- WooCommerce Customer Hooks
- WooCommerce Admin Hooks
- Creating Custom WooCommerce Settings
- WooCommerce Settings API
- Adding Custom Admin Menus for Woo Plugins
- Adding Custom Product Fields
- Adding Custom Checkout Fields
- Adding Custom Registration Fields
- Saving Custom Field Data in WooCommerce
- Displaying Custom Product Data
- Product CRUD Operations
- WooCommerce Product Types
- Simple Products in WooCommerce
- Variable Products in WooCommerce
- Virtual and Downloadable Products
- Custom Product Types
- WooCommerce Orders
- Order CRUD Operations
- Order Status Management
- Custom Order Status in WooCommerce
- WooCommerce Customers and Users
- Customer Data Management
- WooCommerce Cart
- Custom Cart Fees
- Custom Discounts in WooCommerce
- Dynamic Pricing in WooCommerce
- Coupons and Discount Rules
- WooCommerce Checkout Customization
- Custom Checkout Validation
- Custom Payment Fields
- WooCommerce Payment Gateway Development
- Creating a Custom Payment Gateway
- Stripe Payment Gateway Integration
- PayPal Payment Gateway Integration
- Webhooks and Payment Notifications
- WooCommerce Shipping Methods
- Creating a Custom Shipping Method
- Shipping Rates and Rules
- Tax Configuration and Custom Tax Rules
- WooCommerce Emails
- Creating Custom WooCommerce Emails
- Custom Email Templates
- WooCommerce REST API
- Creating Custom REST API Endpoints for Woo
- WooCommerce API Authentication
- Webhooks Integration in WooCommerce
- AJAX in WooCommerce
- Dynamic Product Updates with AJAX
- WooCommerce Session Management
- WooCommerce Cookies
- WooCommerce Blocks
- Checkout Block Integration
- Cart Block Integration
- WooCommerce HPOS
- HPOS Compatibility
- WooCommerce CRUD Classes
- WooCommerce Database Structure
- Custom Database Tables for Woo Plugins
- $wpdb and WooCommerce
- WooCommerce Reports
- Custom Admin Reports
- Import and Export Products
- CSV Product Import/Export
- File Upload in WooCommerce
- Image and Media Handling in WooCommerce
- WooCommerce Multilingual Compatibility
- WPML Compatibility for Woo Plugins
- WooCommerce Security Best Practices
- Nonces and Permissions in Woo Plugins
- Data Sanitization and Validation
- SQL Injection Prevention
- XSS and CSRF Protection
- WooCommerce Performance Optimization
- Caching and Database Optimization
- WooCommerce Debugging
- Error Handling and Logging
- WordPress Coding Standards for Woo Plugins
- WooCommerce Coding Standards
- Plugin Compatibility Testing
- WordPress and WooCommerce Version Compatibility
- Creating Free and Pro WooCommerce Plugins
- Plugin Licensing and Activation
- Automatic Plugin Updates for Woo Extensions
- WooCommerce Plugin Documentation
- Preparing Woo Plugin for WordPress.org
- Git and SVN Workflow for Woo Plugins
- WooCommerce Plugin Deployment
- WooCommerce Plugin Interview Questions
- Final Project – Complete WooCommerce Plugin Development
1. Introduction to WooCommerce Plugin Development
WooCommerce plugins add store features without editing core. This series covers hooks, products/orders, checkout, payment/shipping, REST, blocks, HPOS, security, and release workflows.
- Learn WooCommerce architecture and hooks first.
- Build product/order/checkout customizations.
- Ship a complete payment or store feature plugin.
Learning path
Plugin bootstrap → hooks
Products/cart/checkout/orders
Payments/shipping/emails
REST/AJAX/blocks/HPOS
Security → final Woo plugin
2. What is WooCommerce?
WooCommerce turns WordPress into a store: products, cart, checkout, payments, shipping, taxes, and customer accounts.
Core pieces
Products → Cart → Checkout → Order → Emails/Fulfillment
3. WooCommerce Architecture
WooCommerce uses WordPress hooks plus its own objects (WC_Product, WC_Order), sessions, and data stores (including HPOS for orders).
Architecture map
WP hooks + Woo hooks
CRUD objects (product/order/customer)
Session/cart
Admin settings + REST/Blocks
4. WooCommerce Plugin Structure
Always verify WooCommerce is active before loading store features. Keep payment/shipping/admin code modular.
Suggested layout
woo-acme/
woo-acme.php
includes/class-plugin.php
includes/class-settings.php
includes/gateways/
includes/shipping/
assets/
5. Creating Your First WooCommerce Plugin
Add a plugin header, check for the `WooCommerce` class, then hook a simple feature.
- Create the plugin folder/file with a header.
- Require WooCommerce (or check class_exists).
- Activate and confirm no fatals.
Bootstrap check
<?php
/**
* Plugin Name: Acme Woo Tools
* Description: First WooCommerce extension.
* Requires Plugins: woocommerce
*/
add_action('plugins_loaded', function () {
if (! class_exists('WooCommerce')) {
return;
}
// boot features
});
6. WooCommerce Plugin File Structure
Split by responsibility: settings, product fields, checkout, gateways, and compatibility layers (HPOS/blocks).
Feature folders
includes/Admin
includes/Checkout
includes/Gateway
includes/Compatibility
languages/
7. WooCommerce Hooks and Filters
Almost every store customization starts with a WooCommerce hook. Prefer hooks over template copies when possible.
Hook example
add_action('woocommerce_thankyou', function ($order_id) {
// post-purchase logic
});
8. Actions vs Filters in WooCommerce
Actions run events (send email, render HTML). Filters change prices, labels, query args, and more.
Filter example
add_filter('woocommerce_product_get_name', function ($name, $product) {
return $name;
}, 10, 2);
9. WooCommerce Product Hooks
Key hooks include `woocommerce_before_single_product`, `woocommerce_single_product_summary`, and loop add-to-cart hooks.
Single product hook
add_action('woocommerce_single_product_summary', function () {
echo '<p class="acme-note">Free shipping over ₹999</p>';
}, 25);
10. WooCommerce Cart Hooks
Use cart hooks for fees, notices, and item meta. Recalculate carefully to avoid loops.
Cart fee hook
add_action('woocommerce_cart_calculate_fees', function ($cart) {
if (is_admin() && ! defined('DOING_AJAX')) return;
$cart->add_fee(__('Handling', 'acme-woo'), 20);
});
11. WooCommerce Checkout Hooks
Classic checkout is hook-rich; block checkout needs Blocks extensibility APIs — support both when possible.
Checkout field filter
add_filter('woocommerce_checkout_fields', function ($fields) {
$fields['billing']['billing_phone']['required'] = true;
return $fields;
});
12. WooCommerce Order Hooks
Order hooks power fulfillments, CRM sync, and custom emails. Always verify order objects/IDs.
Status changed
add_action('woocommerce_order_status_changed', function ($order_id, $from, $to, $order) {
// sync / notify
}, 10, 4);
13. WooCommerce Customer Hooks
Customer hooks help add profile fields, welcome flows, and account dashboard widgets.
Account dashboard
add_action('woocommerce_account_dashboard', function () {
echo '<p>Welcome to your store account.</p>';
});
14. WooCommerce Admin Hooks
Admin hooks let you add meta boxes, columns, and settings tabs without rewriting screens.
Product data tab
add_filter('woocommerce_product_data_tabs', function ($tabs) {
$tabs['acme'] = [
'label' => 'Acme',
'target' => 'acme_product_data',
'class' => [],
];
return $tabs;
});
15. Creating Custom WooCommerce Settings
Register a settings tab/section and save options with WooCommerce settings helpers.
Settings tab filter
add_filter('woocommerce_settings_tabs_array', function ($tabs) {
$tabs['acme'] = 'Acme';
return $tabs;
}, 50);
16. WooCommerce Settings API
Use `woocommerce_admin_fields` style arrays for input types, defaults, and sanitization callbacks.
Settings fields sketch
$settings = [
[
'title' => 'Acme',
'type' => 'title',
'id' => 'acme_title',
],
[
'title' => 'API Key',
'id' => 'acme_api_key',
'type' => 'text',
'default' => '',
],
['type' => 'sectionend', 'id' => 'acme_title'],
];
17. Adding Custom Admin Menus for Woo Plugins
Prefer `add_submenu_page` under `woocommerce` for store tools so merchants find them easily.
Submenu under WooCommerce
add_action('admin_menu', function () {
add_submenu_page(
'woocommerce',
'Acme Tools',
'Acme Tools',
'manage_woocommerce',
'acme-woo-tools',
'acme_render_tools_page'
);
});
18. Adding Custom Product Fields
Use product data hooks + nonces/capabilities, then store values as product meta.
Product field panel
add_action('woocommerce_product_options_general_product_data', function () {
woocommerce_wp_text_input([
'id' => '_acme_subtitle',
'label' => 'Subtitle',
'desc_tip' => true,
'description' => 'Shown under the title',
]);
});
19. Adding Custom Checkout Fields
For block checkout, also implement Blocks field extensibility. Start with classic fields, then add block support.
Add checkout field
add_filter('woocommerce_checkout_fields', function ($fields) {
$fields['billing']['billing_gstin'] = [
'label' => 'GSTIN',
'required' => false,
'class' => ['form-row-wide'],
'priority' => 120,
];
return $fields;
});
20. Adding Custom Registration Fields
Add fields to the registration form, validate them, and save to user meta.
Registration field save
add_action('woocommerce_created_customer', function ($customer_id) {
if (isset($_POST['acme_company'])) {
update_user_meta(
$customer_id,
'acme_company',
sanitize_text_field(wp_unslash($_POST['acme_company']))
);
}
});
21. Saving Custom Field Data in WooCommerce
Save product fields on `woocommerce_process_product_meta`, checkout fields on order create hooks, and registration fields on customer create.
Save product meta
add_action('woocommerce_process_product_meta', function ($post_id) {
$subtitle = isset($_POST['_acme_subtitle'])
? sanitize_text_field(wp_unslash($_POST['_acme_subtitle']))
: '';
update_post_meta($post_id, '_acme_subtitle', $subtitle);
});
22. Displaying Custom Product Data
Escape output and only display values that help shoppers or staff.
Display subtitle
add_action('woocommerce_single_product_summary', function () {
global $product;
$subtitle = $product->get_meta('_acme_subtitle');
if ($subtitle) {
echo '<p class="acme-subtitle">' . esc_html($subtitle) . '</p>';
}
}, 6);
23. Product CRUD Operations
Prefer `wc_get_product` / product objects over raw post updates for compatibility.
Create simple product
$product = new WC_Product_Simple();
$product->set_name('Notebook');
$product->set_regular_price('199');
$product->set_status('publish');
$id = $product->save();
24. WooCommerce Product Types
Core types include simple, variable, grouped, external, and custom types registered by extensions.
Type overview
Simple → one price/SKU
Variable → attributes/variations
Grouped → collection of products
External/Affiliate → off-site buy link
25. Simple Products in WooCommerce
Simple products have one price and inventory track. Most custom fields start here.
Load simple product
$product = wc_get_product($id);
if ($product && $product->is_type('simple')) {
echo $product->get_price();
}
26. Variable Products in WooCommerce
Variable products need attributes and child variations. Test add-to-cart and stock carefully.
Variation tip
Parent: WC_Product_Variable
Children: WC_Product_Variation
Use attribute taxonomies (pa_*) or custom attributes
27. Virtual and Downloadable Products
Virtual products skip shipping. Downloadable products grant file access via order permissions.
Set flags
$product->set_virtual(true);
$product->set_downloadable(true);
$product->set_downloads([
['name' => 'PDF', 'file' => 'https://example.com/file.pdf'],
]);
28. Custom Product Types
Custom types need registration, a product class, and admin UI support.
Register type
add_filter('product_type_selector', function ($types) {
$types['acme_booking'] = 'Booking';
return $types;
});
29. WooCommerce Orders
Orders store line items, totals, customer data, and status history. Use CRUD getters/setters.
Get order
$order = wc_get_order($order_id);
echo $order->get_formatted_order_total();
30. Order CRUD Operations
Useful for imports, custom checkouts, and admin tools. Recalculate totals after changes.
Create order sketch
$order = wc_create_order();
$order->add_product(wc_get_product($product_id), 1);
$order->set_address(['first_name' => 'Asha', 'country' => 'IN'], 'billing');
$order->calculate_totals();
$order->save();
31. Order Status Management
Use `$order->update_status()` so emails/hooks fire correctly.
Update status
$order->update_status('processing', 'Payment confirmed');
32. Custom Order Status in WooCommerce
Register the status and optionally include it in reports/admin order actions.
Register status
add_action('init', function () {
register_post_status('wc-awaiting-shipment', [
'label' => 'Awaiting shipment',
'public' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop('Awaiting shipment (%s)', 'Awaiting shipment (%s)'),
]);
});
33. WooCommerce Customers and Users
`WC_Customer` wraps billing/shipping and account data. Guest orders may not have a user ID.
Customer object
$customer = new WC_Customer(get_current_user_id());
echo $customer->get_billing_email();
34. Customer Data Management
Validate country/state formats and keep GDPR/privacy implications in mind when exporting data.
Update billing
$customer->set_billing_phone('9999999999');
$customer->save();
35. WooCommerce Cart
Cart state lives in session. Guard against null cart in admin contexts.
Cart basics
$cart = WC()->cart;
$cart->add_to_cart($product_id, 1);
echo $cart->get_cart_contents_count();
36. Custom Cart Fees
Add fees inside `woocommerce_cart_calculate_fees` and keep fee logic idempotent.
Conditional fee
add_action('woocommerce_cart_calculate_fees', function ($cart) {
if ($cart->get_subtotal() < 500) {
$cart->add_fee('Small order fee', 30);
}
});
37. Custom Discounts in WooCommerce
Prefer coupons for transparency. Negative fees work but can confuse tax/reporting.
Coupon apply
WC()->cart->apply_coupon('SAVE10');
38. Dynamic Pricing in WooCommerce
Use product price filters and test cart/checkout tax/shipping interactions thoroughly.
Role-based price sketch
add_filter('woocommerce_product_get_price', function ($price, $product) {
if (current_user_can('wholesale_buyer')) {
return (float) $price * 0.9;
}
return $price;
}, 10, 2);
39. Coupons and Discount Rules
Coupons support percent/fixed cart/product discounts, limits, and email restrictions.
Create coupon
$coupon = new WC_Coupon();
$coupon->set_code('WELCOME');
$coupon->set_discount_type('percent');
$coupon->set_amount(10);
$coupon->save();
40. WooCommerce Checkout Customization
Keep required fields clear. For Blocks checkout, plan a separate compatibility path.
Remove field example
add_filter('woocommerce_checkout_fields', function ($fields) {
unset($fields['order']['order_comments']);
return $fields;
});
41. Custom Checkout Validation
Use `woocommerce_checkout_process` and `wc_add_notice(…, 'error')` to block checkout.
Validate GSTIN
add_action('woocommerce_checkout_process', function () {
if (empty($_POST['billing_gstin'])) {
return;
}
$gstin = sanitize_text_field(wp_unslash($_POST['billing_gstin']));
if (strlen($gstin) < 15) {
wc_add_notice('Enter a valid GSTIN.', 'error');
}
});
42. Custom Payment Fields
Render fields in the gateway form, validate on process_payment, and never log sensitive card data.
Security note
Never store raw card PANs
Use payment provider hosted fields/token when possible
PCI scope reduction first
43. WooCommerce Payment Gateway Development
Extend `WC_Payment_Gateway`, register via filter, implement settings + `process_payment`.
Register gateway
add_filter('woocommerce_payment_gateways', function ($gateways) {
$gateways[] = 'WC_Gateway_Acme';
return $gateways;
});
44. Creating a Custom Payment Gateway
Return thank-you redirect on success and handle failures with notices + order notes.
Gateway skeleton
class WC_Gateway_Acme extends WC_Payment_Gateway {
public function __construct() {
$this->id = 'acme';
$this->method_title = 'Acme Pay';
$this->has_fields = false;
$this->init_form_fields();
$this->init_settings();
}
public function process_payment($order_id) {
$order = wc_get_order($order_id);
$order->payment_complete();
return ['result' => 'success', 'redirect' => $this->get_return_url($order)];
}
}
45. Stripe Payment Gateway Integration
Prefer official Stripe plugins when possible; custom builds must handle PaymentIntents + webhook verification.
Integration checklist
1. Create PaymentIntent server-side
2. Confirm on client
3. Verify webhook signature
4. Update order status only after verified events
46. PayPal Payment Gateway Integration
Use REST capture APIs and verify notifications before marking orders paid.
PayPal flow
Create order → approve → capture → webhook/order update
47. Webhooks and Payment Notifications
Verify signatures, make handlers idempotent, and log failures without leaking secrets.
Webhook REST route idea
register_rest_route('acme-pay/v1', '/webhook', [
'methods' => 'POST',
'callback' => 'acme_pay_webhook',
'permission_callback' => '__return_true',
]);
48. WooCommerce Shipping Methods
Shipping methods calculate rates per package. Zones decide which methods appear.
Shipping concepts
Zones → Methods → Rates
Package contents + destination matter
49. Creating a Custom Shipping Method
Register the method and implement `calculate_shipping()` with clear labels/costs.
Shipping method sketch
class WC_Shipping_Acme extends WC_Shipping_Method {
public function calculate_shipping($package = []) {
$this->add_rate([
'id' => $this->id,
'label' => 'Acme Express',
'cost' => 80,
]);
}
}
50. Shipping Rates and Rules
Keep rules readable and test edge cases: free shipping thresholds, mixed packages, and local pickup.
Rule idea
$cost = $package['contents_cost'] >= 999 ? 0 : 70;
51. Tax Configuration and Custom Tax Rules
Tax is jurisdiction-sensitive. Prefer settings/rates over hardcoding unless you fully understand implications.
Tax tip
Use tax classes for special products
Test inclusive vs exclusive display
Don’t bypass WC tax unless required legally
52. WooCommerce Emails
Emails are classes extending `WC_Email`. Trigger them on order/customer events.
Email types
New order, processing, completed
Customer invoice/note
Custom plugin emails
53. Creating Custom WooCommerce Emails
Add your email class via `woocommerce_email_classes` and implement trigger/templates.
Register email class
add_filter('woocommerce_email_classes', function ($emails) {
$emails['WC_Email_Acme_Shipped'] = include __DIR__ . '/emails/class-wc-email-acme-shipped.php';
return $emails;
});
54. Custom Email Templates
Provide templates and allow theme overrides under `woocommerce/emails/`.
Template override path
yourtheme/woocommerce/emails/customer-completed-order.php
or plugin template with locate_template fallback
55. WooCommerce REST API
Core REST routes live under `/wp-json/wc/v3/`. Great for headless and integrations.
Example endpoint
GET /wp-json/wc/v3/products
56. Creating Custom REST API Endpoints for Woo
Namespace your routes and require `manage_woocommerce` or customer ownership checks.
Custom route
add_action('rest_api_init', function () {
register_rest_route('acme-woo/v1', '/ping', [
'methods' => 'GET',
'callback' => fn () => ['ok' => true],
'permission_callback' => fn () => current_user_can('manage_woocommerce'),
]);
});
57. WooCommerce API Authentication
WooCommerce consumer key/secret auth is common for server-to-server integrations. Protect keys.
Auth tip
Use HTTPS only
Store keys in env/secrets manager
Rotate keys when staff leave
58. Webhooks Integration in WooCommerce
WooCommerce can deliver webhooks on CRUD events. Verify inbound webhooks from payment providers.
Woo webhook topics
order.created / order.updated
product.created
customer.created
59. AJAX in WooCommerce
Many cart fragments use Woo AJAX. Custom features should still verify nonces and capabilities.
Custom AJAX action
add_action('wp_ajax_acme_woo_action', 'acme_woo_action');
add_action('wp_ajax_nopriv_acme_woo_action', 'acme_woo_action');
60. Dynamic Product Updates with AJAX
Return JSON fragments and refresh cart fragments with WooCommerce events when needed.
JSON response
wp_send_json_success(['price_html' => $product->get_price_html()]);
61. WooCommerce Session Management
`WC()->session` persists customer cart state. Use for temporary UI choices, not sensitive secrets.
Session set/get
WC()->session->set('acme_gift_wrap', 'yes');
$wrap = WC()->session->get('acme_gift_wrap');
62. WooCommerce Cookies
WooCommerce sets cookies for cart/session. Be careful with caching plugins and cookie-dependent pages.
Caching tip
Do not full-page-cache cart/checkout for all users
Vary cache by customer cookie where required
63. WooCommerce Blocks
Block checkout is becoming default. Plan compatibility beyond classic shortcodes.
Blocks note
Classic hooks ≠ Block extensibility
Use Woo Blocks integration packages for fields/payments
64. Checkout Block Integration
Follow WooCommerce Blocks extension examples for additional fields and payment methods.
Integration focus
Additional Checkout Fields API
Payment method registration for blocks
Server-side validation still required
65. Cart Block Integration
Test cart block with your fees, coupons, and shipping methods on a block theme.
QA checklist
Fees visible
Coupons apply
Shipping updates
Tax display correct
66. WooCommerce HPOS
HPOS stores orders in custom tables for performance. Plugins assuming `wp_posts` order storage can break.
HPOS idea
Orders in dedicated tables
Use CRUD APIs, not raw post meta assumptions
67. HPOS Compatibility
Use `FeaturesUtil::declare_compatibility` and order CRUD methods exclusively.
Declare compatibility
use AutomatticWooCommerceUtilitiesFeaturesUtil;
add_action('before_woocommerce_init', function () {
if (class_exists(FeaturesUtil::class)) {
FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true);
}
});
68. WooCommerce CRUD Classes
CRUD classes abstract storage (posts or custom tables) and are required for forward compatibility.
CRUD habit
$order->get_billing_email();
$order->set_customer_note('Thanks');
$order->save();
69. WooCommerce Database Structure
Besides post/meta tables, Woo uses lookup tables and HPOS order tables. Prefer APIs over direct SQL.
Examples
wp_wc_order_stats
wp_woocommerce_order_items
HPOS: wp_wc_orders / wp_wc_order_addresses (names vary by version)
70. Custom Database Tables for Woo Plugins
Use dbDelta + versioning. Relate rows to product/order IDs, not assumptions about storage.
Table idea
wp_acme_woo_licenses
id | order_id | product_id | license_key | created_at
71. $wpdb and WooCommerce
Prepare SQL, allowlist columns, and prefer Woo APIs for mutations.
Prepared query
global $wpdb;
$count = (int) $wpdb->get_var(
$wpdb->prepare(
"SELECT COUNT(*) FROM {$wpdb->prefix}acme_woo_licenses WHERE product_id = %d",
$product_id
)
);
72. WooCommerce Reports
Modern Woo analytics relies on data stores/stats. Custom reports should use CRUD-safe queries.
Reporting tip
Prefer official Analytics extension points
Include refunds/taxes carefully
Respect HPOS storage
73. Custom Admin Reports
Add a Woo submenu page, query efficiently, and cache heavy aggregates.
Report page habit
add_submenu_page('woocommerce', 'Acme Report', 'Acme Report', 'view_woocommerce_reports', 'acme-report', 'acme_render_report');
74. Import and Export Products
Validate CSV columns, map categories/attributes, and run imports in batches.
Import tips
Batch rows
Log failures
Idempotent SKUs
Images sideload carefully
75. CSV Product Import/Export
You can add custom export/import columns via filters for your product meta.
Export column filter idea
add_filter('woocommerce_product_export_column_names', function ($cols) {
$cols['acme_subtitle'] = 'Acme Subtitle';
return $cols;
});
76. File Upload in WooCommerce
Validate mime/size, store safely, and link files to orders/products with permissions.
Upload guardrails
Capability + nonce checks
Allowlist mime types
Store outside public exec paths when possible
77. Image and Media Handling in WooCommerce
Use featured image + gallery IDs on product objects for consistency.
Set image
$product->set_image_id($attachment_id);
$product->set_gallery_image_ids([$id2, $id3]);
$product->save();
78. WooCommerce Multilingual Compatibility
Avoid hardcoding strings, and test language switch impacts on cart/checkout.
i18n habit
esc_html__('Add to cart label override', 'acme-woo');
79. WPML Compatibility for Woo Plugins
Use WPML hooks/APIs when syncing product meta across translations.
WPML tip
Translate strings via text domain
Decide which meta is copy vs translate
Test checkout in secondary language
80. WooCommerce Security Best Practices
Least privilege, nonces, escaping, prepared SQL, and never trust client-side price totals.
Security pillars
Caps + nonces
Sanitize/validate
Escape output
Server-side totals
Secrets not in JS
81. Nonces and Permissions in Woo Plugins
Use `manage_woocommerce`, `edit_shop_orders`, etc. instead of only `manage_options` when appropriate.
Permission check
if (! current_user_can('manage_woocommerce')) {
wp_die('Forbidden');
}
check_admin_referer('acme_woo_save');
82. Data Sanitization and Validation
Amounts, SKUs, emails, and addresses each need specific validation.
Sanitize examples
$sku = wc_clean(wp_unslash($_POST['sku'] ?? ''));
$price = wc_format_decimal(wp_unslash($_POST['price'] ?? ''));
83. SQL Injection Prevention
Never concatenate unsanitized request data into SQL.
Safe SQL
$wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM ... WHERE order_id = %d', $order_id));
84. XSS and CSRF Protection
Order admin screens and product fields are common XSS targets if meta is printed raw.
Escape meta
echo esc_html($order->get_meta('_acme_note'));
85. WooCommerce Performance Optimization
Load admin code only in admin. Cache remote calls. Don’t run expensive logic on `init` globally.
Perf checklist
Conditional asset loading
No unbounded queries on shop loop
Transient-cache remote APIs
HPOS-compatible data access
86. Caching and Database Optimization
Exclude cart/checkout from full-page cache incorrectly configured setups; use fragment caching carefully.
Transient example
$rates = get_transient('acme_remote_rates');
if (false === $rates) {
$rates = acme_fetch_rates();
set_transient('acme_remote_rates', $rates, 10 * MINUTE_IN_SECONDS);
}
87. WooCommerce Debugging
Enable WooCommerce → Status → Logs for gateway/webhook tracing.
Woo logger
$logger = wc_get_logger();
$logger->info('Payment callback received', ['source' => 'acme-pay']);
88. Error Handling and Logging
Show safe customer messages; put technical details in logs/order notes.
Order note + log
$order->add_order_note('Acme Pay: capture failed');
wc_get_logger()->error('Capture failed', ['source' => 'acme-pay']);
89. WordPress Coding Standards for Woo Plugins
Prefix everything, escape/sanitize, and keep files focused.
Standards focus
Prefixing
i18n
Escaping
Hook docs for public APIs
90. WooCommerce Coding Standards
Declare feature compat (HPOS/cart-checkout blocks), avoid deprecated APIs, and use CRUD.
Woo standards checklist
CRUD not raw posts for orders
Declare HPOS compatibility
Support Blocks where required
Avoid deprecated WC functions
91. Plugin Compatibility Testing
Include classic + block checkout tests and HPOS enabled/disabled if you support both eras.
Test matrix
WP latest/previous
Woo latest/previous
HPOS on
Cart/Checkout blocks
Popular payment gateway active
92. WordPress and WooCommerce Version Compatibility
Use plugin headers and runtime checks for minimum WooCommerce versions.
Header fields
* Requires at least: 6.0
* WC requires at least: 8.0
* Requires PHP: 7.4
93. Creating Free and Pro WooCommerce Plugins
Keep free useful. Put advanced automations/gateways features in pro add-ons with clear UX.
Model
Free core extension
Pro add-on plugin OR license-gated modules
Don’t break store if license expires
94. Plugin Licensing and Activation
Cache license status, fail open/closed intentionally, and never brick checkout on license server outages without a plan.
License check habit
$status = get_transient('acme_woo_license_status');
if (false === $status) {
$status = acme_remote_license_check();
set_transient('acme_woo_license_status', $status, DAY_IN_SECONDS);
}
95. Automatic Plugin Updates for Woo Extensions
Keep changelog clear for store owners — breaking checkout changes need warnings.
Release caution
Semver discipline
Staging test checkout/payment
Announce breaking changes
96. WooCommerce Plugin Documentation
Include screenshots for settings and a compatibility section (HPOS/blocks).
Docs sections
Install/setup
Settings reference
Compatibility
Hook reference
FAQ / troubleshooting
97. Preparing Woo Plugin for WordPress.org
Follow both WP plugin guidelines and Woo extension expectations (no trademark abuse, secure code).
Prep checklist
GPL license
No obfuscation
Proper Woo dependency handling
readme.txt + screenshots
Security pass
98. Git and SVN Workflow for Woo Plugins
Tag releases consistently and keep build artifacts intentional.
Workflow
Git feature branches → main
Tag v1.2.0
Deploy trunk/tags in SVN if wp.org hosted
99. WooCommerce Plugin Deployment
Always smoke-test add-to-cart → checkout → payment → order email on staging first.
Deploy checklist
1. Staging deploy
2. Checkout + gateway test
3. HPOS/blocks sanity
4. Production deploy
5. Monitor logs
100. WooCommerce Plugin Interview Questions
Be ready to explain cart fees, order status transitions, gateway process_payment, and Blocks vs classic checkout.
Sample Q&A
Q: Why CRUD over post meta for orders?
A: HPOS/storage abstraction + forward compatibility.
Q: Action vs filter?
A: Side effects vs modify values.
Q: Where add cart fee?
A: woocommerce_cart_calculate_fees.
Q: HPOS risk?
A: Plugins querying shop_order posts directly can break.
101. Final Project – Complete WooCommerce Plugin Development
Ship a professional plugin: Woo dependency checks, settings page, product/checkout custom fields, HPOS compatibility declaration, logging, and docs — plus either a custom fee/shipping method or a demo payment gateway.
- Define the merchant problem (fees, fields, gateway).
- Implement secure settings + data saves.
- Declare HPOS compatibility and test checkout.
- Document and package for release.
Final project scope
1. Plugin bootstrap + Woo active check
2. Settings tab/fields
3. Custom product field + display
4. Custom checkout field + validation + order meta
5. Cart fee or shipping method OR gateway skeleton
6. HPOS compatibility declaration
7. Logger + basic admin tool
8. readme.txt + changelog
9. Checkout smoke-test checklist
Starter bootstrap
<?php
/**
* Plugin Name: Acme Woo Extension
* Description: Complete WooCommerce training project.
* Version: 1.0.0
* Requires Plugins: woocommerce
* Text Domain: acme-woo
*/
if (! defined('ABSPATH')) exit;
add_action('plugins_loaded', function () {
if (! class_exists('WooCommerce')) return;
require_once __DIR__ . '/includes/class-acme-woo-plugin.php';
AcmeWooPlugin::instance(__FILE__)->boot();
});
Conclusion
You now have a professional WooCommerce extension path: architecture, hooks, catalog/order APIs, checkout/payments/shipping, Blocks/HPOS compatibility, and secure release practices. Build the final complete WooCommerce plugin to turn the lessons into a shippable extension.