Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Save downloadable files.
- *
- * @param WC_Product $product Product instance.
- * @param array $downloads Downloads data.
- *
- * @return WC_Product
- */
- protected function save_downloadable_files( $product, $downloads ) {
- $files = [];
- foreach ( $downloads as $key => $file ) {
- if ( empty( $file['file'] ) ) {
- continue;
- }
- $download = new WC_Product_Download();
- $download->set_id( $key );
- $download->set_name( $file['name'] ? $file['name'] : wc_get_filename_from_url( $file['file'] ) );
- $download->set_file( apply_filters( 'woocommerce_file_download_path', $file['file'], $product, $key ) );
- $files[] = $download;
- }
- $product->set_downloads( $files );
- return $product;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement