WordPress.org

Support

Support » Plugins and Hacks » Calling certain product_cat

Calling certain product_cat

  • I have been trying to write some PHP script for some time now and have finally given in!

    Basically I need to write a bit of script that will call in different product_cat depending on the current product_cat.

    So if I am viewing a product that is under the category “spades” I need to display a list of related categories such as “spade handles, spade cleaning products”

    (spades is just an example!)

    I am guessing it will require an if, else kind of setup but cant get it working 🙁

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • sorry need to clarify that better after reading! Setup would need to be:

    if product_cat = “spades”
    echo “spade handles, spade cleaning”

    if product_cat = “plants”
    echo “pots, compost, food”

    etc etc etc

    I have this so far, but simply doesn’t work, any ideas on what needs modifying would be great.

    <?php
    $terms = get_the_terms( $post->ID, 'product_cat' );
    $term = current($terms);
    if ($term == "safety-range") {
    echo "<h1>hello</h1>";
    }
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Calling certain product_cat’ is closed to new replies.