Code snippet hook to customize booking payment complete page

Hello,
I’m trying to create a code snippet that will be executed when a user completed a booking payment : I need to add some conditions depending of the payment gateway used for the order.

I tried something like that (for Paypal) :

add_action( 'hp_booking_payment_completed', 'update_booking_status', 10, 2 );
function update_booking_status( $booking_id, $payment_gateway ) {
    if ( ! $booking_id ) {
        return;
    }

    $booking = hp_booking_get( $booking_id );
    if ( $payment_gateway === 'ppcp-gateway' && $booking->get_status() === 'processing' ) {
        $booking->set_status( 'completed' );
        $booking->save();
		wp_redirect( hp_booking_get_permalink( $booking_id ) );
		exit;
    }
}

But, it looks that the hook itself isn’t right.

Thanks for your help!

1 Like

If you mean adding something to the order when the booking payment was successful, please try to use hooks woocommerce_order_status_changed or woocommerce_thankyou. The first one is called when the order status is changed, and then it is possible to check with additional conditions if the order was paid. The second one is called when checkout payment was successful, but it also requires additional conditions to check it. If you are not familiar with the code customization, then please consider hiring someone for custom work https://fvrr.co/32e7LvY

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.