WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] Store notice text only on shop pages (2 posts)

  1. fatherb
    Member
    Posted 1 year ago #

    Hi,

    I would like to tell people that the store is currently in testing. there is the option in settings for a Store Notice Text but it displays on every page in the site. Is it possible to show the Store Notice text only on shop pages? If so, how would you do that?

    Thanks

    http://wordpress.org/plugins/woocommerce/

  2. fatherb
    Member
    Posted 1 year ago #

    I sorted it myself. This may help others. Add this to your child them, functions.php. It will only show the Store Notice Text on shop pages.

    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>'  );
    	}
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic