• Resolved Christopher Mitchell

    (@chrismitchell)


    Hi all,
    As you can see from the link attached. There is a page on this site which has Lettings that the company are letting, they also have sales. This is being imported to PropertyHive through the import from Jupix.

    I have attempted to use this code here:

    add_action( "propertyhive_property_imported_jupix_xml", "correct_property_availability", 10, 2 );
    function correct_property_availability($post_id, $property)
    {
        if ( (string)$property->department == 'Residential Lettings' )
        {
            // It's a lettings property
     
            wp_suspend_cache_invalidation( false );
            wp_defer_term_counting( false );
            wp_defer_comment_counting( false );
             
            if ( (string)$property->availability == '2' ) // To Let
            {
                wp_delete_object_term_relationships( $post_id, 'availability' );
                wp_set_post_terms( $post_id, 1, 'availability' ); // CHANGE 6 TO BE YOUR 'TO LET' TERM ID
            }
            if ( (string)$property->availability == '4' ) // References Pending / Let Agreed
            {
                wp_delete_object_term_relationships( $post_id, 'availability' );
                wp_set_post_terms( $post_id, 7, 'availability' ); // CHANGE 7 TO BE YOUR 'LET AGREED' TERM ID
            }
            if ( (string)$property->availability == '5' ) // Let
            {
                wp_delete_object_term_relationships( $post_id, 'availability' );
                wp_set_post_terms( $post_id, 6, 'availability' ); // CHANGE 8 TO BE YOUR 'LET' TERM ID
            }
             
            wp_suspend_cache_invalidation( true );
            wp_defer_term_counting( true );
            wp_defer_comment_counting( true );
        }
    }

    I have changed the correct fields within the import settings but I can’t seem to get it to display the Let Agreed/To Let and Let options instead of the For Sale/Sale STC/Under Offer. I’m not sure what i’m doing wrong.

    Does anyone have any tips?

    Thanks in advance ??

    Chris

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Property Hive

    (@propertyhive)

    Hi Chris,

    THis code definitely works as used it on many sites so must be something simple. On the line that reads:

    wp_set_post_terms( $post_id, 1, ‘availability’ );

    Are you sure number 1 is the term ID for ‘To Let’. Seems a bit odd this to me.

    Let me know ??
    Steve

    Thread Starter Christopher Mitchell

    (@chrismitchell)

    Hi Steve,
    I’ve updated the code to use the next one in the list instead (number 8)

    add_action( "propertyhive_property_imported_jupix_xml", "correct_property_availability", 10, 2 );
    function correct_property_availability($post_id, $property)
    {
        if ( (string)$property->department == 'Lettings' )
        {
            // It's a lettings property
     
            wp_suspend_cache_invalidation( false );
            wp_defer_term_counting( false );
            wp_defer_comment_counting( false );
             
            if ( (string)$property->availability == '2' ) // To Let
            {
                wp_delete_object_term_relationships( $post_id, 'availability' );
                wp_set_post_terms( $post_id, 8, 'availability' ); // CHANGE 6 TO BE YOUR 'TO LET' TERM ID
            }
            if ( (string)$property->availability == '3' || (string)$property->availability == '4' ) // References Pending / Let Agreed
            {
                wp_delete_object_term_relationships( $post_id, 'availability' );
                wp_set_post_terms( $post_id, 6, 'availability' ); // CHANGE 7 TO BE YOUR 'LET AGREED' TERM ID
            }
            if ( (string)$property->availability == '5' ) // Let
            {
                wp_delete_object_term_relationships( $post_id, 'availability' );
                wp_set_post_terms( $post_id, 7, 'availability' ); // CHANGE 8 TO BE YOUR 'LET' TERM ID
            }
             
            wp_suspend_cache_invalidation( true );
            wp_defer_term_counting( true );
            wp_defer_comment_counting( true );
        }
    }

    But its still not working ?? any ideas why?

    Chris

    Plugin Author Property Hive

    (@propertyhive)

    Has the import ran again (and completed) since adding/amending the code? Another import will need to run for it to take effect.

    If still unsure send through WP access if you have it to [email protected] and I’ll see if I can spot where the issue lies.

    Thanks,
    Steve

    Thread Starter Christopher Mitchell

    (@chrismitchell)

    Thread Starter Christopher Mitchell

    (@chrismitchell)

    Have set you up with a user. It should’ve sent through an email for you to reset your password etc.

    Thread Starter Christopher Mitchell

    (@chrismitchell)

    There is an import already set to call from Jupix. IF you edit it you will see the settings that were set before I looked at this. And then you will be able to see the extra bits for the To Let etc.

    Plugin Author Property Hive

    (@propertyhive)

    Hi Chris,

    You’re just using the wrong term IDs. The term ID’s you should be using are:

    155 – To Let
    157 – Let Agreed
    159 – Let

    So where it says in the code:

    “// CHANGE 6 TO BE YOUR ‘TO LET’ TERM ID”

    You would change ‘6’ to be ‘155’.
    Steve

    • This reply was modified 6 years, 10 months ago by Property Hive.
    Thread Starter Christopher Mitchell

    (@chrismitchell)

    Awesome.. I have changed those over and have re done the import.

    I’m still getting some errors though it seems the “For Sale” one doesn’t want to replace to the “To Let”

    I updated the code to be this:

    add_action( "propertyhive_property_imported_jupix_xml", "correct_property_availability", 10, 2 );
    function correct_property_availability($post_id, $property)
    {
        if ( (string)$property->department == 'Lettings' )
        {
            // It's a lettings property
     
            wp_suspend_cache_invalidation( false );
            wp_defer_term_counting( false );
            wp_defer_comment_counting( false );
             
            if ( (string)$property->availability == '2' || (string)$property->availability == '1' ) // To Let
            {
                wp_delete_object_term_relationships( $post_id, 'availability' );
                wp_set_post_terms( $post_id, 155, 'availability' ); // CHANGE 6 TO BE YOUR 'TO LET' TERM ID
            }
            if ( (string)$property->availability == '3' || (string)$property->availability == '4' ) // References Pending / Let Agreed
            {
                wp_delete_object_term_relationships( $post_id, 'availability' );
                wp_set_post_terms( $post_id, 157, 'availability' ); // CHANGE 7 TO BE YOUR 'LET AGREED' TERM ID
            }
            if ( (string)$property->availability == '5' ) // Let
            {
                wp_delete_object_term_relationships( $post_id, 'availability' );
                wp_set_post_terms( $post_id, 159, 'availability' ); // CHANGE 8 TO BE YOUR 'LET' TERM ID
            }
             
            wp_suspend_cache_invalidation( true );
            wp_defer_term_counting( true );
            wp_defer_comment_counting( true );
        }
    }
    Thread Starter Christopher Mitchell

    (@chrismitchell)

    Actually, those look like they were withdrawn from within the Jupix system. So I will have to work out a way to change over the text to say Withdrawn instead. Or is there a way to hide withdrawn properties from the system?

    Thread Starter Christopher Mitchell

    (@chrismitchell)

    I suppose, if you have some code, that would allow me to add the class of the department to the body class then I could just hide those with the class of availability-for-sale in the main div. But I would need to have code to allow that to happen.

    Plugin Author Property Hive

    (@propertyhive)

    Actually, those look like they were withdrawn from within the Jupix system.

    In that case surely these properties shouldn’t be on the market in Jupix? And therefore wouldn’t get received in the XML.

    I think the solution for this scenario is to take withdrawn properties off the market as to have a withdrawn property on the market doesn’t make sense.

    Steve

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Mapping Lettings and Sales’ is closed to new replies.