I’m making an attempt to show a line merchandise meta (designid) on invoices. To take action I want to drag line merchandise meta from one plugin to a different utilizing a customized perform.
The customized plugin that shows the information on WooCommerce order particulars web page is as follows:
public static perform init() {
add_action( 'woocommerce_before_order_itemmeta', array( __CLASS__, 'add_order_item_meta' ), 10, 3 );
}
public static perform add_order_item_meta( $item_id, $merchandise, $order ) {
$jumbo_data = $item->get_meta( 'jumbo_data' );
if ( ! $jumbo_data ) {
return;
}
$webservice = new jumbo_Webservice();
strive {
$designid = $webservice->get_designid( $jumbo_data['design'] );
} catch ( Exception $e ) {
$designid = 'not discovered';
}
?>
<p><?php esc_html_e( 'Design ID' ); ?>: <?php esc_html_e( $designid ); ?></p>
I must show the design ID ($designid) on invoices.
The bill plugin developer says I want to make use of the next perform to show customized knowledge on invoices:
// Add Design ID
perform mypc_add_invoice_fields( $fields, $order ) {
$jumbo_designid = '-----';
if ( $jumbo_designid ) {
$fields['design'] = array(
'label' => __( 'Design ID', 'mypc' ),
'worth' => $jumbo_designid ,
);
}
return $fields;
}
add_filter( 'wcdn_order_info_fields', 'mypc_add_invoice_fields', 10, 2 );
How can I pull the designid right into a customized perform?