Skip to content

Commit

Permalink
Add HPOS events to JP sync (#32530)
Browse files Browse the repository at this point in the history
* Add full sync support to HPOS orders for JP sync.

* Add changelog.

* changelog

* Remove accidently added file.

* Fixup versions

* Changelog edit

* Ensure order props are included.

* [not verified] Capture both trash + delete events, additionally, also capture ID.

* Added the HPOS enabled option sync.

* Add core table keys for order sync.

* Add support to sync refund type.

* Fixed project version.

* Added a test for the added HPOS option.

* changelog

---------

Co-authored-by: Samiff <samiff@users.noreply.github.com>
Co-authored-by: Igor Zinovyev <zinigor@gmail.com>
Co-authored-by: Brandon Kraft <public@brandonkraft.com>

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/6226498998
  • Loading branch information
zinigor authored and matticbot committed Sep 18, 2023
1 parent b072926 commit 3d961c0
Show file tree
Hide file tree
Showing 11 changed files with 507 additions and 109 deletions.
1 change: 1 addition & 0 deletions jetpack_vendor/automattic/jetpack-sync/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This is an alpha version! The changes listed here are not final.

### Added
- Jetpack Sync: Drop Sync custom queue table when Jetpack is disconnected
- Woo: add HPOS (custom order tables) events to sync module.

## [1.56.0] - 2023-09-04
### Added
Expand Down
25 changes: 25 additions & 0 deletions jetpack_vendor/automattic/jetpack-sync/src/class-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
use Automattic\Jetpack\Constants;
use Automattic\Jetpack\Identity_Crisis;
use Automattic\Jetpack\Status;
use Automattic\Jetpack\Sync\Modules\WooCommerce_HPOS_Orders;
use Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController;
use WP_Error;

/**
Expand Down Expand Up @@ -744,6 +746,14 @@ public static function initialize_woocommerce() {
return;
}
add_filter( 'jetpack_sync_modules', array( __CLASS__, 'add_woocommerce_sync_module' ) );

if ( ! class_exists( CustomOrdersTableController::class ) ) {
return;
}
$cot_controller = wc_get_container()->get( CustomOrdersTableController::class );
if ( $cot_controller->custom_orders_table_usage_is_enabled() ) {
add_filter( 'jetpack_sync_modules', array( __CLASS__, 'add_woocommerce_hpos_order_sync_module' ) );
}
}

/**
Expand Down Expand Up @@ -790,6 +800,21 @@ public static function add_woocommerce_sync_module( $sync_modules ) {
return $sync_modules;
}

/**
* Adds Woo's HPOS sync modules to existing modules for sending.
*
* @param array $sync_modules The list of sync modules declared prior to this filter.
*
* @access public
* @static
*
* @return array A list of sync modules that now includes Woo's HPOS modules.
*/
public static function add_woocommerce_hpos_order_sync_module( $sync_modules ) {
$sync_modules[] = WooCommerce_HPOS_Orders::class;
return $sync_modules;
}

/**
* Initializes sync for WP Super Cache.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class Defaults {
'wordads_display_page',
'wordads_display_post',
'wordads_second_belowpost',
'woocommerce_custom_orders_table_enabled',
'wp_mobile_app_promos',
'wp_mobile_excerpt',
'wp_mobile_featured_images',
Expand Down
Loading

0 comments on commit 3d961c0

Please sign in to comment.