Merge pull request #13665 from JeroenSormani/custom-order-item

Add required filters to allow custom order item types
This commit is contained in:
Mike Jolley 2017-03-21 12:08:28 +00:00 committed by GitHub
commit 78d564e02c
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, $id );
break;
}
if ( $classname ) {
if ( $classname && class_exists( $classname ) ) {
try {
// Try to get from cache, otherwise create a new object,
$item = wp_cache_get( 'object-' . $id, 'order-items' );