WordPress.org

Forums

WooCommerce - excelling eCommerce
Conditional Tags is_product_category (2 posts)

  1. krisscross90
    Member
    Posted 1 year ago #

    I'm trying to add a button to my single product pages which allows the user to request a sample, however I only need this to be seen on products within certain categories.

    I've got the button appearing on the single product page, however I want to now single out the categories on which it should only appear.

    This is what I've got so far, but it doesn't seem to be working...

    <?php if is_product_category( array( 'coving', 'skirting-boards', 'dado-rails', 'indirect-lighting-by-orac' ) ){ ?>
        <div id="requestsample"><a class="fancybox button" href="#contact_form_pop">Request a Sample</a><div class="fancybox-hidden" style="display: none;"><div class="hentry" id="contact_form_pop" style="width: 600px; height: 500px; overflow-x: hidden"><?php echo do_shortcode( '[contact-form-7 id="269" title="Request Sample"]' ); ?></div></div></div>
      <?php} ?>

    Can anyone help me out... Am I on the right track?
    Any help will be greatly appreciated!!
    Thanks in advance!

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

  2. ouverz
    Member
    Posted 1 year ago #

    You would need to change the code to the following:
    <?php if (is_product_category(arrry('cat1','cat2','cat3')){ ?>
    <div></div>
    <?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic