Created
April 2, 2026 09:43
-
-
Save plugin-republic/a444ae41ebaf0812a3952ce17fd9a684 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* This code was provided by WebToffee support on 10/21/25 | |
| * Makes Plugin Republic's Product Add-ons plugin available to use in the packing list PDF | |
| */ | |
| add_filter( 'wf_pklist_add_package_product_meta', 'wf_pklist_add_additional_fields', 10, 5 ); | |
| function wf_pklist_add_additional_fields( $additional_product_meta, $template_type, $_product, $order_item, $order ) { | |
| if ( 'packinglist' !== $template_type ) { | |
| return $additional_product_meta; | |
| } | |
| $order_item_id = isset( $order_item['order_item_id'] ) ? $order_item['order_item_id'] : 0; | |
| if ( ! $order_item_id ) { | |
| return $additional_product_meta; | |
| } | |
| $meta = wc_get_order_item_meta( $order_item_id, 'product_extras', true ); | |
| if ( empty( $meta ) || ! is_array( $meta ) ) { | |
| return $additional_product_meta; | |
| } | |
| foreach ( $meta as $meta_group ) { | |
| foreach ( $meta_group as $meta_values ) { | |
| foreach ( $meta_values as $meta_data ) { | |
| if ( ! empty( $meta_data['label'] ) && isset( $meta_data['value'] ) ) { | |
| $additional_product_meta .= sprintf( | |
| '<small><br>%s: %s</small>', | |
| esc_html( $meta_data['label'] ), | |
| esc_html( $meta_data['value'] ) | |
| ); | |
| } | |
| } | |
| } | |
| } | |
| return $additional_product_meta; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment