items_type_key filter and woocommerce_order_line_item_object fix

This commit is contained in:
Petar Petrov 2017-04-25 18:07:40 +03:00
parent f71a498892
commit fdb28218ea
2 changed files with 5 additions and 4 deletions

View File

@ -798,8 +798,9 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
* @return string
*/
protected function get_items_key( $item ) {
if ( is_a( $item, 'WC_Order_Item_Fee' ) ) {
if ( is_a( $item, 'WC_Order_Item_Product' ) ) {
return 'line_items';
} elseif ( is_a( $item, 'WC_Order_Item_Fee' ) ) {
return 'fee_lines';
} elseif ( is_a( $item, 'WC_Order_Item_Shipping' ) ) {
return 'shipping_lines';
@ -808,7 +809,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
} elseif ( is_a( $item, 'WC_Order_Item_Coupon' ) ) {
return 'coupon_lines';
} else {
return 'line_items';
return apply_filters( 'woocommerce_items_type_key', '', $item );
}
}

View File

@ -349,7 +349,7 @@ class WC_Checkout {
public function create_order_line_items( &$order, $cart ) {
foreach ( $cart->get_cart() as $cart_item_key => $values ) {
$product = $values['data'];
$item = apply_filters( 'woocommerce_order_line_item', new WC_Order_Item_Product(), $product);
$item = apply_filters( 'woocommerce_order_line_item_object', new WC_Order_Item_Product(), $values );
$item->legacy_values = $values; // @deprecated For legacy actions.
$item->legacy_cart_item_key = $cart_item_key; // @deprecated For legacy actions.
$item->set_props( array(