Generate description for listing from attributes automatically

Does anyone know how to generate description for listings from existing attributes. I want to implement this feature for my users.
For example if an user is listing a double room in London and fills all the attributes ( location, price, pet friendly ect ) they will have the option to generate description, a button with generate description ( without writing) based in that attributes ( for the ease of use) .
Does anyone have a code for this feature.
Thanks

Please try this PHP snippet but please note that it can require further customization. Please change get_attribute_slug on get_ + attribute slug which value you want to add to a listing description

If you are not familiar with the code customization then please consider hiring someone for custom work https://fvrr.co/32e7LvY

add_action('hivepress/v1/models/listing/update', 'custom_set_listing_description', 1000, 2);

function custom_set_listing_description($listing_id, $listing) {
			remove_action('hivepress/v1/models/listing/update', 'custom_set_listing_description', 1000);
	
            $description = null;
	
			if ( $listing->get_attribute_slug() ) {
				$description .= $listing->get_attribute_slug();
			}
			
            // Save description.
            if ($description && $listing->get_description() !== $description) {
                $listing->set_description($description)->save_description();
            }
    }



add_filter(
	'hivepress/v1/models/listing',
	function( $model ) {
		$model['fields']['description']['required']     = false;

		return $model;
	},
	1000
);
1 Like

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