woocommerce_hpos_enable_sync_on_read filter-hookWC 8.1.0

Filters whether to sync order data from posts on read.

Defaults to false because sync-on-read can be dangerous when HPOS is authoritative and running correctly, as it allows the posts data store to override HPOS data.

Usage

add_filter( 'woocommerce_hpos_enable_sync_on_read', 'wp_kama_woocommerce_hpos_enable_sync_on_read_filter' );

/**
 * Function for `woocommerce_hpos_enable_sync_on_read` filter-hook.
 * 
 * @param bool $sync_on_read_enabled Whether to sync on read.
 *
 * @return bool
 */
function wp_kama_woocommerce_hpos_enable_sync_on_read_filter( $sync_on_read_enabled ){

	// filter...
	return $sync_on_read_enabled;
}
$sync_on_read_enabled(true|false)
Whether to sync on read.

Changelog

Since 8.1.0 Introduced.

Where the hook is called

OrdersTableDataStore::read_multiple()
woocommerce_hpos_enable_sync_on_read
woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php 1308
$data_sync_enabled = apply_filters( 'woocommerce_hpos_enable_sync_on_read', false );

Where the hook is used in WooCommerce

woocommerce/src/Internal/DataStores/Orders/LegacyDataHandler.php 332
add_filter( 'woocommerce_hpos_enable_sync_on_read', $prevent_sync_on_read, 999 );
woocommerce/src/Internal/DataStores/Orders/LegacyDataHandler.php 336
remove_filter( 'woocommerce_hpos_enable_sync_on_read', $prevent_sync_on_read, 999 );