get_cat_ID gets the ID of a category based on the name. “Category” is a specific taxonomy named category. You’re trying to get the ID of a Product Category (product_cat). You cannot use get_cat_ID() to get the ID of a custom taxonomy.
To do that you need to use get_term_by():
$product_cat = get_term_by( 'name', $cat_name, 'product_cat' );
if ( $product_cat ) {
$thisCatID = $product_cat->term_id;
}
But, based on your code, you don’t need to be finding the ID. You already have it:
$cate_object = get_the_terms( $post->ID, 'product_cat' );
foreach( $cate_object as $cate ){
$thisCatID = $cate->term_id; // This is the ID.
$cat_array[] = $thisCatID;
}
Related Posts:
- Display All Products by Category with WooCommerce
- Woocommerce get category image full size
- Programmatically create product category and add thumbnail in woocommerce
- Reflect nested categories in appearance > menus
- Create product category and keyword search form in woocommerce? [closed]
- How do I edit pre_get_post for the category the user is currently in?
- Display WooCommerce product categories in a 4 columns custom menu [closed]
- How to select product category while adding new product in woocommerce? [closed]
- Hide uncategorized products from the shop page
- Add Icons to the Product Category Sidebar Widget WooCommerce
- Add Product categories to WordPress menu without losing hierarchy
- Display “add to cart” button on every listing in product category page?
- Custom page for WooCommerce’s /product-category/
- Getting categories id for all products in cart
- Get woocommerce catogry
- Display child categories in WooCommerce
- WooCommerce duplicate sub categories and product slugs
- WooCommerce IF statements not working
- Woocommerce category show subcategories only/omit posts for specific category
- products nested by subcategories in a current category archive
- WC 3.x Get categories from variable product of the cart
- Hide woocommerce category name from specific pages
- Pagination not visible on woocommerce’s category page
- Best way of getting WooCommerce category path
- Remove product category placeholder image (Woocomerce)
- Categories for each brands
- Change thumbnail image depending product category
- Unwanted Duplicate Product Categories in WooCommerce
- Woocommerce custom category pages
- Customize WordPress widget – Product Category
- WordPress/Woocommerce only show category in shop to a single role
- WooCommerce – How to show specific category first-rest of products-specific category last
- Categories are not listing their respective products
- Display single category name in woocommerce loop
- Building Menu from Woocommerce Product Categories
- Include WooCommerce product to all child categories
- woocommerce related products by specific categories [closed]
- List just subcategory and products of active category page in Woocommerce
- List a maximum of ‘x’ product categories with qty of ‘y’ in each column
- Display all product tags associated with a specific product category
- How to access deleted term inside delete_product_cat action
- Apply WordPress function on specific woocommerce product categories only
- Grandchild Term Things Grandfather Term is It’s Parent
- Adding custom ID field to the categories
- How can i change what one category displays?
- How to display product with two condition, category and brand taxonomy
- Show different menu on each woocommerce category page
- Template for product-category page [closed]
- WooCommerce shared categories
- displaying the last product comment in the woocommerce category
- Woocommerce only display child category when parent is checked (on add new product page)
- category description not showing in my woocommerce
- Show audio player only in specific post type category
- How to make product image inherit from category image
- Shop Category Pages missing s
- How to set acf color field as background color to product category
- How to target all woocommerce categories that don’t have any subcategories in them?
- In if…else condition, the else statement shows even if if statement is correct
- Show the parent taxonomy by creating shortcode in woocommerce?
- How can I display all products from all categories on one page with woocommerce?
- How to add all subcategories as submenu in WordPress menu
- How to edit woocommerce sub-category page
- When creating a new product, auto assign it to all custom taxonomy woocommerce
- Get WooCommerce product category list in functions.php
- in post content shortcode works, but hardcoded in same page template doesn’t?
- selecting categories that have products with tag/category
- Restrict retrieved terms by category?
- How to fix 404 error in pagination in categories of woocommerce with common url base /shop/?
- How to display custom fields as table in Woocommerce
- How do I merge WooCommerce categories with the same name?
- Woocommerce Category Sort Dropdown
- Woocommerce: all products of all categories instead products of one category
- How to delete WooCommerce categories in bulk that only have one product
- Product Category page showing all products
- How to load terms of a custom taxonomy of a product in woocommerce cart page
- product_cat image url from database
- How to get WooCommerce Product Categories and its children’s children?
- Woocommerce change tag_id to name
- WooCommerce – Get products from category right before deleting category
- Categories and Tags Conflict after Woocommerce Installation
- How to get related category/categories in WordPress archive page
- Category menu that filters out empty categories
- Custom Woocommerce Category view
- Displaying categories and subcategories without link
- WooCommerce category display in custom page
- Sorting Woocommerce products by category and attributes
- Woocommerce custom taxonomy order
- Update wordpress menu with woocommerce products
- How to get Woocomerce categories count
- Woocommerce – Display product category of product in Orders page
- Changing Woocommerce categories programatically
- Get all categories
- Categories and products woocommerce wordpress
- Function to reference post meta in place of category Woocommerce
- Restricted category in Woocommerce [closed]
- category id (term_id) in url instead of slug
- Products showing up in subcategory when they shouldn’t
- Adding 400 product categories with their hierarchy to a navigation menu
- How do we ReWrite HTACCESS to point a cat/subcat Product URL, to Cat/ only?
- What would be the easiest way to show subcategories under specific parents as text links only?