Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the community forum?
All Topics
ming xuan

Category for orders

If i have many orders and have different order_number like
“y-ball-xxx” ( order_meta=”y-ball”) & “p-store-xxx-xxx” ( order_meta=”-store” )

Could i create two order admin list for these two kind of order type?
Because there are some different field name with order_meta.

Thanks.

4 years, 4 months ago
Stefan
Developer

Hi Ming,

Creating 2 different admin lists is not possible, at least not with our product. Since 3.8 we support multiple Column Sets where you can create multiple sets with different sets of columns. You could create 2 layouts with some columns and write your own filters for the two layouts with the WordPress filter pre_get_posts. You have to be a developer to write this. Here’s a quick example to get you started where I also use a function to get the current Column Set. This example changes the $query when on the shop_order post type and using the ‘Custom’ column set.

function cac_filter_woo_orders( $query ){
	if( $query->is_main_query() && function_exists( 'cpac' ) ) {

		// Filter results based on an Admin Columns Layout (in this case named Custom
		$storage_modal = cpac()->get_current_storage_model();
		$column_set = cpac()->get_current_storage_model()->get_layout_name(); // Column Set

		if ( 'shop_order' == $storage_modal->post_type && 'Custom' == $column_set ) {
			$meta_query = $query->get( 'meta_query' );
			$meta_query[] = array(
				'key'     => '_order_key',
				'value'   => 'y-ball',
				'compare' => 'LIKE'
			);
			$query->set( 'meta_query', $meta_query );
		}
	}

	return $query;
}
add_action( 'pre_get_posts', 'cac_filter_woo_orders' );
4 years, 4 months ago

You must be logged in to reply to this topic.