WC_Abstract_Order::get_items_key()protectedWC 3.0.0

Get key for where a certain item type is stored in _items.

Method of the class: WC_Abstract_Order{}

Hooks from the method

Return

String.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_items_key( $item );
$item(string) (required)
object Order item (product, shipping, fee, coupon, tax).

Changelog

Since 3.0.0 Introduced.

WC_Abstract_Order::get_items_key() code WC 8.7.0

protected function get_items_key( $item ) {
	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';
	} elseif ( is_a( $item, 'WC_Order_Item_Tax' ) ) {
		return 'tax_lines';
	} elseif ( is_a( $item, 'WC_Order_Item_Coupon' ) ) {
		return 'coupon_lines';
	}
	return apply_filters( 'woocommerce_get_items_key', '', $item );
}