On HPOS environments the edit subscription screen metaboxes were appearing in the incorrect order - the line items meta box appeared above the subscription data. The reason this happens is because of slight differences in how the metaboxes get registered on HPOS and CPT environments.
On CPT the add_meta_boxes hook is triggered by WordPress core and we can register our metaboxes before WC do for our subscription data to appear first.
On HPOS the add_meta_boxes hook is triggered by WooCommerce core after they have registered their metaboxes. This results in our metaboxes appearing after theirs.
Unforunetly WP remembers the order that metaboxes are registered and so this PR fixes that by forcibly removing the order items metabox from the global and re-registers it after we've registered the subscriptions-related ones.
How to test this PR
Enable HPOS.
Purchase a subscription.
Go to the WooCommerce > Subscriptions list table.
Click on a subscription to edit it.
On trunk you notice that the line items metabox appears at the top of the screen (see screenshot above).
On this branch the metabox order is correct. Subscription-data -> line items -> downloads -> custom meta - related orders etc.
Note
This change shouldn't impact CPT stores at all.
Product impact
[x] Added changelog entry (or does not apply)
[ ] Will this PR affect WooCommerce Subscriptions? yes/no/tbc, add issue ref
[ ] Will this PR affect WooCommerce Payments? yes/no/tbc, add issue ref
[ ] Added deprecated functions, hooks or classes to the spreadsheet
Fixes #338
Description
On HPOS environments the edit subscription screen metaboxes were appearing in the incorrect order - the line items meta box appeared above the subscription data. The reason this happens is because of slight differences in how the metaboxes get registered on HPOS and CPT environments.
On CPT the
add_meta_boxes
hook is triggered by WordPress core and we can register our metaboxes before WC do for our subscription data to appear first.On HPOS the
add_meta_boxes
hook is triggered by WooCommerce core after they have registered their metaboxes. This results in our metaboxes appearing after theirs.Unforunetly WP remembers the order that metaboxes are registered and so this PR fixes that by forcibly removing the order items metabox from the global and re-registers it after we've registered the subscriptions-related ones.
How to test this PR
trunk
you notice that the line items metabox appears at the top of the screen (see screenshot above).Product impact