Auto-fill listing field price

Hi there,

I am trying to pre-fill a specific field in the page where new listing’s are created.
This snippet is apparently supposed to do the trick, but isn’t working for me.

add_filter(
'hivepress/v1/models/listing/create', 
	function($form ) {
		if (isset($form['fields']['listing_price'] ) ) {
			$form['fields']['listing_price']['default'] = Fr;
		}

		return $form;
	},
	1000
);

Did something change?

Hi,

Please use this PHP snippet:

add_action(
	'hivepress/v1/models/listing/create', 
	function($listing_id, $listing) {
		$listing->set_price(123)->save_price();
	},
	1000,
	2
);

​I hope this is helpful to you.

Hi @andrii , thank you for the snippet.

Unfortunately it doesn’t work, but maybe that is because I am trying to pre-fill a text field which is a Listing attribute named ‘listing_price’.

Hi,

I see. Please use this PHP snippet:

add_action(
	'hivepress/v1/models/listing/create', 
	function($listing_id, $listing) {
		$listing->set_listing_price(123)->save_listing_price();
	},
	1000,
	2
);

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