Create custom fields inside make an offer popup

How can I add in a few extra fields in the make an offer popup? Or even some descriptions and text?

Hi,

Please use this code snippet [How to add custom code snippets - HivePress Help Center]:

add_filter(
	'hivepress/v1/forms/offer_make',
	function ( $form ) {
		$form['fields']['custom_name'] = array(
			'type'  => 'text',
			'label' => '123',
		);

		return $form;
	}
);

Hope this helps

How do I make these fields then show in the offers that the organiser receives? The price and details just show, not the new ones.

Sorry for the confusion. After looking into it further, it seems this is more complex than a simple code snippet. While we can’t provide customization within our support scope, you can refer to this thread, where there’s a solution on how to add a price field to the offer form. You can adjust this code for your case by replacing the attribute name and making other necessary changes.

Hope this helps

Thank you, I have it sort of working but I am having trouble changing this bit in the code, I can’t get it pull in the new field content:

add_filter( 'hivepress/v1/models/offer', 'add_offer_fields', 1000);
add_filter( 'hivepress/v1/forms/offer_make', 'add_offer_fields', 1000);

function add_offer_fields($model){
	if ( get_option( 'hp_offer_allow_bidding' ) ) {
		$model['fields']['custom-name'] = [
			'label'     => 'Additional expenses',
			'type'      => 'text',
			'min_value' => 0,
			'required'  => false,
			'_external' => true,
			'_order'    => 5,
		];
	}
	return $model;
}

add_filter( 
	'hivepress/v1/templates/offer_view_block/blocks', 
	function($blocks, $template){
		$offer = $template->get_context('offer');
		
		if(!$offer){
			return $blocks;
		}
		
		if ( get_option( 'hp_offer_allow_bidding' ) ) {
			return hivepress()->template->merge_blocks(
				$blocks,
				[
					'offer_attributes_primary' => [
						'blocks' => [
							'custom_name' => [
								'type'   => 'content',
								**'content'   => '<div class="hp-offer__attribute hp-offer__attribute--price">'.esc_html($offer->get_price()).'</div>',**
								'_order' => 10,
							],
						],
					],
				],
			);
		}
		
		return $blocks;
	}, 
	1000,
	2
);

To reference the desired field, please replace all instances of price in the text with your custom field name. If the field name contains more than one word, please use underscores instead of spaces. For example: custom_field_name.

Hope this helps

Thank you, I had done that but had a character wrong. Thank you for you help.

1 Like

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