Hide products tab on store page if no products

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WC Marketplace Hide products tab on store page if no products

Viewing 9 reply threads
  • Author
    Posts
    • #75437
      nict
      Participant

      I would like to hide the products tab on the vendor’s store page if the vendor has no products to display. Is there something I can add to functions to achieve this?

      Attachments:
      You must be logged in to view attached files.
    • #75876
      WCFM Forum
      Member

      Hi,

      Sorry, this is not possible. Products is default tab for Store page.

      Well, you may hide those stores from store list which not yet have any products.

      Use short code like this – [wcfm_stores has_product="yes"]

      Thank You

    • #75880
      nict
      Participant

      Ah I need those stores to be on the list though. Is there a way to reorder the tabs so that The products tabs isn’t the first tab?

    • #76210
      WCFM Forum
      Member

      Hi,

      Is there a way to reorder the tabs so that The products tabs isn’t the first tab?

      – Well, it’s possible to re-arrange store tabs, but product tab should the first one.

      Thank You

    • #76231
      nict
      Participant

      lol i get that but in my specific case it would be better to not display the products tab for a certain vendor group, and if not possible to hide it, at least make it so that I don’t have it displayed as the first tab. So if you have some snippet for me to use in order to achieve that ( ? ), that would be great and much appreciated.

    • #76589

      Hi,

      Try this code to hide the products tab on the vendor’s store page if the vendor has no products

      add_filter( 'wcfmmp_store_tabs', 'new_wcfmmp_store_tabs',90,2);
      function new_wcfmmp_store_tabs($store_tabs, $vendor_id) {
          if(get_wcfm_vendor_have_product($vendor_id) < 1) {
              unset($store_tabs['products']);
          }
          return $store_tabs;
      }
      add_filter('wcfmp_store_default_query_vars',function($tab,$vendor_id){
          if(get_wcfm_vendor_have_product($vendor_id) < 1) {
              return 'about';
          } else {
              return 'products';
          }    
      },20,2);
      function get_wcfm_vendor_have_product($vendor_id) {
          $args=array(
               'post_type' => 'product',
               'post_status' => 'publish',
               'author' => $vendor_id
                );
          $have_products = get_posts( $args );
          return count($have_products);
      }

      Copy the code at the end of functions.php of your activated theme. Also update the plugin(WCFM Marketplace) before adding this code.
      Let me know if it is ok.

      Thank You for your patience.

    • #76600
      nict
      Participant

      Hi hi. Thanks for the snippet but when trying it the site fails to load on the frontend. “The site is experiencing technical difficulties.”

      • #76608

        Hello,

        Can you share us your site and ftp access. So, we can debug the issue in your site.
        We presume that you have already updated the plugins.

        Thank You.

    • #76625
      nict
      Participant
      This reply has been marked as private.
      • #76626
        This reply has been marked as private.
        • #76639
          nict
          Participant
          This reply has been marked as private.
    • #82246
      Michael Elliott
      Participant

      Sorry to jump in but how do I list all the stores? I can”t find the setting that I changed that prevented vendors with no products from being listed and now I need to change that back.

    • #82481
      WCFM Forum
      Member

      Hi,

      Well, you just have to create a page using short code – [wcfm_stores]

      Please check this for details – https://docs.wclovers.com/store-list/

      Thank You

Viewing 9 reply threads
  • You must be logged in to reply to this topic.