Enable metabox on only shop orders with ACF

29 Views Asked by At

I am trying to enable the metabox only for shop_orders, as ACF disables them. I am aware of the general filter add_filter('acf/settings/remove_wp_meta_box', '__return_true');, but I want to limit this only to shop orders, as there are essential fields for us. But I do not want to enable it throughout all post types.

I struggle to call the condition for shop_order. It's not finding the if statement:

add_action( 'admin_init', 'enable_metabox' );
function enable_metabox(){
    if( get_post_type() === 'shop_order' ){
        acf_update_setting('remove_wp_meta_box', false);
    }
}

I have tried with $post_id, no luck.

0

There are 0 best solutions below