Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Woocommerce Bookings - show booking duration WordPress

We are using Woocommerce Bookings and wish to echo in the PHP file the booking duration field and also the booking duration unit. (see screenshot)

ie. 60 minutes

We want to insert this on multiple pages including the detail page and the summary pages in WooCommerce so the user can see how long each booking will last.

Can the PHP code please be provided to us so we can implement.

Thank you.

Answers (2)

2015-08-04

Arnav Joy answers:

Hi ,

can you show all the places where you want it??


vi_au comments:

I need it in content-product.php and and single-product/title.php

2015-08-05

IndiTheme - answers:

Add this function in your theme functions.
/**
* A function to reorder the default display of fields on the WooCommerce Bookings form
* Put this function in your theme's functions.php file
*/
function custom_order_booking_fields ( $fields ) {

$reorder = array();
$reorder[] = $fields['wc_bookings_field_duration']; // Duration
return $reorder;
}
add_filter( 'booking_form_fields', 'custom_order_booking_fields');


vi_au comments:

And then what? I echo reorder to have this display to the visitor?


IndiTheme - comments:

try this ... $booking_form->output();


vi_au comments:

Nope - nothing shows. I just need to show on screen the booking duration field and unit.


IndiTheme - comments:

Try this bro....

global $product;
$product->get_duration(); // Display duration.
$product->get_duration_unit(); // Display duration unit.