How do categories and subcategories for WooCommerce are saved in DB? How do categories and subcategories for WooCommerce are saved in DB? wordpress wordpress

How do categories and subcategories for WooCommerce are saved in DB?


function getParentCategories() {    global $wpdb;    $sql = "SELECT term_id as id, name, slug FROM wp_terms where term_id in (SELECT term_id FROM wp_term_taxonomy where parent = 0 and taxonomy = 'category') order by name asc";    $parents = $wpdb->get_results( $sql );    return $parents;}function getChildCategories($id) {    global $wpdb;    $sql = "SELECT term_id as id, name, slug FROM wp_terms where term_id in (SELECT term_id FROM wp_term_taxonomy where parent = $id and taxonomy = 'category')  order by name asc";    $children = $wpdb->get_results( $sql );    return $children;}


You have to look into table wp_options for option_name "product_cat_children", there is serialized category hierarchy.


Maybe because one is the parent and the other the child, so if you define this relation, it's right that the opposite shouldn't work.