How Can We Help?
< Back
You are here:
Print

Hiding Cost of Goods Order Item Meta Fields

Deciding not to use our plugin anymore? Sorry to see you go! But if you want to keep the data around to prevent extra work if you decide to use the plugin again, you can use this article to hide the data that becomes visible in the administrative order view! The images below will find a gallery of images illustrating what is described here.

// hide the _cog_wc_order_item_cost and _cog_wc_order_item_total_cost item meta on the Order Items table
function hide_order_item_cogs_meta( $hidden_fields ) {
		
	$order_item_variables = array(
		'_cog_wc_order_item_cost',
		'_cog_wc_order_item_cost_total',
	);
	
	return array_merge( $hidden_fields, $order_item_variables );
}
add_filter( 'woocommerce_hidden_order_itemmeta', 'hide_order_item_cogs_meta' );

Note:
You can use this snippet for any other unwanted order item meta that might be appearing underneath the order items! Just add or replace the quoted fields within the array to hide those fields.

Below you will find a snippet to hide more cost of goods variables:

// hide the _cog_wc_order_item_cost and _cog_wc_order_item_total_cost item meta on the Order Items table
function hide_order_item_cogs_meta( $hidden_fields ) {
		
	$order_item_variables = array(
		'_wc_cog_item_cost',		// For compatibility with WooCommerce Cost of Goods by SkyVerge
		'_wc_cog_item_total_cost',	// Same as above 
		'_ni_cost_goods',		// For compatibility with Ni Cost of Goods by Anzar Ahmed
		'_cog_wc_order_item_cost',	// Our plugin, Cost of Goods by The Rite Sites
		'_cog_wc_order_item_cost_total',// Same as above
	);
	
	return array_merge( $hidden_fields, $order_item_variables );
}
add_filter( 'woocommerce_hidden_order_itemmeta', 'hide_order_item_cogs_meta' );

Table of Contents