Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Bugs & Fixes 2 years ago
Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
I want to remove, for shop-managers, the ability to mark an order as completed. To do so, I used the following based on "Hide a specific action button conditionally in Woocommerce admin Orders list"answer in my theme's functions.php file:
add_filter( 'woocommerce_admin_order_actions', 'custom_admin_order_actions', 900, 2 ); function custom_admin_order_actions( $actions, $the_order ){ if(isset(wp_get_current_user()->roles[0]) && wp_get_current_user()->roles[0] == 'shop-manager') unset($actions['complete']); return $actions; }
By this, I succesfully removed the complete button from the shop_order page. However, the shop-manager is still able to complete the order using the Complete button that appears in the order preview. To avoid this, I tried the next action after the previous one:
add_action( 'woocommerce_admin_order_preview_start', 'custom_display_order_data_in_admin' ); function custom_display_order_data_in_admin(){ // Call the stored value and display it echo 'Class = "button hidden wc-action-button wc-action-button-complete complete"'; }
However, this does not remove the button from the preview window because it does not substitute the line in the code.
Is there a way to remove this ability from the shop_order page and the order preview at once? If not, how can I hide this button from the preview window?
To remove the "complete" update order status button from admin order preview for "Shop manager" user role, use the following:
add_filter( 'woocommerce_admin_order_preview_actions', 'filter_admin_order_preview_actions', 10, 2 ); function filter_admin_order_preview_actions( $actions, $order ) { if( current_user_can('shop-manager') && isset($actions['status']['actions']['complete']) ) { unset($actions['status']['actions']['complete']); } return $actions; }
Code goes in function.php file of your active child theme (or active theme). Tested and works.
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 10 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 9 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.