How to Alter/Hide Meta Values in Print Invoice, Packing Slip, Delivery Note & Label Plugin for WooCommerce?

There may be instances where some unwanted meta values are printed on your shipping documents. And you would want to hide them or replace them with custom ones. These meta values are usually generated from third-party plugins. They are printed on the product table of your shipping documents.

With the help of following code snippets, you can alter or hide the meta values in your invoice, packing slip and delivery note. These code snippets must be added to the functions.php file of your website theme.

Replacing meta keys with custom keys

Following code snippet replaces meta values ‘_wwp_wholesale_priced‘ & ‘_wwp_wholesale_role to Wholesale Priced’ & ‘Wholesale Role respectively, in the product table of invoice.

//code snippet to replace meta key with value
add_filter(‘wf_pklist_modify_meta_data’, ‘wf_pklist_change_meta_data_label’, 1);

function wf_pklist_change_meta_data_label($meta_data)
{
//replace the array key value with your custom key value.
$label_array = array(
‘_wwp_wholesale_priced’ => ‘Wholesale Priced’,
‘_wwp_wholesale_role’ => ‘Wholesale Role’
);
$new_meta_data = array();
foreach( $meta_data as $id => $value) {
if(array_key_exists($id, $label_array)){
$new_meta_data[$label_array[$id]] = $value;
} else {
$new_meta_data[$id] = $value;
}
}

return $new_meta_data;
}

Hiding meta values

Following code snippet hides all meta values in the product table of your shipping document.

//code snippet to hide all meta keys
add_filter(‘wf_pklist_modify_meta_data’, ‘wf_pklist_change_meta_data_label’, 1);

function wf_pklist_change_meta_data_label($meta_data)
{
//replace the array key value with your custom key value.
$label_array = array();
return $label_array;
}

The same code snippet can be accessed from Github:

To know more about the product, check out Print Invoice, Packing Slip, Delivery Note & Label Plugin for WooCommerce.

Or check out the documentation section for more related articles.

Leave a Reply

Your email address will not be published. Required fields are marked *