Hi @panconpescao,
With the following code snippet, you should be able to set different IDs per case, as you want:
/**
* PDF Invoices & Packing Slips:
* Show a custom text after the document label for certaing shipping method IDs
*/
add_action( 'wpo_wcpdf_after_document_label', function( $document_type, $order ) {
if ( $document_type == 'invoice' ) {
// Check shipping methods
if ( ! empty( $shipping_methods = $order->get_shipping_methods() ) ) {
$first_method = array_shift( $shipping_methods );
$shipping_method_id = $first_method->get_method_id();
}
if ( in_array( $shipping_method_id, [ 15, 13, 23 ] ) ) {
$custom_text = 'bluexpress';
} elseif ( in_array( $shipping_method_id, [ 14, 11, 12, 24 ] ) ) {
$custom_text = 'starken';
}
if ( $custom_text ) {
echo "<div style='margin: -10pt 0 10pt 0'>$custom_text</div>";
}
}
}, 10, 2 );
Please note that I have used the numbers you have provided, though in my experience, shipping IDs are usually formatted using slug names like flat_rate
, local_pickup
, free_shipping
, etc. Therefore, please double-check that you update the code snippet using the actual shipping IDs.