ResolvedVendors with Zero Products
- This topic has 2 replies, 2 voices, and was last updated 2 years, 9 months ago by
SameenaHarrington.
- AuthorPosts
- December 3, 2020 at 3:36 pm #27577
SameenaHarrington
ParticipantHi,
I can see that WCMP have some code they use with vendor list widget to hide any vendors with zero products from showing. Is there something similar which can be used for the Rigid vendor short code list?
o hide vendor with 0 product from vendor list
Please add this code in the function.php of the current active theme :/**
** Hide zero product vendor on wcmp vendor list page
**/
add_filter(‘wcmp_vendor_list_get_wcmp_vendors_args’, ‘hide_zero_product_vendor_on_vendor_list_page’ , 10 , 4 );
function hide_zero_product_vendor_on_vendor_list_page ( $query, $order_by, $request, $atts ) {
$vendor = get_wcmp_vendors();
$vendor_ids = wp_list_pluck($vendor , ‘id’);
foreach ($vendor_ids as $key => $value) {
$vendor = get_wcmp_vendor($value);
$vendor_products = $vendor->get_products();
if (empty($vendor_products)){
$get_vendor[] = $value;
}
}
$query[‘exclude’] = $get_vendor;
return $query;
}
Copy
To hide vendor with 0 product from vendor list widget
Please add this code in the function.php of the current active theme :/**
** 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;
Thank,
SameenaDecember 4, 2020 at 1:00 pm #27628Althemist
KeymasterHi Sameena,
I’ll discuss with the team if it’s possible to include this in the next update.
Thanks for your feedback.
Regards,
DimitarDecember 4, 2020 at 1:32 pm #27640SameenaHarrington
ParticipantGreat thank you 🙂
- AuthorPosts
You must be logged in and have valid license to reply to this topic.