Automattic\WooCommerce\Internal\DataStores\Orders
DataSynchronizer::process_updated_option
Process an option change for specific keys.
Method of the class: DataSynchronizer{}
No Hooks.
Returns
null. Nothing (null).
Usage
$DataSynchronizer = new DataSynchronizer(); $DataSynchronizer->process_updated_option( $option_key, $old_value, $new_value );
- $option_key(string) (required)
- The option key.
- $old_value(string) (required)
- The previous value.
- $new_value(string) (required)
- The new value.
DataSynchronizer::process_updated_option() DataSynchronizer::process updated option code WC 10.3.3
public function process_updated_option( $option_key, $old_value, $new_value ) {
$sync_option_keys = array( self::ORDERS_DATA_SYNC_ENABLED_OPTION, self::BACKGROUND_SYNC_MODE_OPTION );
if ( ! in_array( $option_key, $sync_option_keys, true ) || $new_value === $old_value ) {
return;
}
if ( self::BACKGROUND_SYNC_MODE_OPTION === $option_key ) {
$mode = $new_value;
} else {
$mode = $this->get_background_sync_mode();
}
switch ( $mode ) {
case self::BACKGROUND_SYNC_MODE_INTERVAL:
$this->schedule_background_sync();
break;
case self::BACKGROUND_SYNC_MODE_CONTINUOUS:
case self::BACKGROUND_SYNC_MODE_OFF:
default:
$this->unschedule_background_sync();
break;
}
if ( self::ORDERS_DATA_SYNC_ENABLED_OPTION === $option_key ) {
if ( ! $this->check_orders_table_exists() ) {
$this->create_database_tables();
}
if ( $this->data_sync_is_enabled() ) {
wc_get_container()->get( LegacyDataCleanup::class )->toggle_flag( false );
$this->batch_processing_controller->enqueue_processor( self::class );
} else {
$this->batch_processing_controller->remove_processor( self::class );
}
}
}