WooCommerce: Remove “Create shipping label” Ad @ Single Order Admin Page

Here we go again. It feels like the WooCommerce plugin has become the same as some of those free extensions you get from the repo that fill up the WordPress dashboard with ads, notices and banners.

This time around, let’s get rid of the “Print discounted shipping labels with a click. By clicking “Create shipping label”, WooCommerce Shipping will be installed and you agree to its Terms of Service. Create shipping label” banner that displays at the top (!) of the single order admin page when the status is processing or completed and shipping is required (see screenshot below).

Long live a world without ads!

Annoying, right?

PHP Snippet: Hide “Print discounted shipping labels with a click” WooCommerce Banner @ Edit Order Page

Of course, you can always click on the “dismiss” button and hide the banner:

But my point here is that I don’t want to display the banner in the first place.

A nice workaround, then, is to let WooCommerce know that we already clicked on that dismiss button, even before loading the page, and this should hide the banner forever.

By looking at the WooCommerce code, I found this after a bit of research (woocommerce/src/Internal/Admin/ShippingLabelBannerDisplayRules.php):

/**
 * Checks if the banner was not dismissed by the user.
 *
 * @return bool
 */
private function banner_not_dismissed() {
	$dismissed_timestamp_ms = get_option( 'woocommerce_shipping_dismissed_timestamp' );

	if ( ! is_numeric( $dismissed_timestamp_ms ) ) {
		return true;
	}
	$dismissed_timestamp_ms = intval( $dismissed_timestamp_ms );
	$dismissed_timestamp    = intval( round( $dismissed_timestamp_ms / 1000 ) );
	$expired_timestamp      = $dismissed_timestamp + 24 * 60 * 60; // 24 hours from click time

	$dismissed_for_good = -1 === $dismissed_timestamp_ms;
	$dismissed_24h      = time() < $expired_timestamp;

	return ! $dismissed_for_good && ! $dismissed_24h;
}

This is the PHP line that matters:

$dismissed_timestamp_ms = get_option( 'woocommerce_shipping_dismissed_timestamp' );

Apparently, the “dismiss” button assigns a timestamp to this custom WordPress option.

Also, we need to consider this bit:

if ( ! is_numeric( $dismissed_timestamp_ms ) ) {
	return true;
}

Which says: “unless the option value is numeric”, do not consider dismissing the banner.

Finally, this line:

$dismissed_for_good = -1 === $dismissed_timestamp_ms;

Which means, if I assign “-1”, it’s dismissed for good!

So, let’s override it by forcing the option value to “-1” with the “pre_option_OPTIONNAME” WordPress filter:

/**
 * @snippet       Dismiss Shipping Label Meta Box @ Woo Order Admin Page
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 9
 * @community     https://businessbloomer.com/club/
 */
 
add_filter( 'pre_option_woocommerce_shipping_dismissed_timestamp', 'bbloomer_hide_shipping_label_banner' );
 
function bbloomer_hide_shipping_label_banner() { 
   return -1;
}

Banner is gone now:

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce: Add Second Description @ Product Category Pages
    In terms of SEO, if you’re trying to rank your product category pages, you really need to make the most of the default WooCommerce product category “description” and “thumbnail”. Most themes, if compatible with WooCommerce, will show this content right below the product category name and above products. Nothing new so far. But what if […]
  • WooCommerce: Add Column to Orders Table @ WP Dashboard
    The WooCommerce Orders Table, which can be found under WP Dashboard > WooCommerce > Orders, provides us with 7 default columns: Order – Date – Status – Billing – Ship to – Total – Actions. This is used by shop managers to have an overview of all orders, before eventually clicking on a specific one. […]
  • WooCommerce: Display Custom Filters @ WP Dashboard > Products
    If you go to WordPress Dashboard > Products you will find default product admin filters such as “Select a category”, “Filter by product type”, “Filter by stock status”. What if you want to add more custom filters to let your shop managers find products easily? For example, you could add “Filter by product tag” (“product […]
  • WooCommerce: Hide/Show The WP Admin Bar
    In previous WooCommerce versions, new customers could access the WP Admin black bar after purchase. Now this seems fixed. Still, what about other user roles, and what if you want to override this default behavior? Well, here’s a quick snippet for you – feel free to use it in your own WooCommerce site. Enjoy!
  • WooCommerce: Access Thank You Page from Order Admin
    I’ve been testing for over an hour but finally I found a way to make this work. When you are in “Edit Order” view under WordPress Dashboard > WooCommerce > Orders, there is a dropdown of “Order actions”: “Email invoice“, “Resend new order notification“, etc. A major problem I’ve always had while troubleshooting or working […]

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

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