Hi, I want to hide all the price extras fields “per place per day”, “per day”, “per booking”, and only keep “per place”. How can I do this? I followed other topics such this one but I did not find a solution: Can you explain price extra types?
Can you please help me find a code snippet to keep only the “per place” option?
Thank you very much!
ihor
June 4, 2023, 7:21pm
2
I noticed that this one regards “per booking”, how should I customize it to make sure that the only price filter is for “per place”?
yevhen
June 7, 2023, 1:25am
10
Please try this PHP code snippet.
add_filter(
'hivepress/v1/models/listing/attributes',
function($attributes){
if(isset($attributes['price_extras'])){
$attributes['price_extras']['edit_field']['fields']['type']['options'] = [
'per_quantity' => 'per place',
];
}
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_quantity' => 'per place',
],
'_order' => 30,
];
}
}
if ( $is_model ) {
$form = $fields;
} else {
$form['fields'] = $fields;
}
return $form;
}
Awesome, it worked! Unfortunately though, “per place” is not translated in Italian anymore (I translated my website in Italian with loco translate). I tried to go to LocoTranslate>Plugins>HivePressBookings>"pricing"per place
I tried to translate the field again but the name shown is still “per place” and not “a cliente” as it should be displayed in Italian.
Do you know how can I show the text displayed in Italian again?
andrii
June 8, 2023, 2:19pm
16
Hi,
You must change the code (change ‘per place’ to your title) above to display the translation correctly.
andrii
June 9, 2023, 6:25am
18
Hi,
Yes, also, please replace per place in the second snippet.
andrii
June 9, 2023, 6:40am
20
Yes, these two strings must be changed to your translation, and everything should be displayed correctly.
system
Closed
July 9, 2023, 6:41am
21
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.