Orders API: Add parent_name to line_items for variable products
This commit is contained in:
parent
19e4c7ac7c
commit
52739ba9ee
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue