Skip to content

Conversation

@trajche
Copy link

@trajche trajche commented Dec 20, 2025

Currently, other WC Order types than Subscription are not compatible (they don't show up in the edit page) with SCF and HPOS even though they show up in the field group rules when creating them. This PR fixes that.

@github-actions
Copy link

github-actions bot commented Dec 20, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props trajche.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@trajche
Copy link
Author

trajche commented Dec 20, 2025

In order to test you would have to create a custom WC order type and then enable HPOS. By default, it will allow you to select the custom WC order type from the SCF Field Groups but it will not show the meta boxes in the custom WC order view.

Here is sample code to register a WC order type called "Charges".

wc_register_order_type(
	'shop_order_charge',
	array(
		'label'                            => __( 'Charges', 'woocommerce' ),
		'capability_type'                  => 'shop_order',
		'public'                           => true,
		'hierarchical'                     => true,
		'exclude_from_orders_screen'       => false,
		'add_order_meta_boxes'             => true,
		'exclude_from_order_count'         => true,
		'exclude_from_order_views'         => false,
		'exclude_from_order_reports'       => false,
		'exclude_from_order_sales_reports' => false,
		'class_name'                       => 'WC_Order_Charge',
		'supports'                         => array( 'title' ),
		'rewrite'                          => true,
	)
);

And the Class would be something simple:

class WC_Order_Charge extends WC_Order {

	protected $object_type = 'order_charge';

	public function get_type() {
		return 'shop_order_charge';
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant