In some cases you need to exclude the order meta from split, duplicate orders.
Add the code snippets below to your site via:
- A child theme‘s
functions.php
file, or - A custom functions plugin, such as Code Snippets.
Do not add custom code directly to your parent theme’s functions.php
file; it will be overwritten/wiped entirely when you update the theme.
Split order
Split by default:
add_filter('yoaoa_split_default_order_meta_data', 'your_hook_here', 10, 2);
Split by category:
add_filter('yoaoa_split_category_order_meta_data', 'your_hook_here', 10, 2);
Split by stock status:
add_filter('yoaoa_split_stock_status_order_meta_data', 'your_hook_here', 10, 2);
Split by tag:
add_filter('yoaoa_split_tag_order_meta_data', 'your_hook_here', 10, 2);
Split by Vendor: (WCFM Marketplace plugin is required)
add_filter('yoaoa_split_vendor_order_meta_data', 'your_hook_here', 10, 2);
Duplicate order
add_filter('yoaoa_duplicate_order_meta_data', 'your_hook_here', 10, 2);
For example:
In case you want the split (new) orders to not copy the order meta from the original order, which does not contain the text ‘sample’ (meta_key). Go for:
add_filter('yoaoa_split_default_order_meta_data', 'exclude_sample_meta_keys', 10, 2);
function exclude_sample_meta_keys($meta, $order) {
$filtered_meta_data = array();
foreach ($meta_data as $meta) {
if (strpos($meta->key, 'sample') === false) {
$filtered_meta_data[] = $meta;
}
}
return $filtered_meta_data;
}