There can be many situations where you’ll have to display notice on single product page. For example
- By one get one free
- Order by 5pm and avail free delivery
- etc
So let’s begin.
Open your theme’s functions.php file and paste the below code, and save the file.
add_action( 'woocommerce_single_product_summary', 'eplugins_display_notice', 6 );
function eplugins_display_notice() {
echo '<div class="woocommerce-message">Order by 5pm and avail free delivery!</div>';
}
Now visit your single product page.
Now Let’s see what happened with our code…
In the above code, we’ve used action hook woocommerce_single_product_summary which is used to display anything above the product title.
After that, we’ve used the function named eplugins_display_notice. Function name can be anything according to our choice. This function is being hooked on the action woocommerce_single_product_summary. This will be called after, under which respected code will be written.
Now we’ll call the woocommerce-message class to display the notice on single product page.
Wrapping Words….
Use the code and display any product related notice on single product page. If you have any suggestion or query paste in the comment section below…