WC_Post_Data::schedule_variation_summary_regeneration
Schedule an asynchronous action to regenerate product variation summaries.
This method uses the WooCommerce Action Scheduler to queue a single regeneration action for product variation summaries. It first checks whether an identical action with the given arguments is already scheduled to avoid duplicate jobs. If the Action Scheduler is not available, a warning is logged instead.
Method of the class: WC_Post_Data{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = WC_Post_Data::schedule_variation_summary_regeneration( $action_name, $args, $warning_message, $group );
- $action_name(string) (required)
- The name/identifier of the scheduled action (hook name).
- $args(array) (required)
- Arguments to pass to the scheduled action callback.
- $warning_message(string) (required)
- Message to log when the Action Scheduler is unavailable.
- $group(string)
- The Action Scheduler group to associate with the scheduled action.
Default:'woocommerce'
WC_Post_Data::schedule_variation_summary_regeneration() WC Post Data::schedule variation summary regeneration code WC 10.8.1
private static function schedule_variation_summary_regeneration( $action_name, $args, $warning_message, $group = 'woocommerce' ) {
if ( function_exists( 'as_schedule_single_action' ) ) {
// Prevent duplicate scheduling of the action.
$when = as_next_scheduled_action( $action_name, $args, $group );
if ( ! $when ) {
as_schedule_single_action( time() + 1, $action_name, $args, $group );
}
} else {
wc_get_logger()->warning(
'Action Scheduler unavailable for product variation summary regeneration. ' . $warning_message,
array( 'source' => 'woocommerce-variations' )
);
}
}