From 52739ba9ee743f5f3f39dd87c60da26266aa2eec Mon Sep 17 00:00:00 2001 From: Shiki Date: Thu, 22 Oct 2020 13:43:08 -0600 Subject: [PATCH] Orders API: Add parent_name to line_items for variable products --- .../Version2/class-wc-rest-orders-v2-controller.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php b/includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php index 01a67019e4f..195c86e3d16 100644 --- a/includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php +++ b/includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php @@ -170,6 +170,12 @@ class WC_REST_Orders_V2_Controller extends WC_REST_CRUD_Controller { if ( is_callable( array( $item, 'get_product' ) ) ) { $data['sku'] = $item->get_product() ? $item->get_product()->get_sku() : null; $data['price'] = $item->get_quantity() ? $item->get_total() / $item->get_quantity() : 0; + + if ( is_callable( array( $item->get_product(), 'get_parent_data' ) ) ) { + $data['parent_name'] = $item->get_product()->get_title(); + } else { + $data['parent_name'] = null; + } } // Format taxes.