Join our new community forum for support & discussion

Join Now

Home Support Themes RentalHive Hiding Price Snippet (needs alteration)

Hiding Price Snippet (needs alteration)

  • Author
    Posts
  • rachelle

    Hello!
    A couple of weeks ago one of you provided the following code snippet for hiding the $0 price and the “book now” button on non-bookable categories. The issues I’ve discovered is that this snippet also hides the ability to filter for price in the menu on the search page.

    Basically users can no longer filter places by price. Any thoughts on how I might modify the snippet so that it still hides the price on non-bookable categories but lets the rest of my listings be filterable by price (because majority of my listings have prices)?

    Here’s the snippet:

    add_filter(
    	'hivepress/v1/models/listing/attributes',
    	function( $attributes ) {
    		$category_ids = [86,89,24,100,104,126,50,14,49,29];
    
    		if ( isset( $attributes['price'] ) ) {
    			$attributes['price']['categories'] = $category_ids;
    		}
    
    		if ( isset( $attributes['booking_offset'] ) ) {
    			foreach ( $attributes as $name => $args ) {
    				if ( strpos( $name, 'booking' ) === 0 ) {
    					$attributes[ $name ]['categories'] = $category_ids;
    				}
    			}
    		}
    
    		return $attributes;
    	},
    	1000
    );
    yevhen developer

    We added a new option for restricting bookings to specific categories only since then, please try selecting categories in HivePress/Settings/Bookings – the code snippet may not be required.

Viewing 2 posts - 1 through 2 (of 2 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.