WooCommerce HubSpot Leads
Send WooCommerce customers to HubSpot.
Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/alexphex/wc-hubspot-leads/archive/refs/heads/main.zipA simple educational WordPress plugin that sends WooCommerce customers to HubSpot after a successful order.
Purpose
This project was built for learning purposes to understand how a real WooCommerce → HubSpot API integration works.
It demonstrates the basic architecture that a WordPress/WooCommerce developer may implement in a custom agency project.
Features
- Create a HubSpot contact after a WooCommerce order
- HubSpot API integration using WordPress HTTP API (
wp_remote_post) - Admin settings page for storing HubSpot Access Token
- Object-Oriented architecture
- Dependency Injection
- Basic logging
- Response handling (201, 400, 401, 403, 409)
- WordPress Coding Standards friendly structure
Project Structure
wc-hubspot-leads/
│
├── includes/
│ ├── Plugin.php
│ ├── OrderListener.php
│ ├── HubSpotAPI.php
│ ├── SettingsPage.php
│ └── Logger.php
│
├── composer.json
├── wc-hubspot-leads.php
└── README.md
How it works
WooCommerce Order
│
▼
OrderListener
│
▼
HubSpotAPI
│
▼
HubSpot CRM
When a customer places an order:
- WooCommerce fires an action.
OrderListenercollects customer information.HubSpotAPIsends the data to HubSpot.- The response is processed.
- Results are written to the log.
Requirements
- WordPress
- WooCommerce
- HubSpot Private App
- HubSpot Access Token
Installation
- Clone the repository into the
wp-content/plugins/directory. - Activate the plugin.
- Open:
Settings → HubSpot Leads
- Paste your HubSpot Access Token.
- Save settings.
- Create a WooCommerce order.
Educational Goals
This project was created to practice:
- WordPress Plugin Development
- WooCommerce Hooks
- Object-Oriented PHP
- Dependency Injection
- WordPress HTTP API
- Working with REST APIs
- JSON requests
- API authentication using Bearer Token
- Error handling
- Basic plugin architecture
Notes
This plugin is intentionally simple.
It focuses on understanding the integration process rather than implementing every HubSpot feature.
Possible future improvements include:
- Update existing contacts
- Create Deals
- Associate Contacts with Deals
- Webhooks
- Retry queue
- Better error reporting
- Unit tests
License
GPL-2.0