Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
Last active May 3, 2023 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webtoffee-git/ec1cde83a857f3be088dbcfeae87a5b5 to your computer and use it in GitHub Desktop.
Save webtoffee-git/ec1cde83a857f3be088dbcfeae87a5b5 to your computer and use it in GitHub Desktop.
Remove unnecessary product meta data from product table using WooCommerce PDF Invoices, Packing Slips, Delivery Notes and Shipping Labels by WebToffee
add_filter('wf_pklist_modify_meta_data', 'webtoffee_modify_meta_data', 10, 2);
function webtoffee_modify_meta_data($meta) {
// Below are the keys for bundled products and composite products - Change the array keys according to the needs
$keys = array(
'_bundle_group_mode',
'_bundle_cart_key',
'_bundle_weight',
'_bundled_by',
'_bundled_item_id',
'_bundled_item_priced_individually',
'_bundled_item_needs_shipping',
'_per_product_pricing',
'_per_product_shipping',
'_composite_cart_key',
'_bundled_shipping',
'_bundled_weight',
'_wc_cog_item_cost',
'_wc_cog_item_total_cost',
'_composite_parent',
'_composite_item',
'_composite_weight',
'_composite_item_needs_shipping',
'_component_priced_individually',
'_component_subtotal_hidden',
'_reduced_stock'
);
foreach ($meta as $id => $value) {
if (in_array($id, $keys) && $id !== 0) {
if (isset($meta[$id])) {
unset($meta[$id]);
}
} else {
$meta[$id] = $value . '<br />';
}
}
return $meta;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment