Skip to content

Instantly share code, notes, and snippets.

@furtive
Created November 24, 2015 20:29
Show Gist options
  • Save furtive/4fcf877cd37eacaebbe9 to your computer and use it in GitHub Desktop.
Save furtive/4fcf877cd37eacaebbe9 to your computer and use it in GitHub Desktop.
In WooCommerce, make the online store notice only show up in store pages as opposed to the entire site, which is the default behaviour.
if ( ! function_exists( 'woocommerce_demo_store' ) ) {
/**
* Adds a demo store banner to the site if enabled
*
* @access public
* @return void
*/
function woocommerce_demo_store() {
if ( get_option( 'woocommerce_demo_store' ) == 'no' )
return;
$notice = get_option( 'woocommerce_demo_store_notice' );
if ( empty( $notice ) )
$notice = __( 'This is a demo store for testing purposes — no orders shall be fulfilled.', 'woocommerce' );
if (! is_woocommerce () )
echo apply_filters( 'woocommerce_demo_store', '<p class="demo_store" style="display:none;">' . $notice . '</p>' );
else echo apply_filters( 'woocommerce_demo_store', '<p class="demo_store">' . $notice . '</p>' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment