这是参考使用 Woo Cancel for Customers 插件回答我的帐户订单列表上的添加取消按钮:
我还尝试将函数添加到 functions.php 中,但也得到了参数太少的错误:
我做了 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'] ) …
Run Code Online (Sandbox Code Playgroud)