I would like to set the value of a listing’s ‘Price’ based on the value inputted by a user for ‘Displayed Hourly Rate’ (displayed_hourly_rate).
I’ve tried the following code with no success, based on this post: Calculated Attributes
add_action(
'hivepress/v1/models/listing/update',
function( $listing_id, $listing ) {
$value = $listing->get_displayed_hourly_rate() * 1.1;
if ( $listing->get_price() !== $value ) {
$listing->set_price( $value )->save_price();
}
},
1000,
2
);