Home » Documentations and support » Woocommerce Polaris connector » How do I change the category ID?

How do I change the category ID?

Practical case: Your Polaris caisse has these categories:

  • Woman
    • Lingerie
      • Bra
      • Panty
      • Slip
    • T-shirt
  • Man
    • Lingerie
      • Underwear
      • Slip
    • T-shirt

Layered, you will have 2 categories named Lingerie, 2 T-shirts and 2 Briefs. You may want to differentiate them, besides the hierarchy.

The filter hook polaris_taxonomy_parameters allows to override the attributes when creating taxonomies in WooCommerce.

In the following example, we will add the taxonomy code to the identifier (slug)

add_filter( 'polaris_taxonomy_parameters', function ( $params, $taxonomy, $polaris_term ) {
	if ( $taxonomy == 'product_cat' ) {
		$params['slug'] = $polaris_term->Code . '-' . $polaris_term->Nom;
	}
	return $params;
}, 10, 3 );

Its URL will then become something like: https://votreboutique.shop/categorie-produit/007-lingerie/