Company Order Metadata
A custom WooCommerce plugin that generates and stores an internal company reference code for orders using WordPress best practices, extensible hooks, and a maintainable, namespaced architecture.
★ 0stars
0forks
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/javiquint1/company-order-metadata/archive/refs/heads/feature%2Fadmin-ui.zipArchitecture
This plugin is built using a single responsibility approach:
- A bootstrap file for registration
- A namespaced main Plugin class
- WooCommerce hooks for behavior extension
No core or theme files are modified.
Hooks Used and Why
woocommerce_checkout_create_order: Fires once when the order object is created, ensuring the reference is generated only once.woocommerce_admin_order_data_after_order_details: Cleanly displays read-only metadata in the admin UI.company_order_reference_code(custom filter): Allows other plugins or custom code to modify the reference format.
Testing Strategy (Production-Safe)
- Place test orders in staging
- Verify reference code is created once
- Confirm no duplication on order updates
- Check admin UI visibility
- Load test bulk orders via WooCommerce tools
Performance Considerations
- Executes only during order creation
- Single meta read/write per order
- No queries on frontend rendering
- Scales linearly even on high-volume stores
Future Improvement
With more time, I would:
- Add REST API exposure for the reference code
- Add automated PHPUnit/WP tests
- Add optional prefix/year customization via settings