WordPress at Your Fingertips
function is not described

wc_get_product_cat_ids() WC 2.5.0

Get all product cats for a product by ID, including hierarchy

No Hooks.

Return

Array.

Usage

wc_get_product_cat_ids( $product_id );
$product_id(int) (required)
Product ID.

Changelog

Since 2.5.0 Introduced.

Code of wc_get_product_cat_ids() WC 5.5.2

<?php
function wc_get_product_cat_ids( $product_id ) {
	$product_cats = wc_get_product_term_ids( $product_id, 'product_cat' );

	foreach ( $product_cats as $product_cat ) {
		$product_cats = array_merge( $product_cats, get_ancestors( $product_cat, 'product_cat' ) );
	}

	return $product_cats;
}