7Pillars.io, bLabs Ventures’ ‘Marketing On Demand’ shop, is built on a few platforms, WooCommerce being a major one for the foundation of our e-commerce needs. The WooCommerce interface by default allows for a user to upload a series of images associated with each product. This works fine for selling clothing, candy, or other tangible goods – but in the case of our ‘Marketing On Demand’ services, we felt that a video explaining the service would be much more effective in place of a standard featured image. There are several plug-ins that may be able to achieve some version of this – but I felt our need was too specific and thus, delved into a custom solution.Below is a step-by-step solution of what I did to achieve the following acceptance criteria: 1. Create a field on a WooCommerce product page that accepts a video embed code. 2. If the field is NOT empty, display this video in place of featured image on the single-product page. If the field IS empty, show the featured image instead. 3. ONLY show this video on the single product page. Use the featured image on collection pages, cart pages, e-mails, and anywhere else it might appear. With that in mind, let’s get started. To be clear, all code changes should be made within a child theme. If you aren’t already doing that, here’s the official WP documentation on Child Themes – https:\/\/developer.wordpress.org\/themes\/advanced-topics\/child-themes\/ STEP 1 – CREATE A NEW ‘PRODUCT VIDEO’ FIELD IN THE WC PRODUCT EDITOR. PASTE THE FOLLOWING CODE AT THE BOTTOM OF YOUR FUNCTIONS.PHP FILE.woocommerce_product_options_general_product_data hooks into the output of the ‘Product Data’ tab. There are more arguments available for woocommerce_wp_textarea_input, the above example only uses a few. See the function definition from WC docs for more info on that. Now that we’ve created the field, we need to make sure the data is saved when we publish\/update our product. To do this we hook into woocommerce_process_product_meta. Paste the below at the bottom your functions.php file.STEP 2 – OUTPUT THE VIDEO ON THE PRODUCT PAGE To do this, we’ll need to modify the woocommerce single-product template file. To do this, create the following directories\/file in your child theme: \/your-child-theme\/woocommerce\/single-product\/product-image.php Cut and paste the below as the contents of the new product-image file.As illustrated in the comment blocks, this template also contains an option to output the featured image underneath the video. If you don’t want that, simply erase these 3 lines.And with that, voila! An iframe\/embed code taken from youtube, pasted into the field below, yields a responsive, featured video in place of our featured image.That’s it! I would love to hear your questions, and also any modifications, customizations, and improvements you were able to attach to the above snippets. Happy PHPing.