title: Woocommerce product ID in url
body: <p>I'm looking for a way to put a Woocommerce product ID in a URL, e.g.:</p>
  
  <pre><code>domain.com/product-category/id/product-title
  </code></pre>
  
  <p>The ID is the product's post ID, e.g. "12092". Automatically created by <code>WooCommerce</code> in <code>Wordpress</code>.</p>
  
  <p>Can this be done in a way? Either easily through the <code>Wordpress</code> permalinks settings or in a different way through hacking my way into the files.</p>
  
  <p>This nearly works:</p>
  
  <pre><code>&lt;?php
  
  add_filter('post_type_link', 'wpse33551_post_type_link', 1, 3);
  
  function wpse33551_post_type_link( $link, $post = 0 ){
  if ( $post-&gt;post_type == 'product' ){
      return home_url( 'p/' . $post-&gt;ID );
  } else {
      return $link;
  }
  }
  
  add_action( 'init', 'wpse33551_rewrites_init' );
  
  function wpse33551_rewrites_init(){
  add_rewrite_rule(
      'product/([0-9]+)?$',
      'index.php?post_type=product&amp;p=$matches[1]',
      'top' );
  }
  
  ?&gt;
  </code></pre>
  
  <p>But the output is:</p>
  
  <pre><code> domain.com/p/45
  </code></pre>
  
  <p>I'd like it to be:</p>
  
  <pre><code> domain.com/p/45/title-of-the-post
  </code></pre>
  
  <p>Thanks!</p>