• Bỏ qua primary navigation
  • Skip to main content
  • Bỏ qua primary sidebar
  • Bỏ qua footer

Thủ thuật thiết kế website

Chia sẻ kinh nghiệm thiết kế website

  • Trang chủ
  • Joomla
    • Thủ thuật Joomla
    • Joomla Extensions
    • Joomla Themes
  • WordPress
    • Thủ thuật WordPress
    • WordPress Plugins
    • WordPress Themes
  • Web Development
    • HTML/CSS
    • Javascript
    • PHP
  • PHP Framework
    • Codeigniter
  • App Developer
    • React Native
  • SEO
  • Chia sẻ
  • Phần mềm
Bạn đang ở:Trang chủ / Wordpress / Thủ thuật WordPress / Adding multiple custom order statuses in Woocommerce

Adding multiple custom order statuses in Woocommerce

11/08/2020 - admin Để lại bình luận

The following code, will add “Awaiting shipment” and “Verification” custom order statuses and it will replace the code from your question:

Code goes in function.php file of your active child theme (active theme). Tested and works.

add_action( 'init', 'register_custom_statuses_as_order_status' );
function register_custom_statuses_as_order_status() {

    register_post_status( 'wc-awaiting-shipment', array(
        'label'                     => __('Awaiting shipment'),
        'public'                    => true,
        'exclude_from_search'       => false,
        'show_in_admin_all_list'    => true,
        'show_in_admin_status_list' => true,
        'label_count'               => _n_noop( 'Awaiting shipment <span class="count">(%s)</span>', 'Awaiting shipment <span class="count">(%s)</span>' )
    ) );

    register_post_status( 'wc-verification', array(
        'label'                     => __('Verification'),
        'public'                    => true,
        'exclude_from_search'       => false,
        'show_in_admin_all_list'    => true,
        'show_in_admin_status_list' => true,
        'label_count'               => _n_noop( 'Verification <span class="count">(%s)</span>', 'Verification <span class="count">(%s)</span>' )
    ) );
}

// Add to list of WC Order statuses
add_filter( 'wc_order_statuses', 'add_additional_custom_statuses_to_order_statuses' );
function add_additional_custom_statuses_to_order_statuses( $order_statuses ) {
    $new_order_statuses = array();
    // add new order status after processing
    foreach ( $order_statuses as $key => $status ) {
        $new_order_statuses[ $key ] = $status;
        if ( 'wc-processing' === $key ) {
            $new_order_statuses['wc-awaiting-shipment'] = __('Awaiting shipment');
            $new_order_statuses['wc-verification'] = __('Verification');
        }
    }
    return $new_order_statuses;
}

Nguồn : Sưu tập

0 0 vote
Article Rating
Subscribe
Login
Notify of
guest
guest
0 Comments
Inline Feedbacks
View all comments

Sidebar chính

Từ khóa

Air Explorer Pro chia se plugin WP Rocket chia se WP Rocket chuyen excel thanh file csv Codeigniter password csv Excel excel thành csv flatsome giam gia woocommerce git git cheat sheet github huong dan seo website loai bo tai nguyen chan hien thi Loại bỏ các tài nguyên chặn hiển thị menu flatsome menu Woocommerce menu xo flatsome nut mua ngay password generator Codeigniter plugin WP Rocket polylang polylang fix lang default polylang loi ngon ngu mac dinh polylang set default language quản lý nhiều tài khoản random password generator React Native seo website splash React Native splash screen splash screen React Native Test Speed Google thu thuat wordpress toi uu seo website tài nguyên chặn hiển thị Woocommerce Woocommerce Product Filter Woo Product Filter wordpress rocket WP Rocket xoá menu quản trị Woocommerce xoá menu Woocommerce xoá thanh menu Woocommerce

Dịch vụ Thiết Kế Website

Footer

GIỚI THIỆU

Đây là blog cá nhân, cung cấp các thông tin, kiến thức và kinh nghiệm về lập trình và cuộc sống. Những bài viết được mình sưu tập từ nhiều nguồn, mọi chi tiết liên quan đến bản quyền xin vui lòng liên hệ qua email kairu2607@gmail.com ! Cám ơn

BÀI VIẾT MỚI NHẤT

  • [Woocommerce] Hướng dẫn thay đổi cách hiển thị giảm giá bắt mắt người xem trong
  • [Woocommerce] Thay chữ Sale bằng % giảm giá trong Woocommerce
  • Thêm nút Mua ngay vào Woocommerce một cách đơn giản

Copyright © 2021 · Metro Pro on Genesis Framework · WordPress · Đăng nhập

wpDiscuz