Knowledge Base
CSS
Plugins
- Locked out from Updraftplus Dashboard
- MAINWP – Kod för att se Server-IP
- Elementor List Icon fix
- Browser downloads file when opening a page
- Elementor Scroll Offset Menu Anchors
- Widget Panel Not Loading
- Align checkboxes to the right
- Greatly Improve the Entrance Animations
- Elementor Posts Widget Title Length
- Change Product Description Tab and Titles in WooCommerce
Wordpress
- Problems with Cronjobs?
- Increase WordPress Memory Limit
- Admin Dashboard not Displaying Correctly
- Critical error on this website
- Disable file editing in WordPress admin
- Password Protected Pages
- Hemsida dålig laddtid vid besök första gången
- Hjälp med koder (Multisite)
- How to add text under add to cart
Browsers
Windows
Server
Themes
WooCommerce
< All Topics
Print
How to add text under add to cart
Posted2025-05-26
Updated2025-05-27
ByLasse
Intro:
To add custom text under the “Add to cart” button in WooCommerce (on the single product page), you can use a small code snippet in your child theme’s functions.php file or a custom plugin.
The code:
add_action('woocommerce_after_add_to_cart_button', 'custom_text_by_category');
function custom_text_by_category() {
global $product;
if (has_term('category-slug-one', 'product_cat', $product->get_id())) {
echo '
Ships within 24 hours – See shipping info
';
}
elseif (has_term('category-slug-two', 'product_cat', $product->get_id())) {
echo '
Limited stock – More about availability
';
}
}
Replace:
● /shipping-info → with the URL to your shipping info page.
● /stock-details → with the URL to your availability/stock details page.
You can use full URLs (https://yourdomain.com/page) or relative (/page).
Example CSS:
custom-cart-text {
font-size: 15px;
color: #444;
margin-top: 60px;
margin-bottom: 20px;
border: dashed 3px #77a464;
border-radius: 10px;
padding: 10px;
}
.custom-cart-text a {
font-weight: 700;
}
.custom-cart-text a:hover {
font-weight: 700;
color: #000000;
}
Table of Contents