fbpx

Vendor List Widget and Vendors Page– Hide Vendors with zero products?

WCMp Core

Vendor List Widget and Vendors Page– Hide Vendors with zero products? Resolved

Viewing 20 reply threads
  • Author
    Posts
    • #44885
      admin24
      Participant

      Is there a way to do this? The list gets cluttered with vendors who have not gotten around to loading items yet. Thank you.

    • #44898

      Hi @admin24, you can hide vendor’s from vendor list page, you need to add your custom code using this filter

      wcmp_vendor_list_data
      Copy

      .

      In order to hide vendor’s from the widget, you need to override “vendor-list.php” template file and use this filter

      get_wcmp_vendors
      Copy

      and fetch the vendor from here.

      Let us know if you have any further query.

    • #44901
      admin24
      Participant

      Thanks but I lack the necessary skills. May I ask this feature be added in the future?

    • #44904

      @admin24, I have added this in our feature list. Once this will be added, we will let you know.

    • #44968
      redilson
      Participant

      WCMP Staff: If you do add this, please make it a checkbox option in the settings or a parameter in the shortcode. Other users, like myself, may need the vendors to display on the Vendors List even if they don’t have any products entered.

    • #44984

      Sure @redilson, we will provide an option, whether admin will show/hide the vendors who have no products.

    • #60727
      admin24
      Participant

      Hello, just checking on any update with this please since October.

    • #61007

      Hi @admin24,
      in order to hide vendors with zero products from vendor list wigdet use this code snippet

      add_filter('wcmp_widget_vendor_list_query_args','check');
      function check($firstvalue){
          $array_value = array();
          $get_vendor = get_wcmp_vendors($firstvalue);
          foreach ($get_vendor as $key => $value) {
              $vendor = get_wcmp_vendor($value->id);
              $vendor_products = $vendor->get_products();
              if (empty($vendor_products)){
                      $array_value[] = $value->id;
                 }
          }
          $firstvalue['exclude'] =  $array_value;
          return $firstvalue;
      }
      Copy
    • #61184

      Hi @@admin24,
      Add this code to hide vendors with 0 products from vendor list page

      add_filter('wcmp_vendor_list_data','vendor_list_shortcode_modification');
      function vendor_list_shortcode_modification($value1){
          $array_value = array();
          foreach ($value1['vendors'] as $key => $value) {
          $vendor = get_wcmp_vendor($value);
          $vendor_products = $vendor->get_products();
          if (!empty($vendor_products)){
              $array_value[] = $value;
              }
          }
          $value1['vendors'] = $array_value;
          return $value1;
      }
      Copy
    • #61220
      admin24
      Participant

      Absolutely perfect. Thank you so much, this really streamlines things well for me.

      One thing I just noticed, is that I have one suspended vendor that is showing in the widget. It is not related to this code at all, but I thought I remembered suspended vendors being removed here. It is removed from the vendors list page though. Is this a glitch?

    • #62460

      @admin24, we don’t display the suspended vendors in the vendor list page and widget also.

      Can you please check.

    • #62565
      admin24
      Participant
      This reply has been marked as private.
    • #62822
      This reply has been marked as private.
      • #63015
        admin24
        Participant
        This reply has been marked as private.
    • #63016
      admin24
      Participant
      This reply has been marked as private.
    • #63029
      This reply has been marked as private.
    • #63862
      admin24
      Participant
      This reply has been marked as private.
    • #63885
      This reply has been marked as private.
    • #63938
      admin24
      Participant
      This reply has been marked as private.
    • #64109

      @admin24, Sorry for this inconvenience. Use this updated code :

      /**
      ** Hide zero product vendor on wcmp vendor list widget
      **/
      add_filter('wcmp_widget_vendor_list_query_args','wcmp_hide_zero_product_vendor_on_vendor_list_widget');
      function wcmp_hide_zero_product_vendor_on_vendor_list_widget($vendor_ids){
          $array_value = array();
          $get_vendor = get_wcmp_vendors($vendor_ids);
          $block_vendors = wp_list_pluck(wcmp_get_all_blocked_vendors(), 'id');
          foreach ($get_vendor as $key => $value) {
              $vendor = get_wcmp_vendor($value->id);
              $vendor_products = $vendor->get_products();
              if (empty($vendor_products)){
                  $array_value[] = $value->id;
              }
          }
          $marge_block_and_zero_product_vendor = array_merge($array_value,$block_vendors);
          $vendor_ids['exclude'] =  $marge_block_and_zero_product_vendor;
          return $vendor_ids;
      }
      Copy
    • #64166
      admin24
      Participant

      That did the trick! Thanks for taking another look!

    • #64183

      You are welcome @admin24

Viewing 20 reply threads

The topic ‘Vendor List Widget and Vendors Page– Hide Vendors with zero products?’ is closed to new replies.

Buy all Marketplace addons together, check out our Bundle

Buy at Slashed Price