Note about Code Snippets
The Phone Orders for WooCommerce plugin is designed to be extensible, allowing developers to tailor its store‑front behaviour to unique business requirements. This overview is your starting point for understanding the customisation options and developer resources available in the Phone Orders for WooCommerce plugin.
Why Extend the Phone Orders Plugin?
While the Phone Orders plugin works perfectly out of the box for most stores, some businesses require specific adjustments. Common reasons for customising the plugin include:
- Changing the customer search logic to include more fields or custom meta data.
- Modifying how products are added when agents are using the phone order interface.
- Integrating the phone order process with third‑party APIs, such as address lookup services.
- Adding custom fields to the phone order form to capture data specific to the business.
- Ensuring compatibility with other plugins that affect pricing, discounts, or taxes.
The Phone Orders plugin provides a set of action hooks and PHP filters that enable you to make these customisations without altering the core plugin files. This means your modifications will remain safe and functional even after plugin updates.
Types of Code Samples Available
The official Phone Orders for WooCommerce documentation includes a library of ready‑to‑use code snippets. These are specifically crafted to help developers accelerate their customisation projects. The code samples cover a variety of tasks:
| Category | Examples of Ready‑Made Snippets |
|---|---|
| Enhancing Product Search | Snippets to add barcode search or lookup by product ID. |
| Customising Order Creation | Hooks for changing how the cart is built and validated before an order is finalised. |
| Integrating External APIs | Examples for connecting address‑lookup, tracking, or currency conversion services. |
| Altering Customer Autocomplete | Filters to modify which customers appear in the search results list. |
| Creating Custom Layouts | Code to change the presentation of order details or to add extra meta boxes. |
Expand Your Toolkit. Many of these code samples are collected in a dedicated Code Samples section, which is the first place to look for a working solution before writing custom code from scratch.
Key Developer Hooks and Filters
The Phone Orders plugin relies on a set of hooks and filters that serve as entry points for custom functionality.
| Hook / Filter Name | Purpose |
|---|---|
wpo_prepare_item | Called for each product before it is added to the phone order cart. Useful for normalising prices or modifying item data. |
wpo_skip_add_to_cart_item | Allows to conditionally prevent a product from being added to the cart, for example when working with chained products. |
wpo_before_update_cart | Fires just before the cart is recalculated. It is particularly important for forcing external tax plugins (like Avalara) to perform a new calculation. |
wpo_get_customer_by_array_data | Modifies the customer information array that is displayed in the phone order interface. |
wpo_after_update_customer | Fires after a customer record is updated, allowing to add extra logic or synchronise data. |
Additional hooks for customer search results, price overrides, and custom field handling are also documented. A full reference list is maintained in the plugin’s developer documentation.
Implementation Methods: Where to Put Custom Code
Adding custom PHP code to a WordPress site requires a safe method that will not be lost when the site is updated. For the Phone Orders plugin, the recommended approach is to use a child theme or a code snippet plugin.
Method 1: Using a Code Snippet Plugin (Recommended)
Using a code snippet plugin is the modern, safest method because:
- It provides a dedicated interface to add, disable, and manage snippets without editing theme files.
- It prevents syntax errors from breaking the whole site.
- It keeps custom code organised and separate from theme updates.
- Install and activate the free Code Snippets plugin from WordPress.org.
- Go to Snippets → Add New in the WordPress admin menu.
- Enter a descriptive title (e.g., “Phone Orders – Reset Product Price”).
- Paste the custom PHP snippet into the Code text area.
- Set the “Run snippet” option to “Run everywhere” (or the most suitable location).
- Click Save Changes and Activate.
Method 2: Using a Child Theme
Alternatively, custom code can be placed in the functions.php file of a child theme.
- If a child theme is not already active, create one.
- After the child theme is active, open its
functions.phpfile and add the required code.
Important Warning: Editing the parent theme’s functions.php directly will cause all customisations to be lost when the theme is updated. Always use a child theme or a snippet plugin.
Best Practices for Extending Phone Orders
- Keep a back‑up of custom code. Store all snippets in a separate file or a version‑controlled repository.
- Use a code snippet plugin for easier management and to avoid losing customisations during theme changes.
- Test on a staging environment before deploying to a live store.
- Check for conflicts after updating the Phone Orders plugin, WordPress, or WooCommerce.
- Document all customisations with inline comments explaining the purpose and the hook used.
Summary
The Phone Orders for WooCommerce plugin is a highly extensible tool for manual order entry. Its rich set of developer hooks and filters gives you full control over product search, customer data, cart behaviour, and the overall order workflow.
| Aspect | Description |
|---|---|
| Purpose | Extend and customise the phone order interface to match unique business needs. |
| Key Hooks | wpo_prepare_item, wpo_skip_add_to_cart_item, wpo_before_update_cart, wpo_get_customer_by_array_data, wpo_after_update_customer. |
| Implementation Methods | Code Snippets plugin (recommended) or child theme functions.php. |
| Common Customisations | Product search by barcode/ID, custom fields, API integrations, pricing adjustments. |
| Free vs Pro | Developer filters are generally available in both versions; advanced UI features may be Pro‑only. |
Need Assistance? If you need a custom solution that is not covered by the existing snippets, or if you encounter unexpected behaviour, please submit a support request. Including the specific hook names, the code snippet you are using, and a description of the expected outcome will help the team assist you quickly.