Integrate IRE "Book Inspection" and "Apply Now" buttons for Rental Properties on Malcolm Real Estate Websites

This guide will help you customize the property key details block for the property listing single page by adding “Book Inspection” and “Apply Now” buttons on Residential-Lease properties.

1. Access Your Theme’s Functions File

  • To begin, log in to your WordPress admin dashboard.
  • Next, navigate to the “Appearance” menu and select “Theme Editor.”
  • In the right-hand panel, you’ll see a list of theme files. Find and click on the “functions.php” file associated with your currently active theme.

2. Insert the Provided Code

  • Once you’ve opened the “functions.php” file, scroll to the bottom or a convenient location for adding custom code.
  • This can also be done if you have installed code snippets plugin in your WordPress site like WPCode and Code Snippets to insert the code.
  • Copy and paste the following code snippet into the “functions.php” file:
// Override related elements to filter by bedrooms
add_action( 'rep__after_the_property_key_details', function ($post_id) {
	if( function_exists( 'Launchpad\lp__get_field_value' ) ){
		$search_category = \Launchpad\lp__get_field_value( 'search_category', $post_id );
		$address = \Launchpad\lp__get_field_value('display_address', $post_id);

		if( strtolower( $search_category ) == 'residential-lease' && !empty($address) ) : 
			$encoded_address = urlencode( $address );
			$BookInspectionURL = 'https://book.inspectrealestate.com.au/Register?AgentAccountName=AllProperties&address=' . $encoded_address . '&Type=rental';
			$ApplyNowURL = 'https://2apply.com.au/Form?AgentAccountName=AllProperties&Address=' . $encoded_address;
		?>
			<div class="lp-button-wrap lp-has-2-buttons">
				<a href="<?php echo esc_url( $BookInspectionURL ); ?>" class="lp-button button rep-make-offer-button" target="_blank"><?php echo esc_html('Book Inspection'); ?></a>
				<a href="<?php echo esc_url( $ApplyNowURL ); ?>" class="lp-button button rep-make-offer-button" target="_blank"><?php echo esc_html('Apply Now'); ?></a>
			</div>
		<?php endif; 	
	}
}, 10, 1 );

Result

The code will add ‘Book Inspection’ and ‘Apply Now’ button on the property key details block.
This documentation provides a comprehensive guide for implementing and comprehending the provided code. You can further customize this code to adapt to your specific requirements. This flexibility allows you to tailor the code to various scenarios within your WordPress site.

3. Understanding the Code

  • The code hooks into rep__after_the_property_key_details to display buttons in the property key details block.
  • It uses lp__get_field_value() from the Launchpad core plugin to retrieve property details such as:
    • search_category (to check if the property belongs to ‘residential-lease’ search categories)
    • display_address (to use in the inspection and application URLs)
  • If the search category is ‘residential-lease’ and an address is available:
    • The address is URL-encoded.
    • The “Book Inspection” and “Apply Now” URLs are generated.
    • The buttons are displayed below the property key details block.

4. Save the Changes

After adding the code, click the “Update File” button to save your changes to the “functions.php” file.

5. Testing

To see the changes in action:

  1. Visit a single page of Malcolm Property Listing (‘rep_listing’) post on your site.
  2. If the property is categorized under ‘Residential Lease’ and has an address, you should see the “Book Inspection” and “Apply Now” buttons displayed.

This customization enhances user experience by providing quick access to property inspections and rental applications.