Skip to content

Instantly share code, notes, and snippets.

@yuliyang
Last active May 21, 2024 04:30
Show Gist options
  • Save yuliyang/598caf60780cd22851614baccf71c6b1 to your computer and use it in GitHub Desktop.
Save yuliyang/598caf60780cd22851614baccf71c6b1 to your computer and use it in GitHub Desktop.
[ WooCommerce ] Notice Message Shortcode
<?php
function dejavu_woocommerce_notice_shortcode($atts) {
ob_start();
?>
<div id="ds-wc-notices"></div>
<script type="text/javascript">
jQuery(document).ready(function($) {
var noticesContainer = $('.woocommerce-notices-wrapper');
if (noticesContainer.length) {
$('#ds-wc-notices').append(noticesContainer);
}
});
</script>
<?php
return ob_get_clean();
}
add_shortcode('ds-wc-notice', 'dejavu_woocommerce_notice_shortcode');
.woocommerce-notices-wrapper {
display: none;
}
#ds-wc-notices .woocommerce-notices-wrapper {
display: block;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment