I would like to change my default status in WooCommerce Admin Dashboard widget to custom status from the plugin order status manager.
So I found the status_widget_order_rows
hook code in the docs from WooCommerce and addded this to my functions.php, i replaced all the default statuses to my custom statuses 'needs changes' = wc-change
and 'waiting for approval' = wc-waiting
. I saved it but nothing happened.
I thought that when i remove the hook and replace it with mine custom hook, it will be shown, but this didn't happen.
I thought that when i add manually the status in mine functions.php, and then hook to the status it will show, but that didn't either.
function custom_remove_status_widget_order_rows() {
remove_action('WC_Admin_Dashboard', 'status_widget_order_rows' );
add_action('WC_Admin_Dashboard', 'custom_status_widget_order_rows', 10, 2);}
function custom_status_widget_order_rows() {
if ( ! current_user_can( 'edit_shop_orders' ) ) {
return;
}
$change_count = 0;
$waiting_count = 0;
foreach ( wc_get_order_types( 'order-count' ) as $type ) {
$counts = (array) wp_count_posts( $type );
$change_count += isset( $counts['wc-change'] ) ? $counts['wc-change'] : 0;
$waiting_count += isset( $counts['wc-waiting'] ) ? $counts['wc-waiting'] : 0;
}
?>
<li class="waiting-orders">
<a href="<?php echo admin_url( 'edit.php?post_status=wc-waiting&post_type=shop_order' ); ?>">
<?php
/* translators: %s: order count */
printf(
_n( '<strong>%s order</strong> waiting to be approved', '<strong>%s orders</strong> awaiting waiting', $waiting_count, 'woocommerce' ),
$waiting_count
);
?>
</a>
</li>
<li class="change-orders">
<a href="<?php echo admin_url( 'edit.php?post_status=wc-change&post_type=shop_order' ); ?>">
<?php
/* translators: %s: order count */
printf(
_n( '<strong>%s order</strong> needs changes', '<strong>%s orders</strong> are changed', $change_count, 'woocommerce' ),
$rejected_count
);
?>
</a>
</li>
<?php
}?>
Somehow i need to load first the statuses from the plugin and then override the default woocommerce class, and then add rows.
Here is the link to the plugin -> docs.woocommerce.com/document/woocommerce-order-status-manager/
But i am beginner php, so i hope someone can help me with this?
Thanks in advance
WC_Admin_Dashboard is not a hook.
You should use woocommerce_after_dashboard_status_widget.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.