Try below code
<?php
$terms = get_the_terms($post->ID, 'product_cat');
foreach ($terms as $term) {
$category_name = $term->name;
$parent_category_id = $term->term_id;
$categories = get_categories(array('parent' => $category_id));
$children = get_terms('product_cat', array(
'parent' => $parent_category_id,
'hide_empty' => true
));
if (!empty($children)) {
echo ' <div class="list-group products box">
<h4>Product Range</h4>';
foreach ($children as $subcat) {
?>
<a href="https://wordpress.stackexchange.com/questions/317473/<?php echo get_term_link($subcat->slug,"product_cat'); ?>" class="list-group-item"><?php echo $subcat->name; ?></a>
<?php
}
echo "</div>";
}
}
?>
Hope this helps
Related Posts:
- How to check if a plugin (WooCommerce) is active?
- How to trigger WooCommerce order complete email?
- How to get Woocommerce order product info
- How to automatically apply woocommerce product title to all product images alt tags?
- How to have a custom display for both woocommerce archive and product-category pages? [closed]
- Woocommerce auto cancel On-Hold after X days
- WP_Query | Help me create a search term with an ‘OR’ relation?
- WooCommerce – Customer Order History Pagination
- Replace existing content from specific WooCommerce admin orders list column
- Woocommerce – How to get products which have a sale between 20% to 40%? [closed]
- Display related products with custom output
- Woocommerce filter cart and category specific quantity [closed]
- How to get woocommerce cart content without an action?
- WooCommerce: Add Payment Gateway Field to Webhooks [closed]
- Woocommerce product download URL
- Limiting woocommerce line_total decimal length
- How can I use wp_query to show all product data using just the products ID?
- write custom woocommerce templates and forms
- Get stock by custom meta field on all Woocommerce variable products
- Set a condition based on WooCommerce checkout city field while placing order
- WooCommerce – Email admin with new user details
- Call global variable array() in woocommerce child/template
- Remove price from Woocommerce variable product dropdown menu
- Issue adding sub category programmatically
- Get and insert order email address to the PHP template inside HTML text
- Auto-update products after they were published – Woocommerce
- How to VAR_DUMP a $variable during checkout process (Is my product meta callable?)
- If no products are on sale – hide ID or class
- do search in two site and show the result in first site
- wordpress + woocommerce display product with additional information [closed]
- How can I pass a custom/dynamic product to the Woocommerce cart?
- How to remove woocommerce_breadcrumb() from do_action( ‘woocommerce_before_main_content’ ); [closed]
- How to get private property in parent class into extended class?
- Replace Woocommerce “add to cart” to be “Download” button [closed]
- Woocommerce Email attachments not working – file not being attached
- Add post with approval by the admin
- How to optimize update_post_meta?
- WooCommerce pages looks unstyled
- How to display a custom product field value of a specific category on a Woo Commerce checkout page?
- Personalize checkout text
- CSS change in woo commerce Place Order Text [closed]
- WooCommerce – Moving Product Price to the Left of Add to Cart Button [closed]
- Exclude product attributes from taxonomy terms loop
- WP All Import / Update stock quantity from multiple XML files
- Woocommerce: remove total sum from new order’s email [closed]
- WordPress WP_Query without query GET parameters
- Where to copy woocommerce files to in my custom theme to avoid editing the core plugin?
- Alter Woocommerce product archive structure
- custom post type with role Vendor
- WooCommerce: Display product categories to make IF statement
- Custom reduce stock code affecting date_modified – How to bypass?
- Modify WooCommerce used to get all orders in dashboard
- Replace category title with category description in woocommerce
- Add Custom Category Description When Empty
- I am having issue in divi woocomerce checkout module. (DIVI theme)
- Add a product category to a specific product via a button
- WooCommerce Query Product Titles
- Woocommerce display orders with products from specific categories to specific admins
- Display div if category has a specific parent
- How to add a shortcode which runs a .php file for the current post
- global $product is empty string when passed into function
- Variant Item SKU as Product Code
- Run a sql (update) after 12 hours after the user login. Woocommerce users
- Use PHP Class in WordPress functions
- How can I change the background color of divs dynamically (depending on an order-status in woocommerce)?
- Add a new view on the Woocommerce account page
- Use Search Term in html link and redirect
- Don’t update modified post date when user add a product review or comment?
- How do I change the “login” label in My Account page to “Registered Customer”
- Customize the “Available for back order” text for specific variation
- How to remove the replace the product image by video on shop page conditionally
- WooCommerce REST API AJAX Auth – 401 response
- Looping through and combining calls to Woocommerce REST API
- get_filtered_term_product_counts – Get product terms if any products
- How to import woocommerce custom fields data into another site?
- How to add custom attribute to all outofstock and all instock products automatically?
- Site infected by link
- Woocommerce – if selected attribute term equals
- Need to forward Data from WooCommerce Webhook sent to same site WordPress REST API custom endpoint
- Add Product Permalink in woocommerce admin order page
- sessionStorage saves input value in browser but it is not loaded in the form field
- WooCommerce – Add Shipping class below each product in Shopping Cart page
- Hide price excluding tax when price is empty
- WooCommerce Custom Tab with ACF Repeater Field
- Woocommerce variable products are being added to the card on the homepage (ajax)
- Display product attributes for current product
- How to remove image on single product and get product to span page?
- Need some help with tweaking a code for woocommerce [closed]
- Adding placeholder text field to woocommerce checkout [closed]
- Getting custom field data from cart page to checkout page in woocomerce [closed]
- Send a custom notification to customer on WooCommerce cancelled order status
- How to code bulk order form in wordpress
- Custom field fetch error on woocommerce pdf invoice
- posts_clauses drop ACF get_field function
- WCFM Custom form
- Hide child of parent categories already hidden with “get_terms_args” – Woocommerce
- Find owner of coupon
- Removing the add to cart button from specific product pages
- Add Woocommerce Customers link to custom admin menu
- Add text below WooCommerce short description if metabox value is true