WC_Product_Data_Store_CPT::read_downloads( WC_Product $product )
Read downloads from post meta.
Description Description
Parameters Parameters
- $product
-
(Required) Product object.
Source Source
File: includes/data-stores/class-wc-product-data-store-cpt.php
protected function read_downloads( &$product ) {
$meta_values = array_filter( (array) get_post_meta( $product->get_id(), '_downloadable_files', true ) );
if ( $meta_values ) {
$downloads = array();
foreach ( $meta_values as $key => $value ) {
if ( ! isset( $value['name'], $value['file'] ) ) {
continue;
}
$download = new WC_Product_Download();
$download->set_id( $key );
$download->set_name( $value['name'] ? $value['name'] : wc_get_filename_from_url( $value['file'] ) );
$download->set_file( apply_filters( 'woocommerce_file_download_path', $value['file'], $product, $key ) );
$downloads[] = $download;
}
$product->set_downloads( $downloads );
}
}
Changelog Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |