Join our new community forum for support & discussion

Join Now

Home Support General HivePress Disable Sort by Price Option

Disable Sort by Price Option

  • Author
    Posts
  • alexif

    Hello!

    I have used the bellow code snippet to disable price on some specific subcategories, but it seems that it does not apply to all of them. I still see the field within the listing.

    add_filter(
    	'hivepress/v1/forms/listing_update',
    	function( $form_args, $form ) {
    		
    		// Categories where field should be hidden.
    		$categories_id = [ 43, 53 ];
    
    		$listing = $form->get_model();
    		
    		if ( isset( $form_args['fields']['price'] ) && array_intersect((array)$listing->get_categories__id(), $categories_id) ) {
    			unset($form_args['fields']['price']);
    		}
    
    		return $form_args;
    	},
    	1000,
    	2
    );
    
    

    Second, I would like to hide the filter and sort by price option for this specific categories where I have disabled it as a field.

    yevhen developer

    You could try to restrict marketplace functionality in HivePress/Settings/Listings/Selling section. Please just choose categories where you want this functionality works

    alexif

    I choose the categories but it is still displaying the filter and sort for all of them…

    yevhen developer

    Please make sure that there are no other Price attributes in Listings/Attributes that may cause this issue. If you restricted Marketplace to categories (in HivePress/Settings/Listings/Selling), then the price filter and the sorting option will appear for the selected categories only.

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

New Reply

This forum has been archived and is no longer accepting new posts or replies. Please join our new community forum for support & discussion.