Answers for "wc get product by category"

PHP
0

wc php get product category in product page

global $post;
$terms = get_the_terms( $post->ID, 'product_cat' );
foreach ($terms as $term) {
    $product_cat_id = $term->term_id;
    break;
}
Posted by: Guest on January-06-2022
0

wc get product category image

<?php
        if ( is_product_category() ){

            global $wp_query;
            $cat = $wp_query->get_queried_object();    
            $thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true ); 
            $image = wp_get_attachment_url( $thumbnail_id ); 
            echo "<img src='{$image}' alt='' />";
        }
    ?>
Posted by: Guest on June-29-2021

Code answers related to "wc get product by category"

Browse Popular Code Answers by Language