Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // print some text on the product page, under the add-to-cart button
- // for some categories but different text for others
- // snippet goes in functions.php for your child theme
- add_action( 'woocommerce_single_product_summary', 'cat_condition', 35);
- function cat_condition() {
- global $post;
- if ( is_product() ) {
- $socks = 116; // category id for socks
- $terms = get_the_terms( $post->ID, 'product_cat' );
- $found = false;
- foreach ($terms as $term) {
- if ($socks == $term->term_id) {
- $found = true;
- break;
- }
- } // end for
- if ($found) {
- print '<p>Socks found!</p>';
- } else {
- print '<p>No socks here!</p>';
- }
- } // end if
- } // end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement