Статус пользовательского заказа Woocommerce не отображается - PullRequest
1 голос
/ 06 марта 2020

Я пытался добавить статус пользовательского заказа Отправлено в woocommerce.

вот код

function add_awaiting_shippped_to_order_statuses( $order_statuses ) {

        $new_order_statuses = array();

        // add new order status before processing
        foreach ($order_statuses as $key => $status) {
            $new_order_statuses[$key] = $status;
            if ('wc-processing' === $key) {
                $new_order_statuses['wc-order-shipped'] = __('Shipped', 'woocommerce' );
            }
        }

        return $new_order_statuses;


    }
  function register_shipped_status() {


            register_post_status( 'wc-order-shipped', array(
                'label'                     => _x( 'Shipped', 'Order status', 'woocommerce' ),
                'public'                    => true,
                'exclude_from_search'       => false,
                'show_in_admin_all_list'    => true,
                'show_in_admin_status_list' => true,
                'label_count'               => _n_noop( 'Shipped <span class="count">(%s)</span>', 'Shipped<span class="count">(%s)</span>', 'woocommerce' )
            ) );


    }

add_action( 'init', array( $plugin_admin_meta_box, 'register_shipped_status') );

add_filter( 'wc_order_statuses', array( $plugin_admin_meta_box, 'add_awaiting_shippped_to_order_statuses') );

Статус доставки отображается везде в woocommerce, и он отлично работает

enter image description here

Всякий раз, когда я меняю статус заказа на отправку, он успешно обновляется

Теперь проблема в том, что отправленные заказы не отображаются в таблице заказов

enter image description here

1 Ответ

0 голосов
/ 06 марта 2020

Следующее работает для добавления функционального пользовательского статуса заказа в пользовательский плагин:

// Register new custom order status
function register_shipped_status() {
    register_post_status( 'wc-order-shipped', array(
        'label'                     => _x( 'Shipped', 'Order status', 'woocommerce' ),
        'public'                    => true,
        'exclude_from_search'       => false,
        'show_in_admin_all_list'    => true,
        'show_in_admin_status_list' => true,
        'label_count'               => _n_noop( 'Shipped <span class="count">(%s)</span>', 'Shipped<span class="count">(%s)</span>', 'woocommerce' )
    ) );
}

// Add new custom order status to list of WC Order statuses
function add_awaiting_shippped_to_order_statuses( $order_statuses ) {
    $new_order_statuses = array();

    // add new order status before processing
    foreach ($order_statuses as $key => $status) {
        $new_order_statuses[$key] = $status;
        if ('wc-processing' === $key) {
            $new_order_statuses['wc-order-shipped'] = _x( 'Shipped', 'Order status', 'woocommerce' );
        }
    }
    return $new_order_statuses;
}

// Adding custom status to admin order list bulk actions dropdown
function custom_dropdown_bulk_actions_shop_order( $actions ) {
    $new_actions = array();

    // Add new order status before processing
    foreach ($actions as $key => $action) {
        $new_actions[$key] = $action;
        if ('mark_processing' === $key) {
            $actions['mark_order-shipped'] = __( 'Mark Shipped', 'woocommerce' );
        }
    }

    return $actions;
}

add_action( 'init', array($plugin_admin_meta_box, 'register_shipped_status') );
add_filter( 'wc_order_statuses', array($plugin_admin_meta_box, 'add_awaiting_shippped_to_order_statuses' );
add_filter( 'bulk_actions-edit-shop_order', array($plugin_admin_meta_box, 'custom_dropdown_bulk_actions_shop_order'), 20, 1 );

enter image description here

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...