Limit price of listings for certain categories

Hi, is there a php snippet to limit the price a vendor can set for their listing on certain categories? (ie. set a max of $50 for a category but allow no limits for other categories)

Please try this PHP snippet. Please change put_categories_id_here on the listing categories id number, which a comma can separate if you want to set the maximum value for field price for different categories. Please note that it can require further customization. If you are not familiar with the code customization, then please consider hiring someone for custom work https://fvrr.co/32e7LvY

add_filter(
	'hivepress/v1/forms/listing_update',
	function($args, $form){
		$listing = $form->get_model();
		
		if(!isset($args['fields']['price']) || !$listing || !array_intersect([put_categories_id_here], $listing->get_categories__id())){
			return $args;
		}
		
		$args['fields']['price']['max_value'] = 50;
		
		return $args;
	},
	1000,
	2
);

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