From 53b1c6642708086036a8ceb69b40bf97ec3f9c1d Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Wed, 10 Dec 2014 16:28:30 -0200 Subject: [PATCH] [API] Added parent_id in products endpoint, closes #6786 --- includes/api/class-wc-api-products.php | 6 ++++++ readme.txt | 1 + 2 files changed, 7 insertions(+) diff --git a/includes/api/class-wc-api-products.php b/includes/api/class-wc-api-products.php index bc183c7ca7a..ce664235324 100644 --- a/includes/api/class-wc-api-products.php +++ b/includes/api/class-wc-api-products.php @@ -567,6 +567,7 @@ class WC_API_Products extends WC_API_Resource { 'related_ids' => array_map( 'absint', array_values( $product->get_related() ) ), 'upsell_ids' => array_map( 'absint', $product->get_upsells() ), 'cross_sell_ids' => array_map( 'absint', $product->get_cross_sells() ), + 'parent_id' => $product->post->post_parent, 'categories' => wp_get_post_terms( $product->id, 'product_cat', array( 'fields' => 'names' ) ), 'tags' => wp_get_post_terms( $product->id, 'product_tag', array( 'fields' => 'names' ) ), 'images' => $this->get_images( $product ), @@ -871,6 +872,11 @@ class WC_API_Products extends WC_API_Resource { } } + // Product parent ID for groups + if ( isset( $data['parent_id'] ) ) { + wp_update_post( array( 'ID' => $id, 'post_parent' => absint( $data['parent_id'] ) ) ); + } + // Update parent if grouped so price sorting works and stays in sync with the cheapest child $_product = wc_get_product( $id ); if ( $_product->post->post_parent > 0 || $product_type == 'grouped' ) { diff --git a/readme.txt b/readme.txt index 7d2dc95de72..a796cd9b39a 100644 --- a/readme.txt +++ b/readme.txt @@ -162,6 +162,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc * Tweak - Added 'stupidtable' script to allow order item sorting on the order screen (by name, cost, qty). * Tweak - In the cart, add variation selected data to the permalink. * Dev - API - Look up product by sku. +* Dev - API - New parent_id param for products API. * Dev - Made template debug mode set WC_TEMPLATE_DEBUG_MODE constant and remove all overrides for all template loading functions. * Dev - Switched to .scss from .less for all styles. * Dev - Included bourbon for scss mixins.