Develop WooCommerce

The official WooCommerce development blog

WC 3.3 New Webhooks CRUD — December 8, 2017

WC 3.3 New Webhooks CRUD

We have been talking a lot about CRUD since 3.0.0, and the reason is because we want move certain features from the WordPress post database table to new database tables. This improves the performance and scalability of those features. Starting with 3.3.0, our webhooks will not use the posts and comments database tables anymore, and we finally have our first feature migrated to custom tables!

New Webhooks CRUD

Webhooks are a feature that 3rd party developers do not use often or heavily customize, so this make it easy to start moving all of the necessary data for webhooks to a new table.

With CRUD it is now easier to manipulate webhooks too:

// Creating a new webhook.
$webhook = new WC_Webhook();
$webhook->set_user_id( 1 ); // User ID used while generating the webhook payload.
$webhook->set_topic( 'order.created' ); // Event used to trigger a webhook.
$webhook->set_secret( 'secret' ); // Secret to validate webhook when received.
$webhook->set_delivery_url( '' ); // URL where webhook should be sent.
$webhook->set_status( 'active' ); // Webhook status.

// Updating webhook:
$webhook = wc_get_webhook( $webhook_id );
$webhook->set_status( 'disabled' );

// Deleting webhook:
$webhook = wc_get_webhook( $webhook_id );
$webhook->delete( true );

Webhook delivery logs

Delivery logs have been moved from the WordPress comments table to our logging system, which allows more options for handling them instead of having to access the webhook logs in the admin interface.

Note: Because of this change all REST API endpoints for webhook delivery logs are now deprecated and will always return as empty. This is because logs now can be saved in the database, as files, or anything else.

Use your favorite message queue tool to process webhooks

It is now possible to write custom code to process webhooks. We used to only have options to deliver a webhook as soon as it is triggered or by WP CRON, but that may not be good for everyone. Until we have a third option with our “event queue” you may want to use Redis, Amazon SQS or something else.

It’s possible to override the delivery like so:

remove_action( 'woocommerce_webhook_process_delivery', 'wc_webhook_process_delivery', 10 );

 * Custom process webhook delivery.
 * @param WC_Webhook $webhook Webhook instance.
 * @param array      $arg     Delivery arguments.
function my_custom_wc_webhook_process_delivery( $webhook, $arg ) {
	// Your custom code here.
	// Just do not forget to trigger webhook with later:
	// $webhook->deliver( $arg )
	// Or get the webhook payload as JSON and send with your own delivery method:
	// wp_json_encode( $webhook->build_payload( $arg ) )
	// Note that custom delivery methods will require extra code to log deliveries with $webhook->log_delivery( $delivery_id, $request, $response, $duration )
add_action( 'woocommerce_webhook_process_delivery', 'my_custom_wc_webhook_process_delivery', 10, 2 );

And that’s all folks đź‘‹.

WooCommerce 3.2 RC2 — October 5, 2017

WooCommerce 3.2 RC2

WooCommerce 3.2.0 RC2 is available for testing. This includes a few small fixes.

To test WooCommerce 3.2.0 RC2, you can use our WooCommerce Beta Tester plugin or you can download the release candidate here (zip).

Think you’ve found a bug? Please post in detail to Github.

The final version of 3.2 is due for release October 11th 2017. Huge props to everyone who has sent feedback about this release so far or found bugs.

WooCommerce 3.2 RC1 — September 27, 2017
August 15th: Dev chat #9 — August 12, 2017

August 15th: Dev chat #9

The next chat will be on August 15th at 16:00 UTC in the #core channel of the WooCommerce Community Slack. If you don’t already have access to the group, you can request an invite at the bottom of the WooCommerce developers page.

Here is the agenda:

  • 3.2 progress
  • SelectWoo

If you have anything to propose for the agenda or related to the above, please leave a comment below.

See you there!

p.s. if you missed something in the last dev chat, you can recap our summary here.

Dev Chat Summary – June 20th — June 27, 2017

Dev Chat Summary – June 20th

This post summarizes the dev chat meeting from June 20th (agenda, Slack archive).

Questions and feedback related to WooCommerce 3.1 RC

How will the CSV importer work with classes that extend product, e.g. Bookings? will it work out of the box or adjustment will be needed? bor0

By default support any type of product type, and it’s able to handle all meta data, so for most of the 3rd party plugins should work just fine. There’s still a guide about extending the importer/exporter.

One piece of feedback RE exporting products: any thoughts on adding export by category? seems like it may be better for bulk updates than product type bekarice

If it’s something needed we should be happy to include in 3.1. It’s also possible to support this idea on WooCommerce Ideas Board.

So it looks like the export / import isn’t using the asynch processing? bekarice

All import/export processing is done in batching with AJAX, so as long as the windows is open, it will happily import/export all day.

Is WC core a place we can explore a better background processing than cron? pmgarman

For now import/export does not need it, but this is something that we definitely want to look in the future to improve other use cases, like the mailer.

I’ve a question. Has anyone had to do compatibility updates for 3.1, if so, why and was it core at fault? mikejolley

Most of people just had a little work with deprecation notices, e.g with WC_Order_Item_Meta class, but in general no fatal errors or problems like we had in the past.

Welcome to selectWoo

selectWoo is our fork of select2 JavaScript library, where we fixed several accessibility issues and changed the namespace for WooCommerce usage, this should handle incompatibilities caused by different select2 versions too.