Last active
May 21, 2024 04:30
-
-
Save yuliyang/598caf60780cd22851614baccf71c6b1 to your computer and use it in GitHub Desktop.
[ WooCommerce ] Notice Message Shortcode
This file contains 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 | |
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'); |
This file contains 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
.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