Taxonomy , subtaxonomy,child taxonomy of a product woocommerce

Based on this answer, here is my function to get all your terms in an array : function get_term_ancestors($post_id, $taxonomy){ // Declare the array where we are going to store the terms $ancestors = array(); // start from the current term $parent = array_shift(get_the_terms($post_id,$taxonomy)); // climb up the hierarchy until we reach a term with … Read more

Translating add to cart woocommerce button [closed]

What is the content contained within your add-to-cart.php file template override? It should be similar to this: global $product; echo apply_filters( ‘woocommerce_loop_add_to_cart_link’, sprintf( ‘<a href=”https://wordpress.stackexchange.com/questions/218348/%s” rel=”nofollow” data-product_id=”https://wordpress.stackexchange.com/questions/218348/%s” data-product_sku=”https://wordpress.stackexchange.com/questions/218348/%s” data-quantity=”https://wordpress.stackexchange.com/questions/218348/%s” class=”button %s product_type_%s”>%s</a>’, esc_url( $product->add_to_cart_url() ), esc_attr( $product->id ), esc_attr( $product->get_sku() ), esc_attr( isset( $quantity ) ? $quantity : 1 ), $product->is_purchasable() && $product->is_in_stock() ? ‘add_to_cart_button’ … Read more

get_terms won’t display product_cat or any other custom taxonomies when specified

You are maybe running an old version of WordPress (before 4.5). Before WordPress 4.5.0, the first parameter of get_terms() was a taxonomy or list of taxonomies and since 4.5.0, taxonomies should be passed via the ‘taxonomy’ argument in the $args array (that what you are doing, it should work like that). You will find all … Read more

Get product list of given category

In the end my main problem turned out to be that I was executing code right into functions.php (for testing purpose). The code was executing before woocommerce was initialized and then was failing to fetch products correctly. Despite that, I couldn’t get Wp_Query to return only products of one given category. It was still returning … Read more