vendredi 5 février 2016

How do you write conditional PHP based on WooCommerce attribute

I've search the interwebs high and low looking for a way to conditionally display WooCommerce product attribute data on certain pages.

Ex: if attribute somethingcool has a value and it's on /?filtering=1&filter_manufacturer=1648 page, display value

I'd like to display an attribute differently if they are on a specific filtered page

Ex: http://ift.tt/1QLdj13

Based on this filtered page, display a product attribute 'somethingcool'

<?php if ( is_product_attribute('somethingcool') ) {
    echo 'Hi! This is something cool?';}
    else {
    echo '';
  }
?>

If it were a normal WordPress page, not a filtered page I could hide and show based on body class tag but unfortunately the body class doesn't change based on query string urls.

Aucun commentaire:

Enregistrer un commentaire