Snippets

Visser Labs Showing conditional notices on the Single Product and My Account screen #1

Created by Michael Visser
<?php

// Conditionally display a persistent notice on the Single Product screen
function custom_woocommerce_before_main_content() {

	// Check that we are on the Single Product screen
    if( !is_product() )
	    return;

    $text = 'Hi there, if you have any questions get in touch!';
    echo '
<div class="woocommerce-info">
	' . $text . ' <strong>:)</strong>
</div>
    ';

}
add_action( 'woocommerce_before_main_content', 'custom_woocommerce_before_main_content' );

?>

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.