howto call the categories from the product taxonomy (woocommerce)
-
My problem, I can’t call the categories from a woocommerce shops. I know that these categories are special terms. I am using a plugin that can do a chain select.
<a href="https://www.ads-software.com/plugins/category-ajax-chain-selects/">
This plugin works fine, if you call the standard categories from wordpress like this:
$taxurl = get_option( ‘category_base’ );
this snippet is used to build a link to the category.
The taxonomy for the shop is called product_cat, but whatever I try, I can’t catch the the categories to build a path. What I am doing wrong? What function can I try to get the categories from the woocommerce shop?
This is the complete function to understand my problem.
function chainselect_init($tax, $level, $titles, $labels, $btn_text, $exclude, $count) { echo "<div id='chainselect_wrap' class='$tax cs_count_$count'>"; $categories = get_terms( $tax, array('parent' => 0, 'exclude' => $exclude) ); if ($labels) { echo "<label for='chainlist_1'>$labels[0]</label>"; } echo "<select id='chainlist_1'>"; echo "<option>$titles[0]</option>"; foreach ($categories as $cat) { if ($count == 1) { $cat_count = " ($cat->count)"; } else { $cat_count = ''; } echo "<option id='$cat->slug' value='$cat->term_id'>$cat->name$cat_count</option>"; } echo "</select>"; if ($level > 1) { for ($x = 1; $x < $level; $x++) { if ($labels) { echo "<label for='chainlist_". ($x + 1) ."'>$labels[$x]</label>"; } echo "<select id='chainlist_". ($x + 1) ."' disabled>"; echo "<option>$titles[$x]</option>"; echo "</select>"; } } <strong>$taxurl = get_option('category_base');</strong> $siteurl = get_option('siteurl'); echo "<input type='hidden' id='chainselects_taxurl' name='chainselects_taxurl' value='$taxurl' />"; echo "<input type='hidden' id='chainselects_siteurl' name='chainselects_siteurl' value='$siteurl' />"; echo "<input type='button' id='chainselects_submit' class='$tax' value='$btn_text' /><span id='chainselects_loading'></span>"; echo "</div>"; }
- The topic ‘howto call the categories from the product taxonomy (woocommerce)’ is closed to new replies.