I did some research but was unable to find a clue. Here is the scenario:
There is a product called "Album" which is assigned to both the "Music" & "Others" categories. The product permalink has been set to Custom base:
/shop/%product_cat%/. Now, if I try to browse this product using the following URLs then both will work fine:
Not sure how WooCommerce is deciding the permalink but if I browse Music category then I'd expect that the product URL will be:
http://dev.local/shop/music/album/ and if I browse Others category then I'd expect that the product URL will be:
http://dev.local/shop/others/album/ respectively. But, it doesn't happen.
If I fetch the product using custom
WP_Query based on
product_cat then I can set my desired permalink.
Is there any other way that I can override the permalink based on the current product category?