A client of mine decided to add a little notice (“30-day return policy offered”) just above the Add to Cart button on the WooCommerce single product page. There is no need to say this will allow her to increase the click-through rate and her sales conversion rate.
So, how to do this? Once again, it’s very simple. Just copy/paste the following snippet in your functions.php template file:
The PHP snippet to show text above Add to Cart:
/** * @snippet Adds notice at single product page above add to cart * @how-to Get CustomizeWoo.com FREE * @sourcecode https://businessbloomer.com/?p=349 * @author Rodolfo Melogli * @testedwith WooCommerce 3.4.5 */ add_action( 'woocommerce_single_product_summary', 'bbloomer_show_return_policy', 20 ); function bbloomer_show_return_policy() { echo '<p class="rtrn">30-day return policy offered. See Terms and Conditions for details.</p>'; }
The CSS customization
As you may have noticed, 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:
.rtrn { text-align: center; font-style: italic; }
What if I only want the text to show on items with a chosen tag?
I suggest you take a look at “conditional logic”: https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/. Enjoy
Hi,
Thanks for this useful content.
How can i customize to showing that text only for some products not at all single pages?
(For example, do not show in βout of stockβ products.)
Can you explain about it?
Thank you
With Best Regards
Hello Sam, I suggest you take a look at “conditional logic”: https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/. Enjoy π
Thank You
You are awesome and your website is exceptional
Hi! I tried adding this and it did not work. I got the error message on product page “Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘return_policy’ not found or invalid function name in /home/hearta06/public_html/wp-includes/class-wp-hook.php on line 286″. ”
Even after deleting the code, the message still appears.
Can you advise how to get rid of this?
Hello Melissa – thanks so much for your comment! Just make sure the “add_action” and the “function” use the same function name π
Hello Rodolfo, I hope you are well!
How could I do to show this message in the single product page for every product, and also add it below the product when it’s added to cart?
We want to show like a “This item will be delayed X amount of time” for some specific products and we need to change this text for every Product…. Maybe with an ACF field?
Let me know if you can help me!!
Have a nice day!
Hi Juan, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hi Rodolfo,
Thanks for all you do, love your website! This one isn’t working for me, I tried adding it to a category as described in a comment above, I wonder if it didn’t work because most of my products are in multiple categories?
Reading some other comments I came across the suggestion to VeggieShirts (love that!) of putting some extra info in a tab and since I was actually planning to use this to say something about ‘10% to charity’ and probably a link the tab idea would be a way better solution, do you happen to have a tutorial on this? I didn’t see one, I’ll look around some more π
Emily, this should help: https://docs.woocommerce.com/document/editing-product-data-tabs/#section-5 π
Hi, how do I add checkbox next to the text? Many thanks
Henry, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R
Cost price for this?
Hi Henry, sorry just saw this now. Please email me at info@businessbloomer.com and I’ll give you an estimate. Many thanks π
Awesome post, just what I was looking for. Instead of echoing text, how would I provide a link? I make jewelry and want to provide a popup of how to size bracelets. Thanks much!
Hey Tania, thanks for your comment! You can echo any HTML, including an “a” tag π
Not appearing above add to cart, it is appearing above the variations.
Thanks for your comment David! Try to use a number greater than “20” in the add_action call. Try with 30, 40, 50, 60 etc until you have it where you want π Let me know!
Hi, Rodolfo!
I want to use this code:
if ( $product->regular_price > 50 ) {
// run function
}
But I cant understand how to combine it with function:
add_action( ‘woocommerce_single_product_summary’, ‘return_policy’, 20 );
function return_policy() {
echo ’30-day return policy offered. See Terms and Conditions for details.’;
}
Can you show me exemple? I think it should be easy, but I can not.
Hey Mike, thanks so much for your comment! Just put the “echo” part inside the IF statement π
Hi ,i want to add secure payment logos just below add to cart , any thought?
Hi Zaheer! Instead of echoing text, echo the HTML of the image π That’s it!
this codes works but It applies to all the products I want to show this to specific product and that text should be below image. can you do that .. thank you
Hey Rocket, thanks so much for your comment! I suggest you take a look at “conditional logic”: https://businessbloomer.com/conditional-logic-woocommerce-tutorial/ and https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/. Let me know π
Hello,
I used the code and it shows correctly, however i’d like the “Terms and Conditions” to be a link so the customer can click and view the terms. Is this possible?
Thanks.
Actually figured it out, thanks in advance. I’m now looking to add text below the add to cart button and i’m using the below code. Everything seems correct but it adds the text next to the cart button not below. Any idea why?
Thanks.
Hey RK, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R
Hello,
If I want to change the position of the content, how can I change this script? For example I want to show something after product title.
Thank you very much!
Hey Joe, thanks for your comment! I’d recommend you watch my customization tutorial here: https://businessbloomer.com/woocommerce-customization-single-product-page and then take a look at the single product page hooks here: https://businessbloomer.com/woocommerce-visual-hook-guide-single-product-page/. Let me know π
okay i have this in my functions.php file
So what i want to do is show these addresses on the cart page . and they do . however since i have different vendors for each product i want each product to have only its vendors address. right now each product is getting all the the vendors address for all vendors which is wrong. what can i do to rectify that?
Patrick, thanks for your comment! Unfortunately this is custom work (and it’s not even my snippet) and I cannot provide a complementary solution here on the blog. Thanks a lot for your understanding! ~R
Is it possible to add a condition for price? Say, if price is greater than $50, then show text “This item qualifies for Free Shipping” ?
Thanks.
Of course! You can check what the price of the product is by adding a conditional check, something along the lines of:
Thanks, but does this work with variable products?
Hey Vuster, thanks for your comment! Yes, it works for variable products as well π
hi dear friends
i want to add the βQuantityβ word to the side of the box that displays the number in product pages.
for example-> this link:
https://www.meroeh.com/product/lovely-baby-dining-table/
I had done it in the past and Ωt worked properly, but But I updated woocommerce and βQuantityβ word is disappeared and now I can not make it.
I had done in the past by βpβ tag, but now i do not know where it was written.
can you help me pleaseee?
Hey Sara, thanks for your comment! I recommend you watch this tutorial (https://businessbloomer.com/woocommerce-customization-single-product-page/), which should help you remember what you need to do! Let me know π
I want to add accept terms and conditions button above add to cart button so when user check this box so product can be add in cart otherwise error message that you must need to accept terms and conditions.
Can you please help me about it?
Regards
Ali, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide you with a complementary solution here on the blog. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R
Hello Rodolfo,
Great tutorial! I’m selling virtual products some of them are downloadable some of them aren’t. So I’m trying to add a statement only on my downloadable product page is it possible? (I tried this code it’s adding the statement on all products)
Thanks
Thank you Suman! Yes, take a look at https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/, and specifically in the section that says “do something if product is simple, variable, external…” π
At the moment i’m building a new webstore for organic, eco-friendly t-shirts (and made without child labor) and found your tutorial. Thank you very much! Your example text is very good choosen, too. Looks very good placed on my site! Perfect! No edit, nothing. Just this super short tut. Very cool.
This are the small things, how to build/demonstrate trust. I will add a link to the TOS there, too. Sure, a new way to click away from the sale when i add a link there, but i think not much people will click there… and if they click it’s ok if they are looking for trust (and find it). Then they will come back, cause they realize the quality af the shop, the project and so on (i hope so).
Do you include there a link for your projects/clients, too? Do you think it’s important/worthy? (Look, we have nothing to hide! Trust us! [ok, answered by my self]) Do you have experience how many percent will click there and so on? How do you think about all this?
Brings me to the next point: write the TOS… Something nice looking, nothing ugly-to-read. I think it’s very important, too. My opinion is: show clear and transparent that anybody can look inside and find the trust.
Thanks again. I’m really looking forward to study your website (infos in the sidebar looked interesting + this worty tutorial here)! I think with you in my shop there is a lot of more optimization/money/attention for the project possible.
Cheers VeggieShirts for your very long comment π I’d recommend to leave the TOS on the checkout page, and maybe put additional tabs on the single product page to increase conversion, such as “why Veggie?”, “how we make it without child labor”, etc π Best of luck!
Hey Rodolfo. Thanks for your answer and your inspiration! The tab is a good idea. I think there are a lot of possibilities to promote this and i think it’s very important for me and my customers. Should be arguments to buy there. Thank you for the wishes! I think (and hope) we will read us later again.
(y)
Awesome!
Hi, great tutorial.
I wonder if it is possible to add an array of product ID’s that would make it show on all product pages except the ones defined?
Hello Brian, thanks for your comment! Of course, anything is possible with PHP π Hope you find the solution! Cheers π
After much deliberation I’m still non the wiser. Please help.
Brian, thanks so much for your follow-up! What I meant in the previous comment is that unfortunately this is custom work and I cannot provide a complementary solution here on the blog. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R
Thanks for the help (Y)
You’re very welcome Mazedul! Thanks for your feedback:)
This snippet adds it right below the price, even before the summary and select size dropdowns. How do I add it either after the summary, before the size dropdowns, or after the select size dropdowns, before the add to cart?
Hey James, thanks for your comment! Simply trying playing with the “20” inside the add_action. Change it to a higher number, such as “80” and see if it shows in the position you want it π Let me know!
Great stuff. And easy enough to implement for a beginner like me.
Any easy way to have it show a login form for visitors?
Thanks Lodix, much appreciated! Uhm, what about just showing a link to the “My Account” page?
Hi Rodolfo,
Thanks for the suggestion. I thought of that too, but there are two reason why that doesn’t work for me:
1) the link will show even when the shopper already logged in.
2) clicking the link would direct the shopper away from the product page. After they log in they would have to find the product again through the shop page. I prefer they log in on the product page.
Lodix, I’m glad to say “there is always a way”!
1) you can show the link conditionally – “if user is logged in”, show no link
2) you can add a “referrer” parameter when you send people to the My Account page – upon login they will be redirected to the previous page (product page in this case)
Hope this helps!
Great tips. That would certainly work.
I already found a snippet for the second point you mentioned. I need to do some googling for a snippet that shows the link conditionally. It sounds easy enough, but since I am not a coder I reply on ready made snippet like the awesome code you posted on this page. So please keep sharing and I will be sure to read more articles on this site π
Excellent, thanks for the follow-up!
Thank you for that!
Was very helpful in order to put a “on vacation” notice.
Thanks a lot.
Fantastic David, thanks a lot π And happy holidays!
I actually want to insert a Banner below the Add to cart button. This banner should be different for each product. Can I still use this snippet? If yes please help me.
Hey Sujal, thanks for your comment!
Yes, you can just change the “priority” to place it below the Add to Cart. Try using “35” instead of “20”.
In regard to having this behave differently for each product, it really depends on how many products you have. If you have 5-10 only, you can use conditional logic. Otherwise, you should use custom fields and echo their value on the single product page (similarly to https://businessbloomer.com/woocommerce-show-product-custom-field-in-the-category-pages).
Hope this helps!
Hay, I do not have good knowledge of programming can you please let me know how can I add a custom text for every single product page as COD is available with green check box or something like that?
Hey Mohammad, thanks for your comment! I’m afraid I don’t offer free customization of my snippets. This task would be pretty easy to accomplish. Take a look at Fiverr or other freelancing platforms if you’re on a low budget. Hope this helps!
Very helpful tutorial Rodolfo. This helped out greatly! However, I have a gravity form on my product page to customize the order and the β30-day return policyβ text is shown above this form, not above the add to cart button where I want it. Is there a way to fix this?
Note: I used the exact snippet and added the css customization in your tutorial.
Hey Matthew thanks for your comment π All you need to do is playing with the “20” inside the add_action. That is the hook priority and defines the position. Try changing it to 11, or 35, depending on where you want that to show π
Thank you Rodolfo! That fixed my problem!
Awesome π
Hi Rodolfo,
For some strange reason adding the above code does nothing. I do not get the text appearing anywhere on the single product page. Has anything changed in the recent version of Woocommerce?
Woocommerce: I am using Version 2.5.5 the latest version as of today.
WordPress: Version 4.4.2
Hey Nick thanks for your comment π I just tested this on my Woo 2.5.5 and it works perfectly so take a look at the following:
1) Do you have a cache plugin? Clear the cache and see if the text appears
2) Is your theme or other plugins removing the “woocommerce_single_product_summary” action? I doubt, but do a file search for remove_action(‘woocommerce_single_product_summary’ to see if anything comes up
3) Do you have a theme/plugin conflict? Disable all plugins but Woo and switch theme temporarily: is the text appearing?
4) I hope this is given for granted: have you added the snippet to the functions.php file of your child theme?
Hope this helps π
Hi Rodolfo, thank you for your reply.
Looks like my theme is the issue. I tried with TwentySixteen and it seems to work fine. I did get a message when I was installing WC, that the theme files are outdated. I will check with the developer regarding this.
Btw, could you explain what exactly is the number for? The number in the add_action part? I don’t seem to get it.
Thanks again!
Cheers
I see π Thanks for reporting back! In relation to the add_action “number”, that’s called priority. You can find the theory here: https://developer.wordpress.org/reference/functions/add_action.
Basically, if you have the following case:
… whatever is generated by function_B will show UNDER whatever is generated by function_A.
Priority defines the “execution order” = the position π
Hope this helps!
Rodolfo, what about if I want to put an “all on-sale sales items are final” only on those products that are on sale? thanks
Hey Hector thanks for your enquiry! I think the solution here is very simple, just add this conditional logic:
Hope this helps π
R
Thanks for this π
Anyway we can show this message only on certain categories?
We want to show a message above cart on single pages in our mobile phone category page.
Would love some help if possible π
Cheers Ran π
Of course – you can just use the conditional tag has_term:
Hope this helps π
What if i want to add it to my cart page+for certain product or product category?
Dzulhelmi, thanks so much for your feedback! Yes, this is possible – but unfortunately it’s pretty custom and I cannot provide this solution on the blog. If you would like to get a quote, feel free to go here. Thank you! R
Hi What if i wanted to add text below the price on all products in the category page? Could i use your code?
Umberto, check this out: “Woocommerce: Add text to each product @ shop page (loop)“. Hope this helps π
Great tutorial! I am trying to use the following code but it isn’t working. Can you help?
if ( is_product_category( ‘oils’ ) ) {
add_action( ‘woocommerce_single_product_summary’, ‘safety’, 20 );
function safety()
{ echo ‘Testing 1’; }
}
If I add the code without the if statement it shows fine on each product page. Am I doing the if command correctly?
Ryan, have you tried this:
add_action( ‘woocommerce_single_product_summary’, ‘safety’, 20 );
function safety() {
if ( is_product_category( ‘oils’ ) ) {
echo ‘Testing 1’;
}
}
Note: this will work exclusively on the Archive page of your “Oils” category.
Thanks. Unfortunately this code doesn’t work for me. I’m not sure what you mean by the “archive page”, I am looking to have this code on the single product page for every item in the Oils category
Hey Ryan, thanks for your comment. Just wondering if you posted on the right page? This snippet is for the single product page – if it doesn’t work for you feel free to copy/paste your snippet and I’ll take a look. Cheers!
Here is the code I am using:
add_action( ‘woocommerce_single_product_summary’, ‘safety’, 20 );
function safety() {
if ( is_product_category( ‘essential-oils’ ) ) {
echo ‘Testing 1’;
}
}
I have a category with the slug essential-oils so in theory it should work fine. Perhaps I have some errors in my code or something.
If I use this code without the if statement it works (on every product in the shop)
add_action( ‘woocommerce_single_product_summary’, ‘safety’, 20 );
function safety() {
echo ‘Testing 1’;
}
Ryan, “is_product_category” only works on the shop/category page. If you are working on the single product page the snippet will be different. Anyway, we’re off topic here so maybe contact me as this post is about the Cart page. Thank you!
Good to find you here. ^.^
Can I use WC conditional tag wrap your snippets for specific category?
Yes you can! See a similar question answered here: https://campbloomer.com/woocommerce-add-text-product-shop-page-loop/
Never received you reply email too
I am not luck, cannot make it work. May be my theme issue.
Anyway thanks
Sorry! Is worked but not in above the add-to-cart, its was in my bottom of product short category.
Cool, glad it worked!