Mini-Cart

WooCommerce Add Content At The Top Of The Mini-Cart

WooCommerce Minicart showing a custom title

Pre-Requisites

There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About This Solution

By default, the WooCommerce mini-cart doesn’t even have a title. This quick guide shows you how you can add custom content to the very top of the mini-cart. If you find your custom text isn’t quite displaying at the top, tweak the priority number in the code. You’ll be wanting to use HTML and CSS to style the title as desired.

/**
* Snippet Name: 	WooCommerce add content to the top of the mini-cart.
* Snippet Author:	ecommercehints.com
*/

function ecommercehints_minicart_top_content() {
    echo 'My Basket';
};

add_action( 'woocommerce_before_mini_cart', 'ecommercehints_minicart_top_content', 10 );

What About For A Specific Product?

/**
* Snippet Name: WooCommerce show custom content above product title for a specific product
* Snippet Author: ecommercehints.com
*/

function ecommercehints_content_above_product_name() {
if (is_single('31')) { // The product ID to show the custom content
   echo 'Custom content here!';
}};

add_action( 'woocommerce_single_product_summary', 'ecommercehints_content_above_product_name', 1); // Custom text appearing but not above title? Change this number (priority)

100 WooCommerce Conversion Rate Optimisation Tips

This field is for validation purposes and should be left unchanged.

Let’s collaborate!

Need to outsource WordPress development?

Join forces with UnlimitedWP for an outsourced white label web development service you can truly rely on.

First Timer Here?

Sign up to receive 20% off on your first month with us.

26027
WELCOME OFFER