WC_Order_Factory::get_class_names_for_order_ids
Gets the class name bunch of order instances should have based on their IDs.
Method of the class: WC_Order_Factory{}
Hooks from the method
Returns
Array. Array of order_id => class_name.
Usage
$result = WC_Order_Factory::get_class_names_for_order_ids( $order_ids );
- $order_ids(array) (required)
- Order IDs to get the class name for.
WC_Order_Factory::get_class_names_for_order_ids() WC Order Factory::get class names for order ids code WC 10.7.0
public static function get_class_names_for_order_ids( $order_ids ) {
$order_data_store = WC_Data_Store::load( 'order' );
if ( $order_data_store->has_callable( 'get_orders_type' ) ) {
$order_types = $order_data_store->get_orders_type( $order_ids );
} else {
$order_types = array();
foreach ( $order_ids as $order_id ) {
$order_types[ $order_id ] = $order_data_store->get_order_type( $order_id );
}
}
$order_class_names = array();
foreach ( $order_types as $order_id => $order_type ) {
$order_type_data = wc_get_order_type( $order_type );
if ( $order_type_data ) {
$order_class_names[ $order_id ] = $order_type_data['class_name'];
} else {
$order_class_names[ $order_id ] = false;
}
/**
* Filter classname so that the class can be overridden if extended.
*
* @param string $classname Order classname.
* @param string $order_type Order type.
* @param int $order_id Order ID.
*
* @since 3.0.0
*/
$order_class_names[ $order_id ] = apply_filters( 'woocommerce_order_class', $order_class_names[ $order_id ], $order_type, $order_id );
if ( ! class_exists( $order_class_names[ $order_id ] ) ) {
$order_class_names[ $order_id ] = false;
}
}
return $order_class_names;
}