And just FYI, there are some other scripts running on the Add listing page as well as my cut/copy/past PHP skills don’t allow me to merge them all.
**Image required:**
*add_filter(*
* 'hivepress/v1/forms/listing_update/errors',*
* function( $errors, $form ) {*
* $listing = $form->get_model();*
* if ( $listing && ! count($listing->get_images__id()) > 1 ) {*
* $errors[] = 'Please upload at least one image for this listing.';*
* }*
* return $errors;*
* },*
* 100,*
* 2*
*);*
*add_filter(*
* 'hivepress/v1/forms/listing_update',*
* function( $form ) {*
* $form['fields']['images']['statuses']['optional'] = null;*
* return $form;*
* },*
* 1000*
*);*
**Field Labels and Descriptions:**
*add_filter(*
* 'hivepress/v1/forms/listing_update',*
* function( $form ) {*
* *
* if(isset($form['fields']['images'])){*
* $form['fields']['images']['description'] = '(1 image required, no more than 5)';*
* }*
* if(isset($form['fields']['title'])){*
* $form['fields']['title']['description'] = '(max 60 charactres)';*
* }*
* if(isset($form['fields']['price'])){*
* $form['fields']['price']['description'] = '(per listing)';*
* }*
* if(isset($form['fields']['price_extras'])){*
* $form['fields']['price_extras']['description'] = 'Specify any extra items offered at an additional charge.';*
* }*
* if(isset($form['fields']['description'])){*
* $form['fields']['description']['description'] = '(max 600 charactres)';*
* }*
* if(isset($form['fields']['purchase_note'])){*
* $form['fields']['purchase_note']['description'] = 'Note that will be revealed at purchase.';*
* } *
* if(isset($form['fields']['booking_offset'])){*
* $form['fields']['booking_offset']['label'] = 'PURCHASE OFFSET';*
* }*
* if(isset($form['fields']['booking_offset'])){*
* $form['fields']['booking_offset']['description'] = 'How many days are required prior purchase date.';*
* }*
* if(isset($form['fields']['booking_days'])){*
* $form['fields']['booking_days']['description'] = 'Day/s available for purchase.';*
* }*
* *
* return $form;*
* },*
* 1000*
*);*
**Fields unset:**
*add_filter(*
* 'hivepress/v1/forms/listing_update',*
* function( $form ) {*
* unset( $form['fields']['booking_window'] );*
* unset( $form['fields']['booking_min_time'] );*
* unset( $form['fields']['booking_max_time'] );*
* unset( $form['fields']['booking_min_quantity'] );*
* unset( $form['fields']['booking_max_quantity'] );*
* unset( $form['fields']['booking_slot_duration'] );*
* unset( $form['fields']['booking_slot_interval'] );*
* unset( $form['fields']['booking_moderated']);*
* //unset( $form['fields']['booking_min_length'] );*
* //unset( $form['fields']['booking_max_length'] );*
* return $form;*
* },*
* 1000*
*);*
**Extras field option:**
*add_filter(*
* 'hivepress/v1/models/listing/attributes',*
* function($attributes){*
* if(isset($attributes['price_extras'])){*
* $attributes['price_extras']['edit_field']['fields']['type']['options'] = [*
* 'per_order' => 'per item',*
* ];*
* }*
* *
* 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_order' => 'per extra',*
* ],*
* '_order' => 30,*
* ];*
* }*
* }*
* if ( $is_model ) {*
* $form = $fields;*
* } else {*
* $form['fields'] = $fields;*
* }*
* return $form;*
*}*