propertyhive / WP-Property-Hive

The complete estate agency software plugin for WordPress
Other
26 stars 26 forks source link

Property Import - Availability update when "Off the market" #110

Closed brynnroom57 closed 4 years ago

brynnroom57 commented 4 years ago

I'm having a problem with updating the Availability of a property when the imported status is "Off the market" using a jet/reapit feed.

For instance, I have a property set to "For sale" in Reapit and "For sale/On the market" in propertyhive. When updated to "Sold STC - Unavailable" in Reapit, it changes the property hive status to "For Sale / Off the market" Instead of "Sold STC - Off the market" presumably as it assumes that sold just translates to off the market, so the availability doesn't need to be updated. This is a problem as I'm displaying Sold properties on the site.

Note - this is not a problem when switching from "For sale" to "Sold STC - Available" in Reapit, as these import as "Sold STC - On the Market" as both status and availability are updated with it being still an "on the market" property.

Any help/fixes much appreciated.

propertyhive commented 4 years ago

@brynnroom57 Thanks for getting in touch.

Firstly, I think it's important for us to be on the same page regarding terminology: Sold STC vs Sold as you mention both in your question but both should be treated differently. I'm assuming you're referring to Sold STC but do let me know if not.

Sold STC are properties that are normally left on the market and are kept available until they exchange. You're saying in your question that you're making Sold STC properties unavailable in ReapIT? If so, may I ask the reason for this and why they're being made unavailable at this stage?

By default we only import available properties from ReapIT, however if you do wish to mark Sold STC properties as unavailable I might be able to construct some code to allow you to still import them regardless of their available status in ReapIT.

Do let me know your thoughts, Steve

brynnroom57 commented 4 years ago

Hi Steve,

Thanks for the reply. I'm referring to Sold STC.

What I'm after is being able to import/update properties regardless of their on/off-market status, which is what I think you suggest in your last paragraph.

I might be able to construct some code to allow you to still import them regardless of their available status in ReapIT.

If you can help me out here that would be greatly appreciated.

Cheers, Brynn

propertyhive commented 4 years ago

Hi Brynn,

You can add the following should you wish unavailable properties to be returned from Reapit too:

add_filter( 'propertyhive_jet_sales_criteria', 'jet_include_archived' );
add_filter( 'propertyhive_jet_lettings_criteria', 'jet_include_archived' );
function jet_include_archived( $criteria )
{
    $criteria['Unavailable'] = true;
    return $criteria;
}

Once the above has been added, another import will need to run for it to take effect. Do let me know how you get on.

Steve

brynnroom57 commented 4 years ago

Hi Steve,

Thanks for that but no luck! Added to child theme functions.php and ran an import and still only returning available properties.

I've got the problem for instance, that a Sold STC property won't get a status update to Sold on the website when changed in Reapit. I need all properties to have their availability (e.g for sale, under offer, sold stc, sold) update, regardless of their (on/off market - available/unavailable) status.

Sorry about the confusing wording!

Cheers

brynnroom57 commented 4 years ago

I do you an injustice, that filter does return "Sold Stc - unavailable" properties and sets them to on the market, which is ideal.

Just trying to test going from "Sold Stc - Unavailable" to "Sold" now. Am I right in thinking that in this case, the import won't find the property again and so will default it to off the market? I'm hoping this is the case as I can then just change the marketing flag frontend with jquery.

Thanks for the help.

Brynn

propertyhive commented 4 years ago

Hi Brynn,

Am I right in thinking that in this case, the import won't find the property again and so will default it to off the market?

I'll be honest and say this is uncharted territory for me. I know you can pass the availabilities you wish to return. I've included an example of this below using the code provided previously:

add_filter( 'propertyhive_jet_sales_criteria', 'jet_include_archived' );
add_filter( 'propertyhive_jet_lettings_criteria', 'jet_include_archived' );
function jet_include_archived( $criteria )
{
    $criteria['Unavailable'] = true;
    $criteria['PropertyStatus'] = array('for sale', 'under offer', 'to let', 'let', 'sold', 'exchanged', 'completed', 'recently sold', 'reserved'); // remove the ones you don't wish to import
    return $criteria;
}

Do let me know how you get on,

Steve

brynnroom57 commented 4 years ago

Hi Steve,

That's exactly what I was after - Thanks! I now have all the statuses I want coming across and updating.

I'll do my best to explain what the problem was and how it's working now if you're interested.

Before I was having to include "Off the market" in search results to show the "Sold STC" properties. This was giving me headaches filtering, as a property that was set to "For sale" and then withdrawn, kept the "For sale" status, but added "Off the market", which in this configuration, made no difference on the frontend.

All properties coming across now without "Withdrawn" Status (For sale, Sold STC, Sold etc) are set to "On the market" which works fine for me as the client wants to show all Sold STC in search results. Withdrawn statuses still get set to "For sale - Off the market" but I now don't have to include off the markets in search so I don't have these showing up. I then just have one function to remove "Sold" from search results and everything works how I wanted.

Thanks again for your help!

will-yellowpeach commented 12 months ago

Just piggy-backing off the back of this one... Is 'PropertyStatus' still valid with Reapit? We always used to use something similar with: $criteria['PropertyStatus'] = array('for sale', 'under offer', 'exchanged', 'to let');

...but it looks like we may now need to use 'SaleStatus' and 'LettingStatus' independently. Is that right?

Martin-PH commented 11 months ago

Hi will-yellowpeach,

You are correct, please have a look at the following gist which has all the requested fields: https://gist.github.com/propertyhive/e12046cd26304817494017047713f265 Sometimes the fields don't match 100%, like VTour2 - sometimes it's there, sometimes it's not. It's different per client. You can use the following testing tool to make a demo request: https://tracker.reapit.net/demo/_support/web-service/ Reapit has depreciated their their old SOAP API and have now migrated to their Reapit Foundations API.

the 'criteria' we pass through are: // Sales $criteria = array( 'SearchType' => 'sales', 'PropertyField' => $property_fields, 'Offset' => 0, 'Limit' => 50, ); and // Lettings $criteria = array( 'SearchType' => 'lettings', 'PropertyField' => $property_fields, 'Offset' => 0, 'Limit' => 50, ); and // Commercial Sales $criteria = array( 'SearchType' => 'sales', 'PropertyField' => $property_fields, 'Offset' => 0, 'Limit' => 50, );