Orders API: Add parent_name to line_items for variable products

This commit is contained in:
Shiki 2020-10-22 13:43:08 -06:00 committed by Claudio Sanches
parent 19e4c7ac7c
commit 52739ba9ee
1 changed files with 6 additions and 0 deletions

View File

@ -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.