Hide the 2 extra call price options

hide the 2 extra call price options

  • by location (hide)
  • by location and day
    and leave the other 2 options visible:
  • per booking
  • per day

Please try this PHP snippet

add_filter(
	'hivepress/v1/models/booking/attributes',
	function($attributes){
		if(isset($attributes['price_extras'])){
			$attributes['price_extras']['edit_field']['fields']['type']['options'] = [
				'' => 'per day',
				'per_order' => 'per booking',
			];
		}
		return $attributes;
	},
	1000
);

Forgive me yevhen, I explained it wrong to you

I just want to make the “per Day” option visible.

And hide the other 3 options so that they do not appear and cannot be selected.

Sorry for the error

Please try this PHP snippet instead

add_filter(
	'hivepress/v1/models/booking/attributes',
	function($attributes){
		if(isset($attributes['price_extras'])){
			$attributes['price_extras']['edit_field']['fields']['type']['options'] = [
				'' => 'per day',
			];
		}
		return $attributes;
	},
	1000
);

sorry yevhen I tried it but it doesn’t work.
I have added it with code snippets but it doesn’t work.
I send you a picture so you can see what I need.
I want to display only one of the 4 options that are displayed when adding a being. Only the option “per day”.
Thank you very much

Please try this PHP snippet instead

add_filter(
	'hivepress/v1/models/listing/attributes',
	function($attributes){
		if(isset($attributes['price_extras'])){
			$attributes['price_extras']['edit_field']['fields']['type']['options'] = [
				'' => 'per day',
			];
		}
		
		return $attributes;
	},
	1000
);

add_filter( 'hivepress/v1/models/listing/fields', 'change_price_extras_custom', 200, 2 );
add_filter( 'hivepress/v1/forms/listing_update', 'change_price_extras_custom', 200, 2 );
add_filter( 'hivepress/v1/meta_boxes/listing_attributes', 'change_price_extras_custom', 200 );
add_filter( 'hivepress/v1/models/vendor/fields', 'change_price_extras_custom', 200, 2 );
add_filter( 'hivepress/v1/forms/vendor_update', 'change_price_extras_custom', 200, 2 );
add_filter( 'hivepress/v1/meta_boxes/vendor_attributes', 'change_price_extras_custom', 200 );

function change_price_extras_custom($form, $model = null){
		$is_form    = strpos( current_filter(), 'form' );
		$is_model   = strpos( current_filter(), 'model' );
		$is_listing = strpos( current_filter(), 'listing' );
		$per_vendor = get_option( 'hp_booking_per_vendor' );

		if ( ! $is_listing && ! $per_vendor ) {
			return $form;
		}
		$fields = [];

		if ( $is_model ) {
			$fields = $form;
		} else {
			$fields = $form['fields'];
		}
		$listing_id = null;

		if ( $is_listing ) {
			if ( $is_model ) {
				$listing_id = $model->get_id();
			} elseif ( $is_form ) {
				$listing_id = $model->get_model()->get_id();
			} else {
				$listing_id = get_the_ID();
			}

			if ( ! $listing_id || ! hivepress()->booking->is_booking_enabled( $listing_id ) ) {
				return $form;
			}
		}


		if ( $is_listing && hivepress()->get_version( 'marketplace' ) ) {
			if ( get_option( 'hp_listing_allow_price_extras' ) ) {
				$fields['price_extras']['fields']['type'] = [
					'type'    => 'select',
					'options' => [
						'' => 'per day',
					],
					'_order'  => 30,
				];
			}
		}
		if ( $is_model ) {
			$form = $fields;
		} else {
			$form['fields'] = $fields;
		}

		return $form;
}

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