[REST API] Fixed variation date_created and date_updated
cc @mikejolley
This commit is contained in:
parent
2de65d2fac
commit
745f161456
|
@ -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(),
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -740,41 +740,43 @@ 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 ),
|
||||
'downloadable' => $variation->is_downloadable(),
|
||||
'virtual' => $variation->is_virtual(),
|
||||
'permalink' => $variation->get_permalink(),
|
||||
'sku' => $variation->get_sku(),
|
||||
'price' => wc_format_decimal( $variation->get_price(), $prices_precision ),
|
||||
'regular_price' => wc_format_decimal( $variation->get_regular_price(), $prices_precision ),
|
||||
'sale_price' => $variation->get_sale_price() ? wc_format_decimal( $variation->get_sale_price(), $prices_precision ) : null,
|
||||
'taxable' => $variation->is_taxable(),
|
||||
'tax_status' => $variation->get_tax_status(),
|
||||
'tax_class' => $variation->get_tax_class(),
|
||||
'managing_stock' => $variation->managing_stock(),
|
||||
'stock_quantity' => (int) $variation->get_stock_quantity(),
|
||||
'in_stock' => $variation->is_in_stock(),
|
||||
'backordered' => $variation->is_on_backorder(),
|
||||
'purchaseable' => $variation->is_purchasable(),
|
||||
'visible' => $variation->variation_is_visible(),
|
||||
'on_sale' => $variation->is_on_sale(),
|
||||
'weight' => $variation->get_weight() ? wc_format_decimal( $variation->get_weight(), 2 ) : null,
|
||||
'dimensions' => array(
|
||||
'length' => $variation->length,
|
||||
'width' => $variation->width,
|
||||
'height' => $variation->height,
|
||||
'unit' => get_option( 'woocommerce_dimension_unit' ),
|
||||
),
|
||||
'shipping_class' => $variation->get_shipping_class(),
|
||||
'shipping_class_id' => ( 0 !== $variation->get_shipping_class_id() ) ? $variation->get_shipping_class_id() : null,
|
||||
'image' => $this->get_images( $variation ),
|
||||
'attributes' => $this->get_attributes( $variation ),
|
||||
'downloads' => $this->get_downloads( $variation ),
|
||||
'download_limit' => (int) $product->download_limit,
|
||||
'download_expiry' => (int) $product->download_expiry,
|
||||
'id' => $variation->get_variation_id(),
|
||||
'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(),
|
||||
'sku' => $variation->get_sku(),
|
||||
'price' => wc_format_decimal( $variation->get_price(), $prices_precision ),
|
||||
'regular_price' => wc_format_decimal( $variation->get_regular_price(), $prices_precision ),
|
||||
'sale_price' => $variation->get_sale_price() ? wc_format_decimal( $variation->get_sale_price(), $prices_precision ) : null,
|
||||
'taxable' => $variation->is_taxable(),
|
||||
'tax_status' => $variation->get_tax_status(),
|
||||
'tax_class' => $variation->get_tax_class(),
|
||||
'managing_stock' => $variation->managing_stock(),
|
||||
'stock_quantity' => (int) $variation->get_stock_quantity(),
|
||||
'in_stock' => $variation->is_in_stock(),
|
||||
'backordered' => $variation->is_on_backorder(),
|
||||
'purchaseable' => $variation->is_purchasable(),
|
||||
'visible' => $variation->variation_is_visible(),
|
||||
'on_sale' => $variation->is_on_sale(),
|
||||
'weight' => $variation->get_weight() ? wc_format_decimal( $variation->get_weight(), 2 ) : null,
|
||||
'dimensions' => array(
|
||||
'length' => $variation->length,
|
||||
'width' => $variation->width,
|
||||
'height' => $variation->height,
|
||||
'unit' => get_option( 'woocommerce_dimension_unit' ),
|
||||
),
|
||||
'shipping_class' => $variation->get_shipping_class(),
|
||||
'shipping_class_id' => ( 0 !== $variation->get_shipping_class_id() ) ? $variation->get_shipping_class_id() : null,
|
||||
'image' => $this->get_images( $variation ),
|
||||
'attributes' => $this->get_attributes( $variation ),
|
||||
'downloads' => $this->get_downloads( $variation ),
|
||||
'download_limit' => (int) $product->download_limit,
|
||||
'download_expiry' => (int) $product->download_expiry,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1199,42 +1199,44 @@ 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 ),
|
||||
'downloadable' => $variation->is_downloadable(),
|
||||
'virtual' => $variation->is_virtual(),
|
||||
'permalink' => $variation->get_permalink(),
|
||||
'sku' => $variation->get_sku(),
|
||||
'price' => $variation->get_price(),
|
||||
'regular_price' => $variation->get_regular_price(),
|
||||
'sale_price' => $variation->get_sale_price() ? $variation->get_sale_price() : null,
|
||||
'taxable' => $variation->is_taxable(),
|
||||
'tax_status' => $variation->get_tax_status(),
|
||||
'tax_class' => $variation->get_tax_class(),
|
||||
'managing_stock' => $variation->managing_stock(),
|
||||
'stock_quantity' => $variation->get_stock_quantity(),
|
||||
'in_stock' => $variation->is_in_stock(),
|
||||
'backorders_allowed' => $variation->backorders_allowed(),
|
||||
'backordered' => $variation->is_on_backorder(),
|
||||
'purchaseable' => $variation->is_purchasable(),
|
||||
'visible' => $variation->variation_is_visible(),
|
||||
'on_sale' => $variation->is_on_sale(),
|
||||
'weight' => $variation->get_weight() ? $variation->get_weight() : null,
|
||||
'dimensions' => array(
|
||||
'length' => $variation->length,
|
||||
'width' => $variation->width,
|
||||
'height' => $variation->height,
|
||||
'unit' => get_option( 'woocommerce_dimension_unit' ),
|
||||
),
|
||||
'shipping_class' => $variation->get_shipping_class(),
|
||||
'shipping_class_id' => ( 0 !== $variation->get_shipping_class_id() ) ? $variation->get_shipping_class_id() : null,
|
||||
'image' => $this->get_images( $variation ),
|
||||
'attributes' => $this->get_attributes( $variation ),
|
||||
'downloads' => $this->get_downloads( $variation ),
|
||||
'download_limit' => (int) $product->download_limit,
|
||||
'download_expiry' => (int) $product->download_expiry,
|
||||
'id' => $variation->get_variation_id(),
|
||||
'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(),
|
||||
'sku' => $variation->get_sku(),
|
||||
'price' => $variation->get_price(),
|
||||
'regular_price' => $variation->get_regular_price(),
|
||||
'sale_price' => $variation->get_sale_price() ? $variation->get_sale_price() : null,
|
||||
'taxable' => $variation->is_taxable(),
|
||||
'tax_status' => $variation->get_tax_status(),
|
||||
'tax_class' => $variation->get_tax_class(),
|
||||
'managing_stock' => $variation->managing_stock(),
|
||||
'stock_quantity' => $variation->get_stock_quantity(),
|
||||
'in_stock' => $variation->is_in_stock(),
|
||||
'backorders_allowed' => $variation->backorders_allowed(),
|
||||
'backordered' => $variation->is_on_backorder(),
|
||||
'purchaseable' => $variation->is_purchasable(),
|
||||
'visible' => $variation->variation_is_visible(),
|
||||
'on_sale' => $variation->is_on_sale(),
|
||||
'weight' => $variation->get_weight() ? $variation->get_weight() : null,
|
||||
'dimensions' => array(
|
||||
'length' => $variation->length,
|
||||
'width' => $variation->width,
|
||||
'height' => $variation->height,
|
||||
'unit' => get_option( 'woocommerce_dimension_unit' ),
|
||||
),
|
||||
'shipping_class' => $variation->get_shipping_class(),
|
||||
'shipping_class_id' => ( 0 !== $variation->get_shipping_class_id() ) ? $variation->get_shipping_class_id() : null,
|
||||
'image' => $this->get_images( $variation ),
|
||||
'attributes' => $this->get_attributes( $variation ),
|
||||
'downloads' => $this->get_downloads( $variation ),
|
||||
'download_limit' => (int) $product->download_limit,
|
||||
'download_expiry' => (int) $product->download_expiry,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue