Firstly, you are going to need to create a Child Theme, for your WordPress/WooCommerce website.
Once created, simply insert the following code, into the functions.php
file, within your Child Theme:
<?php
// Remove Default WooCommerce Product Images/Placeholders.
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
// Create conditional logic function.
function logged_in_images(){
// If site visitor is Logged in, display Default WooCommerce Product Images/Placeholder.
if ( is_user_logged_in() ) {
echo woocommerce_show_product_images();
}
// If site visitor is not logged in, display the following Image instead.
else {
echo '<img src=http://vaporcenter.be/theme/Wholesale/img/placeholders/default.jpg?1504084579>';
};
}
// We are inserting ('Hooking' into) the above function into where the Default WooCommerce Product Image/Placeholder was, before we removed it.
add_action( 'woocommerce_before_single_product_summary', 'logged_in_images', 20 );
?>
Be sure to replace http://vaporcenter.be/theme/Wholesale/img/placeholders/default.jpg?1504084579 with your desired image.
Don't forget, you can remove the comments (// ...) from the code. They are there, to just help explain what is happening.
I have tested the above code and it does work.
Best of luck!
If you receive an error
- Step One: Using an FTP client, such as Filezilla, go into your Root Folder (Where you installed WordPress).
- Look for a file entitled
wp-config.php
and drag this to your computer.
- Open the file, using Notepad/Notepad++ and look for the line
define('WP_DEBUG', false);
and change 'false' to 'true'.
- Drag the
wp-config.php
file back from where you got it from.
- Refresh the page you are having an issue. You should then see an error message, which will be helpful in addressing how to resolve any issues.
- Once you have resolved your issue, and your website is back in working order, head back into your
wp-config.php
and change 'true' back to 'false'.