Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save propertyhive/e93abc6a118af9c80afbbfa971e2123d to your computer and use it in GitHub Desktop.

Select an option

Save propertyhive/e93abc6a118af9c80afbbfa971e2123d to your computer and use it in GitHub Desktop.
<?php
add_filter( 'ph_zoopla_rtdf_send_request_data', 'td_fix_zoopla_poa_per_channel', 20, 2 );
function td_fix_zoopla_poa_per_channel( $request_data, $post_id ) {
$department = get_post_meta( $post_id, '_department', true );
if (
$department !== 'commercial' &&
function_exists( 'ph_get_custom_department_based_on' ) &&
ph_get_custom_department_based_on( $department ) !== 'commercial'
) {
return $request_data;
}
if ( empty( $request_data['category'] ) ) {
return $request_data;
}
$price_from = get_post_meta( $post_id, '_price_from', true );
$price_to = get_post_meta( $post_id, '_price_to', true );
$rent_from = get_post_meta( $post_id, '_rent_from', true );
$rent_to = get_post_meta( $post_id, '_rent_to', true );
// Default unless this specific channel should be POA.
//$request_data['property']['price_information']['price_qualifier'] = 0; // don't think we need this line
// Channel 1 = sales
if (
substr($request_data['listing_reference'], -2) !== '-l' &&
(float) $price_from === 1.0 &&
(float) $price_to === 1.0
) {
$request_data['pricing']['price_qualifier'] = 'non_quoting';
unset($request_data['pricing']['price']);
}
// Channel 2 = lettings/rentals
if (
substr($request_data['listing_reference'], -2) === '-l' &&
(float) $rent_from === 1.0 &&
(float) $rent_to === 1.0
) {
$request_data['pricing']['price_qualifier'] = 'non_quoting';
unset($request_data['pricing']['price']);
}
return $request_data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment