• Resolved 2acom

    (@2acom)


    Hi everybody,

    I have custom status (being-delivered) and i would like to see the “complete” order button on mobile app, i can see it when order are on “pending” but when i change the status with my custom status, the action button is not displayed.

    However, this button is displayed on my computer order list…

    Is someone know how can i fix it ?

    There’s the code :

    /**
     * Register order status
     */
    function filter_woocommerce_register_shop_order_post_statuses( $order_statuses ) {
        // Status must start with "wc-"
        $order_statuses['wc-being_delivered'] = array(
            'label'                     => _x( 'En cours de livraison', 'Order status', 'woocommerce' ), 
            'public'                    => false,
            'exclude_from_search'       => false,
            'show_in_admin_all_list'    => true,
            'show_in_admin_status_list' => true,
            /* translators: %s: number of orders */
            'label_count'               => _n_noop( 'En cours de livraison <span class="count">(%s)</span>', 'Abonnement <span class="count">(%s)</span>', 'woocommerce' ),       
        );
        
        return $order_statuses;
    }
    add_filter( 'woocommerce_register_shop_order_post_statuses', 'filter_woocommerce_register_shop_order_post_statuses', 10, 1 );
    
    /**
     * Show order status in the dropdown @ single order
     */
    function filter_wc_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 ) {
                // Status must start with "wc-"
                $new_order_statuses['wc-being_delivered'] = _x( 'En cours de livraison', 'Order status', 'woocommerce' );
            }
        }
    
        return $new_order_statuses;
    }
    add_filter( 'wc_order_statuses', 'filter_wc_order_statuses', 10, 1 );
    
    /**
     * Show order status in the dropdown @ bulk actions
     */
    function filter_bulk_actions_edit_shop_order( $bulk_actions ) {
        // Note: "mark_" must be there instead of "wc"
        $bulk_actions['mark_being_delivered'] = __( 'En cours de livraison', 'woocommerce' );
        return $bulk_actions;
    }
    add_filter( 'bulk_actions-edit-shop_order', 'filter_bulk_actions_edit_shop_order', 10, 1 );
    
    /**
     * Add quick action button @ admin orders list
     */
    function filter_order_actions( $actions, $order ) {
        // Get Order ID (compatibility all WC versions)
        $order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;
        
        // Display the button for all orders that have a 'processing' status
        if ( $order->has_status( array( 'processing' ) ) ) {
    
            $action_slug = 'being_delivered';
    
            // Set the action button
            $actions['being_delivered'] = array(
                'url'       => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=being_delivered&order_id=' . $order_id ), 'woocommerce-mark-order-status' ),
                'name'      => __( 'En cours de livraison', 'woocommerce' ),
                'action'    => $action_slug, // keep "view" class for a clean button CSS
            );
        }
        
        // Display the button for all orders that have a 'being_delivered' status
        if ( $order->has_status( array( 'being_delivered' ) ) ) {
            
            $action_slug = 'complete';
        
            // Set the action button
            $actions['complete'] = array(
                'url'    => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=completed&order_id=' . $order_id ), 'woocommerce-mark-order-status' ),
                'name'   => __( 'Complete', 'woocommerce' ),
                'action' => $action_slug,
            );
        }
        
        return $actions;
    }
    add_filter( 'woocommerce_admin_order_actions', 'filter_order_actions', 10, 2 );
    
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘“complete” order missing on app with custom status’ is closed to new replies.