The aim was to build a WordPress plugin to collect user data at the WooCommerce checkout and send this data to a selected CRM system. This was my first attempt at a WordPress plugin development and also involved how WooCommerce integrates with WordPress. A great learning experience.

The plugin was developed for a specific project and is not something that can be installed and used without modification.


Create a plugin template from various examples, and the WordPress documentation.
Add an admin Settings section to store the the required UID and URL for the CRM system.
Processing function to collect the Order information required, and send it to the CRM.



Line 37 begins by checking if WooCommerce is loaded.
Line 49 starts the definition of the WC_CRM_Integration class
The __construct function defines the settings title and parameters, from line 54.
Default options are created and written, lines 81 & 82.
Followed by a series of add_action() functions to display the settings, save the settings, and where to call the our function to process the the checkout data during processing.
Note: “woocommerce_checkout_order_processed” – I found it difficult to find a good explanation of the hooks available in WooCommerce and where it would be best to inject our function. So with a bit of trial and error and some diagnostic triggers I found found this works well. Function is called post checkout but before sending the user to the external payment page. In the later function the required order parameters can be recalled for our purpose.

The real action happens in checkout_order_processed($order_id, $checkout).
Recall the settings required, lines 118, 119.
Load the order and gather the names from the item(s), lines 122 – 129.
Line 135 sends the collected data by posting it the CRM web site for processing. This process will be CRM specific, and t
here were some tricks applied here to get it working for our case.


As this is my first plugin there were some challenges to sort through and there is no doubt I probably broke some rules along the way. Some of the documentation I found could be more helpful.

Let me know your experience in the comments.