Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add meta boxes for custom taxonomies in order edit screens #38676

Merged
merged 4 commits into from Jun 14, 2023
Merged

Conversation

vedanshujain
Copy link
Contributor

@vedanshujain vedanshujain commented Jun 12, 2023

Submission Review Guidelines:

Changes proposed in this Pull Request:

This PR adds support to display taxonomy widgets on the order edit screen for HPOS, when a taxonomy is registered for the shop_order post type. This is already done by WP core for post edit screens, so we add similar functionality for HPOS as well.

Additionally, this also fixes a bug when a taxonomy with a default term is registered for order, but it does not get automatically added to the new orders.

Closes #38560

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

First, we are going to register a custom taxonomy for orders, by adding the following code snippet:

function register_custom_taxonomy_gh_38676() {
	register_taxonomy(
		'custom_tag',
		'shop_order',
		array(
			'labels' => array(
				'name' => 'Custom Tag',
			),
			'default_term' => 'new_tag',
		),
	);
	register_taxonomy(
		'custom_category',
		'shop_order',
		array(
			'labels' => array(
				'name' => 'Custom Category',
			),
			'default_term' => 'new_category',
			'hierarchical' => true,
		),
	);
}
add_action( 'init', 'register_custom_taxonomy_gh_38676' );
  1. Switch to HPOS as an authoritative data table.
  2. In the sidebar, you should see the following two widgets for custom taxonomies we registered, like so:
Screenshot 2023-06-12 at 6 31 19 PM
  1. Add and remove categories and tags and click on update to make sure that changes persists, similar to how it works when posts are authoritative. By default, the tag new_tag and category new_category will already be applied to new order.

@github-actions github-actions bot added focus: react admin [team:Ghidorah] plugin: woocommerce Issues related to the WooCommerce Core plugin. labels Jun 12, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jun 12, 2023

Test Results Summary

Commit SHA: c8114f3

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 48s
E2E Tests1950010020514m 59s

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

@vedanshujain vedanshujain marked this pull request as ready for review June 12, 2023 13:03
@vedanshujain vedanshujain requested review from a team and Konamiman and removed request for a team June 13, 2023 07:36
@github-actions
Copy link
Contributor

Hi @Konamiman,

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

@Konamiman Konamiman merged commit e4f3273 into trunk Jun 14, 2023
19 checks passed
@Konamiman Konamiman deleted the fix/38560 branch June 14, 2023 13:47
@github-actions github-actions bot added this to the 7.9.0 milestone Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: woocommerce Issues related to the WooCommerce Core plugin.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[HPOS]: Support post_categories_meta_box and post_tags_meta_box equivalent for HPOS order edit screen
2 participants