[REST API] Fixed variation date_created and date_updated

cc @mikejolley
This commit is contained in:
Claudio Sanches 2016-06-09 12:36:06 -03:00
parent 2de65d2fac
commit 745f161456
4 changed files with 83 additions and 74 deletions

View File

@ -502,10 +502,12 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
continue;
}
$post_data = get_post( $variation->get_variation_id() );
$variations[] = array(
'id' => $variation->get_variation_id(),
'date_created' => wc_rest_prepare_date_response( $variation->get_post_data()->post_date_gmt ),
'date_modified' => wc_rest_prepare_date_response( $variation->get_post_data()->post_modified_gmt ),
'date_created' => wc_rest_prepare_date_response( $post_data->post_date_gmt ),
'date_modified' => wc_rest_prepare_date_response( $post_data->post_modified_gmt ),
'permalink' => $variation->get_permalink(),
'sku' => $variation->get_sku(),
'price' => $variation->get_price(),

View File

@ -348,13 +348,16 @@ class WC_API_Products extends WC_API_Resource {
$variation = $product->get_child( $child_id );
if ( ! $variation->exists() )
if ( ! $variation->exists() ) {
continue;
}
$post_data = get_post( $variation->get_variation_id() );
$variations[] = array(
'id' => $variation->get_variation_id(),
'created_at' => $this->server->format_datetime( $variation->get_post_data()->post_date_gmt ),
'updated_at' => $this->server->format_datetime( $variation->get_post_data()->post_modified_gmt ),
'created_at' => $this->server->format_datetime( $post_data->post_date_gmt ),
'updated_at' => $this->server->format_datetime( $post_data->post_modified_gmt ),
'downloadable' => $variation->is_downloadable(),
'virtual' => $variation->is_virtual(),
'permalink' => $variation->get_permalink(),

View File

@ -740,10 +740,12 @@ class WC_API_Products extends WC_API_Resource {
continue;
}
$post_data = get_post( $variation->get_variation_id() );
$variations[] = array(
'id' => $variation->get_variation_id(),
'created_at' => $this->server->format_datetime( $variation->get_post_data()->post_date_gmt ),
'updated_at' => $this->server->format_datetime( $variation->get_post_data()->post_modified_gmt ),
'created_at' => $this->server->format_datetime( $post_data->post_date_gmt ),
'updated_at' => $this->server->format_datetime( $post_data->post_modified_gmt ),
'downloadable' => $variation->is_downloadable(),
'virtual' => $variation->is_virtual(),
'permalink' => $variation->get_permalink(),

View File

@ -1199,10 +1199,12 @@ class WC_API_Products extends WC_API_Resource {
continue;
}
$post_data = get_post( $variation->get_variation_id() );
$variations[] = array(
'id' => $variation->get_variation_id(),
'created_at' => $this->server->format_datetime( $variation->get_post_data()->post_date_gmt ),
'updated_at' => $this->server->format_datetime( $variation->get_post_data()->post_modified_gmt ),
'created_at' => $this->server->format_datetime( $post_data->post_date_gmt ),
'updated_at' => $this->server->format_datetime( $post_data->post_modified_gmt ),
'downloadable' => $variation->is_downloadable(),
'virtual' => $variation->is_virtual(),
'permalink' => $variation->get_permalink(),