This is a WordPress plugin designed to handle Sendcloud webhooks. Sendcloud is a shipping and logistics platform, and this plugin facilitates the integration of Sendcloud webhook data with a WordPress website.
-
Download the Plugin:
- Download the
sendcloud-webhook-handler
directory and its contents. - Place the entire directory in the WordPress plugins directory (
wp-content/plugins/
).
- Download the
-
Activate the Plugin:
- Log in to your WordPress admin dashboard.
- Navigate to the "Plugins" section.
- Locate "Sendcloud Webhook Handler" and click "Activate."
Once the plugin is activated, it automatically hooks into the WordPress initialization process (init
). It listens for incoming Sendcloud webhook data and processes it accordingly.
-
Receiving Webhook Data:
- The plugin listens for incoming webhook data on the
php://input
stream.
- The plugin listens for incoming webhook data on the
-
Processing Webhook Data:
- If data is received, it is logged and then decoded from JSON format.
- The plugin checks for the existence of the "action" field in the decoded data.
-
Validating and Saving Data to the Database:
- If the "action" field exists, the plugin extracts parcel details and validates the required data.
- If the required parcel data is present, it is sanitized and validated before being saved to the WordPress database.
-
Updating Post and Parcel Status:
- The plugin maps Sendcloud status messages to corresponding WordPress post statuses.
- It updates the post status in the WordPress posts table and the custom Sendcloud parcels table.
- The plugin uses two database tables:
- The WordPress posts table to update the post status.
- A custom table (
cu_sendcloud_parcels
) to store Sendcloud parcel information.
- The plugin does not require specific configuration. However, ensure that the Sendcloud webhook is configured to send data to the correct endpoint on your WordPress site.
- The plugin assumes a specific structure in the Sendcloud webhook payload, including the presence of the "action" field and required parcel data.
- If needed, you can customize the plugin by modifying the code to suit your specific requirements.
- In case of issues, check the error logs for relevant information. The error logs capture details about webhook data processing and database operations.
This plugin is released under the GPL-2.0 license. Feel free to modify and distribute it according to your needs.
Note: Make sure to replace 'cu_sendcloud_webhook'
and 'cu_sendcloud_parcels'
with your actual table names as needed.