Vendor List Widget and Vendors Page– Hide Vendors with zero products?
Home / Topic / WCMp Core / 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
- This topic has 21 replies, 6 voices, and was last updated 1 year, 7 months ago by
NerdySupportExpert Moumita.
-
AuthorPosts
-
-
October 30, 2018 at 4:08 AM #44885
admin24
ParticipantIs there a way to do this? The list gets cluttered with vendors who have not gotten around to loading items yet. Thank you.
-
October 30, 2018 at 5:58 AM #44898
CrazyPluginAuthor Khokan
KeymasterHi @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
Copyand fetch the vendor from here.
Let us know if you have any further query.
-
October 30, 2018 at 6:42 AM #44901
admin24
ParticipantThanks but I lack the necessary skills. May I ask this feature be added in the future?
-
October 30, 2018 at 7:15 AM #44904
NerdySupportExpert Moumita
Keymaster@admin24, I have added this in our feature list. Once this will be added, we will let you know.
-
October 30, 2018 at 8:21 PM #44968
redilson
ParticipantWCMP 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.
-
October 31, 2018 at 1:59 AM #44984
NerdySupportExpert Moumita
KeymasterSure @redilson, we will provide an option, whether admin will show/hide the vendors who have no products.
-
May 4, 2019 at 9:01 PM #60727
admin24
ParticipantHello, just checking on any update with this please since October.
-
May 8, 2019 at 5:12 AM #61007
Raju The Cool Guy
KeymasterHi @admin24,
in order to hide vendors with zero products from vendor list wigdet use this code snippetadd_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 -
May 10, 2019 at 7:47 AM #61184
Raju The Cool Guy
KeymasterHi @@admin24,
Add this code to hide vendors with 0 products from vendor list pageadd_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 -
May 10, 2019 at 11:09 PM #61220
admin24
ParticipantAbsolutely 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?
-
May 25, 2019 at 1:48 AM #62460
NerdySupportExpert Moumita
Keymaster@admin24, we don’t display the suspended vendors in the vendor list page and widget also.
Can you please check.
-
May 26, 2019 at 1:15 AM #62565
admin24
ParticipantThis reply has been marked as private. -
May 29, 2019 at 8:35 AM #62822
NerdySupportExpert Moumita
KeymasterThis reply has been marked as private. -
May 31, 2019 at 6:31 PM #63016
admin24
ParticipantThis reply has been marked as private. -
May 31, 2019 at 11:27 PM #63029
NerdySupportExpert Moumita
KeymasterThis reply has been marked as private. -
June 11, 2019 at 1:37 AM #63862
admin24
ParticipantThis reply has been marked as private. -
June 11, 2019 at 4:09 AM #63885
NerdySupportExpert Moumita
KeymasterThis reply has been marked as private. -
June 11, 2019 at 9:45 PM #63938
admin24
ParticipantThis reply has been marked as private. -
June 13, 2019 at 2:25 AM #64109
Raju The Cool Guy
Keymaster@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 -
June 13, 2019 at 11:56 PM #64166
admin24
ParticipantThat did the trick! Thanks for taking another look!
-
June 14, 2019 at 3:45 AM #64183
NerdySupportExpert Moumita
KeymasterYou are welcome @admin24
-
-
AuthorPosts
The topic ‘Vendor List Widget and Vendors Page– Hide Vendors with zero products?’ is closed to new replies.