wc_format_option_hold_stock_minutes()
Formats hold stock option and sets cron event up.
Хуки из функции
Возвращает
Строку.
Использование
wc_format_option_hold_stock_minutes( $value, $option, $raw_value );
- $value(строка) (обязательный)
- Option value.
- $option(массив) (обязательный)
- Option name.
- $raw_value(строка) (обязательный)
- Raw value.
Код wc_format_option_hold_stock_minutes() wc format option hold stock minutes WC 10.4.2
function wc_format_option_hold_stock_minutes( $value, $option, $raw_value ) {
$value = ! empty( $raw_value ) ? absint( $raw_value ) : ''; // Allow > 0 or set to ''.
// Clear existing scheduled events.
if ( function_exists( 'as_unschedule_all_actions' ) ) {
as_unschedule_all_actions( 'woocommerce_cancel_unpaid_orders' );
} else {
wp_clear_scheduled_hook( 'woocommerce_cancel_unpaid_orders' );
}
if ( '' !== $value ) {
/**
* Filters the interval at which to cancel unpaid orders in minutes.
*
* @since 5.1.0
*
* @param int $cancel_unpaid_interval The interval at which to cancel unpaid orders in minutes.
*/
$cancel_unpaid_interval = apply_filters( 'woocommerce_cancel_unpaid_orders_interval_minutes', absint( $value ) );
if ( function_exists( 'as_schedule_single_action' ) ) {
as_schedule_single_action( time() + ( absint( $cancel_unpaid_interval ) * 60 ), 'woocommerce_cancel_unpaid_orders', array(), 'woocommerce', true );
} else {
wp_schedule_single_event( time() + ( absint( $cancel_unpaid_interval ) * 60 ), 'woocommerce_cancel_unpaid_orders' );
}
}
return $value;
}