• 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,
    Florian

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

    (@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

    (@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:
    https://drive.google.com/open?id=1zFhoOsKgmm0WMTHwdVTUUL70BjXt0gE9
    (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

    (@kluver)

    Hi @deindorfleben

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

    Schermafbeelding-2020-05-01-om-11-26-39

    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 4 years, 10 months ago by kluver.
    Thread Starter deindorfleben

    (@deindorfleben)

    Hi kluver,

    here you can see that we use the default theme “simple”:
    https://drive.google.com/open?id=1iXQkMEEmCdBS__2A–MOwTyuhX26pWsg

    We use the multivendor plugin WCFM Marketplace. They have a special functionality where it is possible that vendors send invoices directly to customers:
    https://wclovers.com/knowledgebase/wcfm-store-invoice/

    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,
    Florian

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.