Merge branch 'pr/14678'

This commit is contained in:
Mike Jolley 2017-05-23 19:16:37 +01:00
commit 6dfdc86111
3 changed files with 8 additions and 6 deletions

View File

@ -810,9 +810,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
return 'tax_lines'; return 'tax_lines';
} elseif ( is_a( $item, 'WC_Order_Item_Coupon' ) ) { } elseif ( is_a( $item, 'WC_Order_Item_Coupon' ) ) {
return 'coupon_lines'; return 'coupon_lines';
} else {
return '';
} }
return apply_filters( 'woocommerce_get_items_key', '', $item );
} }
/** /**

View File

@ -350,8 +350,12 @@ class WC_Checkout {
*/ */
public function create_order_line_items( &$order, $cart ) { public function create_order_line_items( &$order, $cart ) {
foreach ( $cart->get_cart() as $cart_item_key => $values ) { foreach ( $cart->get_cart() as $cart_item_key => $values ) {
/**
* Filter hook to get inital item object.
* @since 3.1.0
*/
$item = apply_filters( 'woocommerce_checkout_create_order_line_item_object', new WC_Order_Item_Product(), $cart_item_key, $values, $order );
$product = $values['data']; $product = $values['data'];
$item = new WC_Order_Item_Product();
$item->legacy_values = $values; // @deprecated For legacy actions. $item->legacy_values = $values; // @deprecated For legacy actions.
$item->legacy_cart_item_key = $cart_item_key; // @deprecated For legacy actions. $item->legacy_cart_item_key = $cart_item_key; // @deprecated For legacy actions.
$item->set_props( array( $item->set_props( array(

View File

@ -89,11 +89,10 @@ class WC_Order_Factory {
case 'tax' : case 'tax' :
$classname = 'WC_Order_Item_Tax'; $classname = 'WC_Order_Item_Tax';
break; break;
default :
$classname = apply_filters( 'woocommerce_get_order_item_classname', $classname, $item_type, $id );
break;
} }
$classname = apply_filters( 'woocommerce_get_order_item_classname', $classname, $item_type, $id );
if ( $classname && class_exists( $classname ) ) { if ( $classname && class_exists( $classname ) ) {
try { try {
return new $classname( $id ); return new $classname( $id );