如何获得Woocommerce产品的所有类别

hello I want to develop a woo-commerce website and JSON API, I want to "get all categories for a product"

<?php
$terms = get_the_terms( '1753', 'product_cat' );
//$nterms = get_the_terms( '1753', 'product_tag' );

foreach( $terms as $term ) {
   $product_cat_id = $term->term_id;
   $product_cat_name = $term->name;
   break;
}

Please try:

<?php
get_the_term_list( '1753', 'product_cat', '', ', ', '' ); ?> 

Check reference here: https://codex.wordpress.org/Function_Reference/get_the_term_list