Hide price for a specific category

1- hi,
I want to hide the price for one of the categories, so I used the following code replacing 1,2,3 with the ID of the category to hide but it hides the price on all categories
Moreover when I hide the price, at the addition of ad impossible to validate because even if the price is hidden I am told “to indicate the price” :

	function( $attributes ) {
		if ( isset($attributes['price']) ) {
			$attributes['price']['categories'] = [1,2,3];

		return $attributes;

2-Then I would like to adjust the image of the header because it does not fit into the frame and is there a different adjustment for the pc and mobile, thank you very much

1 Like
  1. Please try to set listing categories in the Categories setting in HivePress/Settings/Listings/Selling section. Then the attribute price and marketplace functionality will work only for these categories

  2. Sorry for the inconvenience, but customization is beyond our support scope - it includes fixing bugs and guidance about the available features Support Policy | HivePress
    If customizations are required for your site, please try customizing it using the collection of code snippets Search · user:hivepress · GitHub and other developer resources, or consider hiring someone for custom work https://fvrr.co/32e7LvY

  • i think you didn’t misunderstand me or I expressed myself badly: I used the code above to hide the price field (of the theme) in the addition of an ad but I want to hide it only for a category: when I put the name of the category instead of 1,2,3 it doesn’t work…

  • moreover when I hide the price field, if I add the ad when validating it tells me that the “price” field must be filled in when it is hidden

It is possible to use the code snippet which was provided by you. But please note that here category IDs are set where the price attribute is shown. So if you set 1,2,3 as price attribute categories, then this attribute will be shown only in these categories. But please note that if you use the HivePress Marketplace extension on your website, then it is recommended to set listing categories in the Categories setting in the HivePress/Settings/Listings/Selling section. As in this case, the price attribute is a specific attribute that is needed for the correct operation of this extension functionality

@yevhen @ihor It doesn’t work, I want to hide the “price” field (theme) for 2 of the three categories I have in the “Add ad” page, because I want to use a price/session attribute that I add manually on the ad attributes. The problem is that when I use the code above and replace (1,2,3) with “housing” which is the name of the category I want to hide it hides the 3 categories… I use Marketplace but the proposed solution does not work either

Please put category id, not category name, instead of 1,2,3 in the code snippet

1 Like

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