Home Support Extensions Messages Display Message Button only for certain listing

Display Message Button only for certain listing

  • Author
    Posts
  • shotsandvideos

    Hi! Is there a way to display the message/contact button for a listing based only on the presence of a given attribute?

    Another question: is there a way to forward a message to the vendor email automatically?

    ihor developer

    Sorry, there’s no option to enable/disable messages per listing at the moment, this would require custom implementation. By default, vendors get an email notification if there’s a new message and you can include the message text there with the %message_text% token.

    shotsandvideos

    Ok thanks!

    And another question: could it possible to display a contact form that automatically send a message to email recipient specified with the token %value%?

    I desperately need to give chance to be contacted only for certain vendors.

    What should I do?

    ihor developer

    If possible send more details, do you mean some checbox option for vendors (per vendor or listing) to display/hide the Send Message button on the front-end?

    shotsandvideos

    Not exactly. I have an “email” attribute, but not every vendor has one. I would like to enable messages only for those who have it.

    Or, to make it easier, a function that hides the message button for all those vendors who don’t have email in their attributes.

    Otherwise I would like to set a form in the text field of my email attribute, so that only those who inserted email can receve a message.

    ihor developer

    Sorry, this would require customizations because there are multiple places where the Send Message button/icon appears. It’s possible to check the attribute value to show/hide this form, but please note that this custom attribute value is not linked with the email address, messages are always sent to the user’s email address set in My Account/Settings section.

    shotsandvideos

    OK, so what would be the easiest way, without customization? How would you do it?
    Thanks again for your support!

    ihor developer

    Unfortunately there’s no simple code snippet for it. I can post a snippet for hiding a single button (e.g. on the listing page) depending on the attribute value and you can consider hiding all the other message buttons/icons via CSS, please let me know if this works for oyu.

    shotsandvideos

    Yes please, that is absolutely viable. Thank you! 🙂

    ihor developer

    Please try this one (you can add it via the Code Snippets plugin):

    add_filter(
    	'hivepress/v1/templates/listing_view_page/blocks',
    	function( $blocks, $template ) {
    		$listing = $template->get_context( 'listing' );
    
    		if ( $listing && ! $listing->has_attributenamehere() ) {
    			$blocks = hivepress()->helper->merge_trees(
    				[ 'blocks' => $blocks ],
    				[
    					'blocks' => [
    						'message_send_link' => [
    							'type' => 'content',
    						],
    					],
    				]
    			)['blocks'];
    		}
    
    		return $blocks;
    	},
    	1000,
    	2
    );
    staarkos

    in wich line i need change listing name or atribute in your code.

    i copieed this but i cant understand what i need change

    ihor developer

    Please try replacing the “attributenamehere” part with the attribute name that defines the Send Message button visibility.

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.