Hi,
I would like to automatically fill the value of an attribute (in the booking section) after a payment is complete.
Could you please give me some tricks or reflection to succeed ?
Thanks
Hi,
I would like to automatically fill the value of an attribute (in the booking section) after a payment is complete.
Could you please give me some tricks or reflection to succeed ?
Thanks
Hi,
You can use this PHP hook 'hivepress/v1/models/listing/update_status'
, and in this snippet, specify bookings -> set_attribute_name -> save_attribute_name
.
I hope this is helpful to you.
Thank you Andrii
I check it and keep you updated
Hi Andrii,
I’m working with Christophe on this request. We have this use case :
Maybe you have some sample hook that you could share ?
I’m trying with something like this in functions.php :
// Update attribute when reservation is created
function update_booking_attribute($booking_id) {
// Get booking ID
$booking = hivepress()->bookings->get_booking($booking_id);
// Check if booking exists
if ($booking) {
// Update attribute
$booking->set_meta('link', 'https://www.test.fr');
$booking->save();
}
}
add_action('hp_booking_created', 'update_booking_attribute');
This code is not a good way to do it, it seems.
Thanks in advance,
Baptiste
If I understand correctly, you have created a booking attribute with the field name link. Please try this PHP code snippet if you want to set some value for this attribute when the booking is confirmed.
add_action(
'hivepress/v1/models/booking/update_status',
function($booking_id, $new_status, $old_status, $booking){
if('publish' === $new_status){
$booking->set_link('value')->save_link();
}
},
1000,
4
);
Thank you so much yevhen !
It works perfectly
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.