Plugin Updates
This commit is contained in:
@@ -65,6 +65,30 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Product_Variations_V
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the downloads for a product variation.
|
||||
*
|
||||
* @param WC_Product_Variation $product Product variation instance.
|
||||
* @param string $context Context of the request: 'view' or 'edit'.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_downloads( $product, $context = 'view' ) {
|
||||
$downloads = array();
|
||||
|
||||
if ( $product->is_downloadable() || 'edit' === $context ) {
|
||||
foreach ( $product->get_downloads() as $file_id => $file ) {
|
||||
$downloads[] = array(
|
||||
'id' => $file_id, // MD5 hash.
|
||||
'name' => $file['name'],
|
||||
'file' => $file['file'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $downloads;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare a single variation output for response.
|
||||
*
|
||||
@@ -95,7 +119,7 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Product_Variations_V
|
||||
'purchasable' => $object->is_purchasable(),
|
||||
'virtual' => $object->is_virtual(),
|
||||
'downloadable' => $object->is_downloadable(),
|
||||
'downloads' => $this->get_downloads( $object ),
|
||||
'downloads' => $this->get_downloads( $object, $context ),
|
||||
'download_limit' => '' !== $object->get_download_limit() ? (int) $object->get_download_limit() : -1,
|
||||
'download_expiry' => '' !== $object->get_download_expiry() ? (int) $object->get_download_expiry() : -1,
|
||||
'tax_status' => $object->get_tax_status(),
|
||||
|
||||
Reference in New Issue
Block a user