HPOS issue with add_meta_boxes hook
-
I have issue with add_meta_boxes hook when HPOS feature is enabled. To start with what I want to achieve. I want to add meta box data to order details page. This meta box contains some information about the order tracking and it is shown in the top right of the order details page. Here is the code that I am using:
add_action(‘add_meta_boxes’, array($this, ‘add_shipping_box’), 10, 2);
public function add_shipping_box($page, $post)
{
if ((‘shop_order’ === $page && $post && ‘auto-draft’ !== $post->post_status)) {
$controller = new Order_Details_Controller();
add_meta_box(
‘shipping-modal’,
__(‘Shipping’, ‘pro-shipping’),
array($controller, ‘render’),
‘shop_order’,
‘side’,
‘core’
);
}
}With this code render method is successfully executed. However, when I enabled HPOS feature, I noticed that my render method is never called. After debugging this issue, I found the following order of execution depending if HPOS is enabled or disabled:
HPOS is disabled:
1) add_shipping_box
2) show_screen_options
3) render_meta_boxes_preferences()
4) renderHPOS is enabled:
1) show_screen_options
2) render_meta_boxes_preferences()
3) add_shipping_boxrender is not called. How to fix this issue ? Is there any other hook that I could use for creating meta boxes ?
- The topic ‘HPOS issue with add_meta_boxes hook’ is closed to new replies.