Okay
  Public Ticket #3840936
Filtering products by Vendor
Closed

Comments

  • David started the conversation

    Hello, I need help filtering by vendors in a couple of ways:

    1. I need to surface clickable "sold by" vendor names within the relevant product cards (using Avada) in my shop. These vendor names should link to the vendor's profile page with only that vendor's products visible. See this shop (using Woocommerce Product Vendors) for an example: https://www.carnivorousplantresource.com/shop/ How would I go about doing this? Is there a shortcode to use?

    2. I'm using WOOF/Husky product filter and need to be able to filter products in the shop by vendor. How do I do this?

    Attached files:  Screenshot 2025-03-18 at 4.40.59 PM.png
      Screenshot 2025-03-18 at 4.44.42 PM.png

  •  2,361
    WebWizards replied

    Hi David,

    Thank you for purchasing MarketKing! 

     

    1. To display vendor names in your product cards, we do not have a built-in shortcode, but I tried to create one now.

    Here's how to implement it:

    First add this PHP code snippet to your site:

    add_shortcode('marketking_vendor_name', function(){
        global $post;
        $product_id = $post->ID;
        $vendor_id = marketking()->get_product_vendor($product_id);
        $store_name = marketking()->get_store_name_display($vendor_id);
        $store_link = marketking()->get_store_link($vendor_id);
        return '<a class="marketking_vendor_link" href="'.esc_attr($store_link).'">'.esc_html($store_name).'</a>';
    });

    Then you can add the shortcode [marketking_vendor_name] to your product cart

     

    2. Regarding WOOF filtering by vendor - this would require filtering by the post_author attribute. I believe it should be possible but I recommend reaching out to their support team directly to confirm the exact implementation method, as they would be best positioned to guide you through their specific filtering options.

    Technically we use the "post_author" attribute to set that the vendor is the author of the product - I believe this is the same method other plugins like Dokan or WCFM use.

     

    Let me know if you need any clarification!

    Kind regards,
    Stefan