Support » Plugin: WooCommerce PDF Invoices & Packing Slips » Show amount of persons on item level (Woocommerce Bookings)

  • Hello,

    currently the PDF invoice does not show the amount of persons in case of a bookable products on item level (WooCommerce bookings extension).
    The user cannot differ in the invoice whether it was a booking of 1 or 5 persons.

    Is there a setting or code snippet to add this information to the invoice?

    Thanks in advance,

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor kluver


    Hi @deindorfleben,

    Could you try the following code snippet:

    //Add booking person count to item meta
    add_action( 'wpo_wcpdf_after_item_meta', 'wpo_wcpdf_add_person_count', 10, 3 );
    function wpo_wcpdf_add_person_count ( $template_type, $item, $order ) {
    	if ( $template_type == 'invoice' && is_callable( 'WC_Booking_Data_Store::get_booking_ids_from_order_id') ) {
    		$booking_data = new WC_Booking_Data_Store();
    		$booking_ids = $booking_data->get_booking_ids_from_order_id( $order->get_id() );
    		foreach ( $booking_ids as $booking_id ) {
    			$booking = new WC_Booking( $booking_id );
    			$product_id = $booking->get_product_id();
    			if ( $booking->get_order_item_id() == $item['item_id'] ) {
    				$product = wc_get_product( $product_id );
    				$person_types = $product->get_person_types();
    				$person_counts = $booking->get_person_counts();
    				foreach ( $person_counts as $person_id_count => $person_count ) {
    					foreach ( $person_types as $person_id_type => $person_type ) {
    						if ( $person_id_count == $person_id_type ) {
    							echo sprintf("<span class='booking-variation'>%s - %sx<br></span>", $person_type->get_name(), $person_count );

    This code snippet should be added to the functions.php of your child theme or via a plugin like Code Snippets. If you haven’t worked with code snippets or functions.php before please read this: How to use filters

    Thread Starter deindorfleben


    Hi kluver,

    thanks for your fast feedback. I implemented the code via snipped but the amount of persons won’t be displayed under the product title.

    Here you can see an example:
    (I marked the vendor shop and product title as unrecognizable)

    Our problem is that a customer can book an event e.g. for 3 persons but he can’t see it on the invoice form. In my example I would expect that the invoice shows the following information:

    Booking product title
    vendor shop: XYZ
    Persons: 3

    Thanks for your support!

    Plugin Contributor kluver


    Hi @deindorfleben

    The above snippet should do exactly that for each booking in the order:


    It looks like it isn’t being called at all. Also looking at your screenshot your are not using the default Simple template that comes standard with our plugin. Could it be possible you are using a custom template that misses the wpo_wcpdf_after_item_meta action hook?

    • This reply was modified 1 year, 8 months ago by kluver.
    Thread Starter deindorfleben


    Hi kluver,

    here you can see that we use the default theme “simple”:–MOwTyuhX26pWsg

    We use the multivendor plugin WCFM Marketplace. They have a special functionality where it is possible that vendors send invoices directly to customers:

    For this functionality WCFM uses your plugin in the background. Do you think that they did a special coding so the above named hook will not be called?

    Thanks for your feedback,

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Show amount of persons on item level (Woocommerce Bookings)’ is closed to new replies.