Hi,
I’m trying to modify the label of a field in the new listing form based on the category selected. Specifically, I want to change the “Location” label to “Pick Up Location” for listings filed under “Pick-ups” category.
I’ve tried using filters, and I’m able to change the label with the following code:
add_filter(
'hivepress/v1/models/listing/attributes',
function( $attributes ) {
if ( isset( $attributes['location'] ) ) {
$attributes['location']['edit_field']['label'] = 'PICK UP LOCATION';
}
return $attributes;
},
1000
);
However, I’m having trouble figuring out how to get the selected category in order to conditionally change the label. I was able to achieve this using JavaScript, but I would prefer to keep the function on the backend if possible.
Could someone please provide a sample code snippet or guidance on how to get the selected category in this case?
Thank you in advance for any help or suggestions!