Show a custom template for the vendor shop pages

,

Are you using the plugin WooCommerce Product Vendors?
Well, I think you will love this tutorial then!

If you are one of those users who want to setup a custom vendor shop page, add this code in your functions.php file located in wp-content/themes/your-theme-name/:


<?php
/**
* Load a custom template for vendor taxonomy
*/
function load_custom_vendor_template( $located, $template_name ) {
if( is_tax( WC_PRODUCT_VENDORS_TAXONOMY ) && 'archive-product.php' == $template_name ) {
return get_stylesheet_directory() . '/woocommerce/taxonomy-shop_vendor.php';
}
return $located;
}
add_filter( 'wc_get_template', 'load_custom_vendor_template', 10, 2 );

view raw

functions.php

hosted with ❤ by GitHub

Delete the <?php first line if you are having errors come up after saving the file.

Be sure to create a file named taxonomy-shop_vendor.php in your wp-content/themes/your-theme-name/woocommerce/ folder and edit it to match your desires.

For a basic configuration, I suggest to copy the template taxonomy-product_cat.php from the folder wp-content/plugins/woocommerce/templates/ and paste it in your theme WooCommerce folder. Then rename it and apply your changes.

18 replies
  1. Teo
    Teo says:

    Nice~!
    These seems to be for the Vendors but
    how can I create a page for the /vendor top page…? If I go to /vendor it just gives me 404, would nice to show all the vendors or something on that page.

    Reply
    • Nicola Mustone
      Nicola Mustone says:

      Hi Teo,
      cool idea!

      Actually this is not supported, but we are rewriting the plugin, so perhaps we could add something like this.

      If you’d like you could add this to our ideas board: https://ideas.woothemes.com – that way our developers know what solutions our customers need as they can be voted up and prioritized based on demand.

      Thanks!

      Reply
  2. Alessandro
    Alessandro says:

    Ciao,
    ho fatto come indicato ma quando apro la pagina vendor mi appaiono i seguenti errori:

    Warning: include(/home4/alex/public_html/wp-content/themes/one-child/woocommerce/taxonomy-shop_vendor.php): failed to open stream: No such file or directory in /home4/alex/public_html/wp-content/plugins/woocommerce/includes/wc-core-functions.php on line 195

    Cosa sto sbagliando?

    Warning: include(): Failed opening ‘/home4/alex/public_html/wp-content/themes/one-child/woocommerce/taxonomy-shop_vendor.php’ for inclusion (include_path=’.:/opt/php54/lib/php’) in /home4/alex/public_html/wp-content/plugins/woocommerce/includes/wc-core-functions.php on line 195

    Reply
  3. Alessandro
    Alessandro says:

    ciao, grazie per la risposta veloce.
    ho capito di dover creare cartella woocommerce e file taxonomy-shop_vendor.php nel child-theme.. a quel punto si apriva una pagina bianca alla visione di una pagina vendor..
    quindi ho copiato il file taxonomy-product_cat.php e incollato nella cartella woocomerce col file taxonomy-shop_vendor.php.
    ancora pagina bianca.. quindi ho detto allora non era da copiare il file ma il contenuto del file.. ho copiato il contenuto di taxonomy-product_cat.php in taxonomy-shop_vendor.php ma aquesto punto ricevo una pagina errore 500 – internal server error…

    Reply
  4. Andreas
    Andreas says:

    Hi,
    sounds great, but is this snippet still valid?
    I don’t get it to work, no changes to the vendor template; it still shows the standard layout.
    //Andreas

    Reply
  5. Bond
    Bond says:

    Dosnt seem to work anymore. It looks like the vendor logo and description are being added via a class hook and not a template, making the above code invalid.

    Reply
    • Angeliquw
      Angeliquw says:

      Exactly what I was having an issue with, however the above code does work, it’s just that the taxonomy has a different name, and the template file now needs to be named: taxonomy-wcpv_product_vendors.php

      Rename it, and update your function to match the new name, it’ll work 🙂

      Reply
      • conschneider
        conschneider says:

        Howdy,

        WooCommerce Product Vendors completely changed structure with version 2. Overwriting the template file will not work well any longer.

        The output now uses hooks via the function: `display_vendor_logo_profile()` located in `/includes/class-wc-product-vendors-vendor-frontend.php`.

        Kind regards,

        Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply