目錄
原始文章
WooCommerce-在後台訂單編輯頁面新增上一筆/下一筆 快速切換按鈕
//----- ↓ 上一筆 / 下一筆訂單 Previous Order / Next Order ↓ -----//
add_action('woocommerce_order_actions_end','jump_to_previous_and_next_order');
function jump_to_previous_and_next_order($order_id) {
global $post, $wpdb;
$order_navigation = $wpdb->get_row( $wpdb->prepare( "
SELECT
(SELECT ID FROM {$wpdb->prefix}posts
WHERE ID < %d
AND post_type = '%s'
AND post_status <> 'trash'
ORDER BY ID DESC LIMIT 1 )
AS prev_order_id,
(SELECT ID FROM {$wpdb->prefix}posts
WHERE ID > %d
AND post_type = '%s'
AND post_status <> 'trash'
ORDER BY ID ASC LIMIT 1 )
AS next_order_id
", $post->ID, $post->post_type, $post->ID, $post->post_type ), ARRAY_A ); ?>
- < 較新', esc_url( sprintf( admin_url( 'post.php?post=%d&action=edit' ), $next_order_id ) ), $next_order_id); ?>
- 較舊 >', esc_url( sprintf( admin_url( 'post.php?post=%d&action=edit' ), $previous_order_id ) ), $previous_order_id); ?>