Only display the Marketplace Dashboard if vendor has listings in certain categories?

Hi,

I’m building a platform that’s a combination of a directory and a marketplace. In some categories the vendors don’t sell anything, they simply list the information, so there is no need for a dashboard that tells them their “revenue.”

In other categories, they can sell things. That’s when the dashboard is necessary.

Is there a way to separate the two types of vendors and only display the dashboard on vendors who has listings in the categories that sell things?

Thanks

Please try this PHP snippet. Please just change 1,2,3 on listing categories which vendor should have to see the vendor dashboard

add_filter(
	'hivepress/v1/menus/user_account/items',
	function($menu){
		
		if(!current_user_can('edit_posts')){
			return $menu;
		}
		
		$vendor_id = HivePress\Models\Vendor::query()->filter(['user' => get_current_user_id()])->get_first_id();
		
		if(!$vendor_id){
			return $menu;
		}
		
		$listing = HivePress\Models\Listing::query()->filter(['vendor' => $vendor_id, 'categories__in' => [1,2,3]])->get_first_id();
		
		if($listing){
			return $menu;
		}
		
		unset($menu['vendor_dashboard']);
		
		return $menu;
	},
	1000
);
2 Likes

Wow! This is perfect. Thank you!

1 Like

That worked great, these little details are much appreciated!

By any chance do you have a code snippet to be able to insert any type of listing attribute into the listing description form? I have a hosting website and want to put one or two required attributes that the host has to write inside the listing description box, so things can be organized and presented uniformly to my users.

If you mean embedding attributes into the description text area unfortunately there’s no simple solution for this, I recommend using separate category-specific attributes if required by marking them as Editable.

I am using separate category attributes and have them as editable, however, I need it displayed underneath the listing description not on top where the listing page primary or page secondary is.

I was hoping there was a simple snippet to just display these attributes underneath the listing description instead.

Yes, it’s possible to move the Secondary attributes area under the description with a simple snippet, but this also depends on the theme you’re using, and since there are only 2 areas it will be impossible to add attributes above the description (the whole area will be moved). Let me know if this works for you.

Yes a code snippet for primary attributes actually would work better for me underneath the description, not the secondary attributes, as I would like to leave secondary attributes on top of description.

Is it possible to put the primary attributes underneath the description but just keep the price still in the same top right section? If not I will settle for just placing primary attributes underneath the description.

Thank you! I have listinghive

If possible to have both

Thank you! I have listinghive

Please try this PHP snippet to move primary attributes under the description. Unfortunately, there is no such possibility to move primary attributes without price attribute

add_filter(
	'hivepress/v1/templates/listing_view_page',
	function( $template ) {
		return hivepress()->helper->merge_trees(
			$template,
			[
				'blocks' => [
					'page_sidebar' => [
						'blocks' => [
							'listing_attributes_primary' => [
								'type' => 'content',
							],
						],
					],
					
					'page_content' => [
						'blocks' => [
							'listing_attributes_primary' => [
								'type'      => 'attributes',
								'model'     => 'listing',
								'area'      => 'view_page_primary',
								'_label'    => hivepress()->translator->get_string( 'attributes' ) . ' (' . hivepress()->translator->get_string( 'primary_plural' ) . ')',
								'_settings' => [ 'columns' ],
								'_order'    => 61,
							],
						],
					],
				],
			]
		);
	},
	1000
);
1 Like

Hi, it works thank you! :slightly_smiling_face:

How do I disable the Post related (not the related listings), it is currently above the listing attributes page primary. I go to appearance/customize/post related and I can take out the thumbnail images and header, but how do I either push it below the attributes page primary or remove it completely? So it is not in the way of the listing description followed by attributes primary. Thanks again!

It seems like a custom widget that comes from WordPress and some third-party plugins. Please try to check this widget in Appearance/Widgets where it is possible to remove it from the listing sidebar

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