Botón de cancelación condicional en la lista de pedidos de mi cuenta en Woocommerce

Esto es en referencia aAgregue el botón Cancelar en la lista de pedidos de Mi cuenta usando Woo Cancelar para Clientes Plugin responder

Traté también de agregar la función a functions.php y también obtuve el error de muy pocos argumentos:

Hice la misma función proporcionada por LoicTheAztec:

add_filter( 'woocommerce_valid_order_statuses_for_cancel', 'custom_valid_order_statuses_for_cancel', 10, 2 );
function custom_valid_order_statuses_for_cancel( $statuses, $order ){

// Set HERE the order statuses where you want the cancel button to appear
$custom_statuses    = array( 'pending', 'processing', 'on-hold', 'failed' );

// Set HERE the delay (in days)
$duration = 3; // 3 days

// UPDATE: Get the order ID and the WC_Order object
if( isset($_GET['order_id']))
    $order = wc_get_order( absint( $_GET['order_id'] ) );

$delay = $duration*24*60*60; // (duration in seconds)
$date_created_time  = strtotime($order->get_date_created()); // Creation date time stamp
$date_modified_time = strtotime($order->get_date_modified()); // Modified date time stamp
$now = strtotime("now"); // Now  time stamp

// Using Creation date time stamp
if ( ( $date_created_time + $delay ) >= $now ) return $custom_statuses;
else return $statuses;
}

Respuestas a la pregunta(1)

Su respuesta a la pregunta