Add required filters to allow custom order item types

This commit is contained in:
JeroenSormani 2017-03-20 10:37:06 +01:00
parent adfd955194
commit 373bdda4f8
2 changed files with 7 additions and 3 deletions

View File

@ -652,13 +652,13 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
* @return string group
*/
protected function type_to_group( $type ) {
$type_to_group = array(
$type_to_group = apply_filters( 'woocommerce_order_type_to_group', array(
'line_item' => 'line_items',
'tax' => 'tax_lines',
'shipping' => 'shipping_lines',
'fee' => 'fee_lines',
'coupon' => 'coupon_lines',
);
) );
return isset( $type_to_group[ $type ] ) ? $type_to_group[ $type ] : '';
}

View File

@ -100,8 +100,12 @@ class WC_Order_Factory {
case 'tax' :
$classname = 'WC_Order_Item_Tax';
break;
default :
$classname = apply_filters( 'woocommerce_get_order_item_classname', $classname, $item_type, $item_id );
break;
}
if ( $classname ) {
if ( class_exists( $classname ) ) {
try {
// Try to get from cache, otherwise create a new object,
$item = wp_cache_get( 'object-' . $id, 'order-items' );