Product::youtube_videos()
Summary
Get the list of YouTube videos associated with the product
Return
(array)
Source
File: src/BigCommerce/Post_Types/Product/Product.php
public function youtube_videos() { $videos = $this->get_property( 'videos' ) ?: []; $videos = array_filter( $videos, function ( $video ) { return ! empty( $video->video_id ) && ! empty( $video->type ) && $video->type === 'youtube'; } ); usort( $videos, function ( $a, $b ) { if ( $a->sort_order === $b->sort_order ) { return ( $a->title < $b->title ) ? - 1 : 1; } return ( $a->sort_order < $b->sort_order ) ? - 1 : 1; } ); return array_map( function ( $video ) { return [ 'url' => sprintf( 'https://www.youtube.com/watch?v=%s', urlencode( $video->video_id ) ), 'embed_url' => sprintf( 'https://www.youtube.com/embed/%s', urlencode( $video->video_id ) ), 'id' => $video->video_id, 'title' => $video->title, 'description' => $video->description, 'length' => $video->length, ]; }, $videos ); }