Display Content Above Add to Cart in Single Product Page in WooCommerce?

A customer of mine chose to include a little notice (“40-day merchandise exchange offered”) simply over the Add to Cart button on the WooCommerce single item page.

By and by, it’s extremely straightforward. Simply duplicate/paste the accompanying code in your functions.php layout document:

The PHP snippet to show text above Add to Cart:


<span style="font-weight: 400;">add_action( ‘woocommerce_single_product_summary’, ‘wbcomdesign_show_return_policy’, 20 );</span><span style="font-weight: 400;"> </span>

<span style="font-weight: 400;">function wbcomdesign_show_return_policy() </span>

<span style="font-weight: 400;">{</span>

<span style="font-weight: 400;">    echo ‘<p class="wbcom">40-day return policy offered. See Terms and Conditions for details.</p>’;</span>

<span style="font-weight: 400;">}</span>


The CSS customization

The HTML paragraph tag has an “id” so that you can style it via CSS. In my example I wrote this in the custom.css file:


<span style="font-weight: 400;">.wbcom {</span>

<span style="font-weight: 400;">text-align: center;</span>

<span style="font-weight: 400;">font-style: italic;</span>

<span style="font-weight: 400;">Font-size: 12px;</span>

<span style="font-weight: 400;">}</span>



Here’s the WooCommerce final result:

Leave a Reply

Your email address will not be published. Required fields are marked *