Custom permalink wc marketplace vendor/product-name


I’m developing a marketplace website. At some point I’m stuck and waiting for your support. I use the WC Marketplace plugin. Different vendors can also sell the same product. However, there are some problems:

When different vendors add the same product, a different new URL is created. Like this:

1st seller: — 2nd seller:

I want to customize this URL per vendor. For example: — second-seller/

With the code below, I can get the nickname of the vendor and add it to the URL structure, but I couldn’t add it wherever I want. And when I wanted to view the products I got a 404 error.

I want:

  1. Getting the vendor page URL instead of the nickname. (I tried the code _vendor_page_slug instead of nickname but it returned empty)
  2. Adding the vendor page URL to the end of the product name.
  3. To be able to view the product pages.

My code:

function dab_prefix_filter_vendor_permalink ($post_link, $post, $leavename, $sample) { 
global $WCMp, $product;
$vendor = get_wcmp_product_vendors ($product->id);
if ($vendor) (
$term_vendor = wp_get_post_terms($product->id, dc_vendor_shop);
$store_name = $vendor->user_data->nickname;
$post_link = str_replace ('%vendor_slug%', $store_name, $post_link);
return $post_link;
add_filter ('post_type_link', 'dab_prefix_filter_vendor_permalink', 10, 4);
Mert 4 months 0 Answers 14 views 0

Leave an answer