SkyVerge WooCommerce Extensions

Our WooCommerce Cart Notices extension is geared towards helping you increase conversions and average order value. You can create notices that will encourage customers to add more to the cart to meet a minimum amount (for example, add more to get free shipping). You can also set up notices to encourage orders before a deadline, provide a message based on the referrer, or cross-sell / upsell products.

However, these notices are only displayed on the cart and checkout pages, not while the customer is actually shopping. Displaying a notice on the shopping page might be helpful if you’d like to encourage customers to meet a minimum order value before they even get to the cart, so we can pretty easily add our WooCommerce Cart Notices to shop or product pages.

First, we need a simple little function to output our cart notice. Fortunately, we’ve got a really easy way to do this. There are several shortcodes included with Cart Notices, so let’s determine which shortcode we’d like to use and use the do_shortcode function to output it. You can use the type="all" version if you want all notices to display, or just pick which one(s) you’d like to use. I’ll use a minimum amount notice in my sample.

Here’s the first part of code snippet that will output the notice for us. You can begin a new Code Snippet or start adding this to your theme’s functions.php (Here’s our guide on adding custom code to your site).

function skyverge_output_cart_notices() {
    echo do_shortcode( '[woocommerce_cart_notice type="minimum_amount"]' );
}

Great. Now the issue is that this function is never called, so the notices are never printed on the page. Let’s determine where we’d like them to show up, and then we can finish off this code snippet. Choose one of the following three scenarios to finish this snippet based on where you want notices to be displayed.

Both Shop and Product Pages

If we’d like to add cart notices to all WooCommerce pages (shop, category, tag, and product pages), we can finish off our snippet by adding notices before the main WooCommerce content with this line of code:

add_action( 'woocommerce_before_main_content', 'skyverge_output_cart_notices' );

Now all WooCommerce pages that can print a notice will show our cart notices. For example, here’s the minimum amount notice used on the Shop archive:

WooCommerce Cart Notices | all notice

Shop Page

If we visit a product, the same notice will be displayed at the top of the page:

WooCommerce Cart Notices | all notice

Product Page

Just the Product Page

Only want to show WooCommerce Cart Notices on the product page instead? You can finish your snippet off by using a different action:

add_action( 'woocommerce_before_single_product', 'skyverge_output_cart_notices' );

This will leave the shop archives (shop, category, and tag loops) untouched, but will only add the notice to the single product page.

WooCommerce Cart Notices | product notice

Product Notice

Just the Shop Page

Finally, if you want to display WooCommerce Cart Notices on shop archive pages (shop, category, and tag pages), but not on single product pages, you can use this to finish your code snippet:

add_action( 'woocommerce_before_shop_loop', 'skyverge_output_cart_notices' );

Now my notice will be displayed on the shop page, but the single product page will display no notices.

WooCommerce Cart Notices | shop notice

Shop Notice

Bonus Round

That’s it! You can choose which way you’d like to display cart notices aside from the cart and checkout pages.

As a bonus, we’ve also had customers occasionally ask how to remove these notices from the checkout page (leaving them on just the cart page or elsewhere if you use the snippet above). You could do so by additionally adding this snippet to your site:

function skyverge_remove_cart_notice_on_checkout() {
   if ( function_exists( 'wc_cart_notices' ) ) {
      remove_action( 'woocommerce_before_checkout_form', array( wc_cart_notices(), 'add_cart_notice' ) );
   }
}
add_action( 'init', 'skyverge_remove_cart_notice_on_checkout' );

Now go and change your WooCommerce Cart Notices display as you’d like!

Published by Beka Rice

Beka leads product direction for SkyVerge and technical documentation. She spends a lot of time on research and interviews, but likes to write so she has an excuse to spend more time jamming out to anything from The Clash to Lady Gaga.

13 Comments

  1. Great post! Amazing timing. I just bought the add-on.

    I really was wondering about removing the notices from the cart!

  2. Hi Beka!
    Thanks for sharing this!

  3. I’d love to try this out, but I can’t use the plugin because nothing is saving. I try to setup a new notice, get it all configured the way I want it, hit the save button…..it takes me back to where the list is supposed to be, but nothing is there. So it isn’t actually saving.

    • Hi there, we’d be happy to look into this for you! This isn’t something we’ve seen in testing or support tickets as of yet, so I don’t have a fix off the top of my head. Could you please submit a ticket and forward us the number here? We can then have the dev team grab it to start troubleshooting. Thanks!

  4. Hi, thanks for this. I would really like to be able to show these notices even if a product or product from a certain category is not in the cart. Presently they only show if a certain product or product from a certain category is in the cart already. Would be great to let the customer know that they could get the discount if they added those items before they actually have!

  5. Every time I go to search for a “how to” solution for a WooCommerce plugin… BAM SkyVerge has it covered. 🙂

    Thanks so much for sharing this. In your Bonus Round section your show a snippet to remove the notice from the Checkout. What about if we wanted to keep it on the checkout but remove it from the cart?

    Again, thanks so much for all these useful articles!

    Cheers!

    • 😀 you got it — updated that snippet as it used $GLOBALS which we deprecated a while back in favor of singletons (i.e., wc_cart_notices()) and will be removing completely with WC 2.5. Once that’s updated, should be a simple as swapping the before checkout action for: woocommerce_before_cart_contents

  6. Hey, I’m trying to remove Woo Commerce Default :

    and use my own DIV & CLASS.

    I know i can edit Templates by copying files into my Theme DIR. But i would really love
    to code to my functions.php to get this done. Editing Template will be too easy, so i need
    to know if there is anyway to get this using [ ACTIONS / FILTERS ] .

    Please let me know – Thank You in Advance 🙂

  7. Question: Can a notice be carried over as a message in on the “My Account” page. Either before or after the “Hello name, From your account…” wording?

    I know that I can do this manually with a template but if I could make Cart Notices cross over instead it would be so convenient. 🙂

    • Hey Amber, it should work if you use a Cart Notice shortcode right above the [[woocommerce_my_account]] shortcode on the account page: http://cloud.skyver.ge/18112L141U3Y

      • Awesome, thanks Beka. 🙂

        Curious, any chance we’ll seen an update that includes just a generic/general message type. One that will let us put up notices via shortcode not tied to a deadline/referral/specific product or category.

        • Definitely an idea on our roadmap 🙂 We’d like to do a refresh for this plugin to have more detailed logic rules as to when messages are shown / hidden, but the current structure of the plugin isn’t really conducive to that, so we’d need basically a rewrite. Something we have planned for early 2017 at the moment, happy to add you to a notification list for it if you’d like!

Hmm, looks like this article is quite old! Its content may be outdated, so comments are now closed.