0
votes

I'm developing a custom WooCommerce theme and I'm trying to implement a custom site-wide notice banner. I want the user to enable, disable and customize the message via Appearance > Customize > WooCommerce > Store Notice, just like the Storefront theme, but with custom HTML, CSS and positioning over the page. The idea was to read (somehow) via PHP the "Store Notice" (string) and "Enable Store Notice" (boolean) values and, based on their values, display or not the notice. How can I read those fields via PHP? Thanks.

enter image description here

Psuedo:

...other HTML

<?php if (ENABLE_STORE_NOTICE == true) { ?>

<div class="text-center text-white">
 <span class="heading-xxs letter-spacing-xl">
  <?php echo STORE_NOTICE_MESSAGE; ?>
 </span>
</div>

<?php } ?>

...other HTML
1

1 Answers

1
votes

As suggested in the comments, using the function is_store_notice_showing() to get "Enable Store Notice" (boolean) and get_option('woocommerce_demo_store_notice') to get "Store Notice" (string) perfectly solved my problem.

PHP:

<?php if (is_store_notice_showing()) { ?>
 <div class="text-center text-white">
  <span class="heading-xxs letter-spacing-xl">
   <?php echo get_option('woocommerce_demo_store_notice'); ?>
  </span>
 </div>
</div>