{"id":541,"date":"2015-05-05T21:20:28","date_gmt":"2015-05-05T09:20:28","guid":{"rendered":"http:\/\/geektactics.geektamin.com\/?p=541"},"modified":"2024-06-14T09:53:08","modified_gmt":"2024-06-13T21:53:08","slug":"changing-the-default-demo-store-notice-in-woocommerce","status":"publish","type":"post","link":"https:\/\/geektactics.co.nz\/blog\/changing-the-default-demo-store-notice-in-woocommerce\/","title":{"rendered":"Changing the default Demo Store Notice in Woocommerce"},"content":{"rendered":"
Woocommerce has “store notice” functionality\u00a0built in, which enables you to post a message that displays on every page throughout the site.<\/p>\n
Most themes display this message at the very top of the site, like this:<\/p>\n
<\/p>\n
<\/p>\n
This setting is found in Woocommerce > Settings > General. \u00a0Tick “Store Notice” and then the text box appears to type your store notice. \u00a0Like this:<\/p>\n
<\/p>\n
What happens if you (or your client, or a site editor) deletes the lovely message you have there and forgets to untick “Enable site-wide store notice text”?<\/p>\n
Something bad … something very bad …<\/p>\n
Woocommerce has a default message that it shows if you tick the box but don’t type any message. \u00a0And that message is …<\/p>\n
This is a demo store for testing purposes \u2014 no orders shall be fulfilled.<\/span><\/strong><\/p><\/blockquote>\n
Yes, that’s right. \u00a0You could build a beautiful ecommerce website, and hand it over to your client. \u00a0They might publish a store-wide notice for a special promotion, and then when they take the notice off, if they leave the checkbox accidentally ticked, their site will tell all visitors that it is just a demo site for testing purposes. \u00a0Now that is sure to kill their\u00a0sales.<\/p>\n
But thankfully, with just a few lines of code added to your functions.php file in your child them, or your custom code plugin, you can change the default message to anything you like.<\/p>\n
Here’s the code:<\/p>\n
function wc_custom_store_notice_updated( $text ) {\r\n\treturn str_replace( 'This is a demo store for testing purposes — no orders shall be fulfilled.', '<a href=\"\/shop\/on-sale\">Check out our items On Sale<\/a>', $text );\r\n}\r\nadd_filter( 'woocommerce_demo_store', 'wc_custom_store_notice_updated' );\r\n<\/code><\/pre>\n
<\/p>\n
In this example I am\u00a0replacing the default text with a hyperlink to the page \/shop\/on-sale and the text that says “Check out our items On Sale”. \u00a0You can replace that section with whatever you like.<\/p>\n
Another alternative to achieve the same thing is, if you are already using a localization\/translation plugin, use that to replace the text.\u00a0Personally, I find adding these few lines to functions.php much easier.<\/p>\n","protected":false},"excerpt":{"rendered":"
Woocommerce has “store notice” functionality\u00a0built in, which enables you to post a message that displays on every page throughout the site. Most themes display this message at the very top of the site, like this: This setting is found in Woocommerce > Settings > General. \u00a0Tick “Store Notice” and then the text box appears […]<\/p>\n","protected":false},"author":5,"featured_media":542,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,14],"tags":[100],"class_list":["post-541","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-development","category-wordpress","tag-woocommerce"],"yoast_head":"\n
Changing the default Demo Store Notice in Woocommerce - Geektactics<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n\t\n\n\n\t\n\t\n\t\n