Got it on my own. I also use the webtoffee plugin “packing list, shipping labels, invoice,…” and I just added a custom field using the functions.php .
NOT THE ADVANCED META KEYS ! They don’t work, when you just need the original order id!
add_filter('wf_pklist_alter_find_replace','wf_pklist_add_values_for_custom_placeholders',10,5);
function wf_pklist_add_values_for_custom_placeholders($find_replace,$template_type,$order,$box_packing,$order_package)
{
if($template_type=='invoice')
{
$wc_version=(WC()->version<'2.7.0') ? 0 : 1; $order_id = ($wc_version==0 ? $order->id : $order->get_id());
$find_replace['[wfte_custommeta1]']=get_post_meta($order_id,'_post_title',true);
}
return $find_replace;
}
This is the original code where you could create as many meta_keys as you want by simply duplicating the line “$find_replace….” . But in my case I needed this:
add_filter('wf_pklist_alter_find_replace','wf_pklist_add_values_for_custom_placeholders',10,5);
function wf_pklist_add_values_for_custom_placeholders($find_replace,$template_type,$order,$box_packing,$order_package)
{
if($template_type=='invoice')
{
$wc_version=(WC()->version<'2.7.0') ? 0 : 1; $order_id = ($wc_version==0 ? $order->id : $order->get_id());
$find_replace['[wfte_custommeta_b]']=$order_id;
}
return $find_replace;
}
That’s it. Just this line:
$find_replace[‘[wfte_custommeta_b]’]=$order_id;