Skip to content

Instantly share code, notes, and snippets.

@calvez
Forked from furtive/functions.php
Created July 24, 2018 09:23
Show Gist options
  • Save calvez/7a92ec683929050165529ab7b99bf50d to your computer and use it in GitHub Desktop.
Save calvez/7a92ec683929050165529ab7b99bf50d 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