Verified vendors show up first in vendors page, like featured listings on the listing page

Hello, would it be possible on the ListingHive theme, verified vendors to show up first, at the top of the results and everyone else get displayed below them regardless of title, date or rating? Basically like the featured listings you get on the listing page.

Hi,
Unfortunately, there’s no such option for vendors at the moment, verified vendors just have an extra “Verified” badge and you can use the Vendors block to show selected verified vendors on custom pages like Home.

Would it be possible by adding custom php code?

Sorry, there’s no simple code snippet for implementing this, it would require duplicating the Featured functionality but for vendors instead of listings. We’ll consider adding this feature to future updates, though.

1 Like

How do I set a default value to a custom vendor attribute? (Please read below)
So I figured out a simple way on how to display them.

I created a custom vendor attribute and I called it default rate and set a field name of vendor_default_rate.

I assigned the field type as a Number, with a min value of 1 and Decimal of 1. But no front-end editing.

Every category has that value and I display it as a sorting option.

Every verified member gets a higher value for this field (example 5), and everyone else gets a lower value (example 1). So when you sort them descending it shows the verified members first.

But I have just one more little problem, how do I set default values to these fields, in my case there would be only 5 verified members only all the time which means setting them manually is not a problem, but I need to set a default value of 1 or any number to everyone else.

So my question is, how do I set a default value to a custom vendor attribute like described above? And also set a default sorting option?

I appreciate your support, hope you can help me out.
Thank you.

Implementing the default sorting option would require advanced customization, there is no simple code snippet for it

To set the default attribute value please try this PHP snippet

add_filter(
	'hivepress/v1/meta_boxes/vendor_attributes',
	function($args){
		if(isset($args['fields']['vendor_default_rate'])){
			$args['fields']['vendor_default_rate']['default'] = 1;	
		}
		
		return $args;
	},
	1000
);
1 Like

Okay, thank you it works.

Hello yevhen,

This snippet does work, but only from the backend, like when you manually add a vendor profile as an admin. When you create a profile from the frontend as a user, the value is set, but does not actually register, meaning its there, but it does not save it in the system. In order for it to work you have to update the profile from the dashboard.

Any idea why would this be happening?

Also getting a error after the snippet

Warning: Illegal offset type in .\app\public\wp-includes\class-wp-hook.php on line 78

Please try this PHP snippet instead. It will set vendor_default_rate value to 1 when creating a vendor account

add_action(
	'hivepress/v1/models/vendor/create',
	function ($vendor_id, $vendor){
		$vendor->set_vendor_default_rate('1')->save_vendor_default_rate();
	},
	1000,
	2
);
2 Likes

Now we are talking!

Now it works perfectly, thank you yevhen. Hope I wasn’t anoying :sweat_smile:

Have a great day!
Stefan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.