ResolvedVendors with Zero Products

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #27577
    SameenaHarrington
    Participant

    Hi,

    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,
    Sameena

    #27628
    Althemist
    Keymaster

    Hi Sameena,

    I’ll discuss with the team if it’s possible to include this in the next update.

    Thanks for your feedback.

    Regards,
    Dimitar

    #27640
    SameenaHarrington
    Participant

    Great thank you 🙂

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in and have valid license to reply to this topic.

License required for the following item
Login and Registration Log in · Register