Last active
March 17, 2022 17:45
-
-
Save webaware/c6a6286026eb6a89e5a3 to your computer and use it in GitHub Desktop.
display WooCommerce notices in any page by shortcode [woocommerce_notices]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: WooCommerce Notices Shortcode | |
Plugin URI: https://gist.github.com/webaware/c6a6286026eb6a89e5a3 | |
Description: display WooCommerce notices in any page by shortcode [woocommerce_notices] | |
Author: WebAware | |
Author URI: https://shop.webaware.com.au/ | |
*/ | |
if (!defined('ABSPATH')) { | |
exit; | |
} | |
add_shortcode('woocommerce_notices', function($attrs) { | |
if (function_exists('wc_notice_count') && wc_notice_count() > 0) { | |
?> | |
<div class="woocommerce-notices-shortcode woocommerce"> | |
<?php wc_print_notices(); ?> | |
</div> | |
<?php | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works great. Thanx.
One question though: How can I change the position of the WooCommerce notice? I've noticed that no matter where I put the shortcode, the message will always appear on top of pretty much everything.
T.i.a.