• Resolved bsatsangi

    (@bsatsangi)


    i use below 2 codes to control the visibility of order status dropdown menu on the bulk order page and single order page, but these codes are not working after activating HPOS.

    code 1

    add_filter( 'bulk_actions-edit-shop_order', 'filter_dropdown_bulk_actions_shop_order', 20, 1 );
    function filter_dropdown_bulk_actions_shop_order( $actions ) {
        $new_actions = [];
        foreach( $actions as $key => $option ){
            // Targeting "shop_manager" | order statuses "completed"
            if( current_user_can('shop_manager') && in_array( $key, array('mark_completed') ) ){
                $new_actions[$key] = $option;
            }
        }
        if( sizeof($new_actions) > 0 ) {
            return $new_actions;
        }
        return $actions;
    }

    code 2

    add_filter('wc_order_statuses', 'filter_order_statuses');
    function filter_order_statuses($order_statuses) {
        global $pagenow;
    
        if( $pagenow === 'post.php' || $pagenow === 'post-new.php' ) {
            $new_order_statuses = array();
    
            foreach ($order_statuses as $key => $option ) {
                // Targeting "shop_manager" | order statuses "completed"
                if( current_user_can('shop_manager') && in_array( $key, array('wc-completed') ) ){
                    $new_order_statuses[$key] = $option;
                }
            }
            if( sizeof($new_order_statuses) > 0 ) {
                return $new_order_statuses;
            }
        }
        return $order_statuses;
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi there @bsatsangi ??

    Thanks for reaching out to Woo Support!

    i use below 2 codes to control the visibility of order status dropdown menu on the bulk order page and single order page, but these codes are not working after activating HPOS.

    This sounds like functionality outside what’s included out-of-the-box with WooCommerce.

    Feel free to reach out to the support channel of where the code was shared from, as they would be in a better position to assist you.

    Furthermore, it might be a good idea to share this resource on HPOS there, also.

    I trust that points you in the right direction, but if you have more questions, let us know.

    We’re happy to help.

    • This reply was modified 1 year, 2 months ago by anastas10s. Reason: shared HPOS resource link
    Thread Starter bsatsangi

    (@bsatsangi)

    i understand that, looks like the hook used in my code is not recognized by HPOS, so i was wondering if someone from the community knows the equivalent hook for HPOS.

    i want to wait a bit to see if someone can help, before i close this thread.

    Hey, @bsatsangi!

    i want to wait a bit to see if someone can help, before i close this thread.

    No worries! We can leave it open for a bit.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there too.

    Have a wonderful day!

    ari

    (@arihant2301)

    Did you find a solution? Stuck in the same situation.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘code not working after activating HPOS’ is closed to new replies.