Forums
Forums / Plugin: WooCommerce / Delete Order metadata
(@ahnabil)
9 years, 10 months ago
Hello, i’m trying to delete specific metadata by key from all orders
i’ve tried
add_action( 'wc_delete_order_item_meta', 'please_delete', 10, 2 ); function please_delete($item_id, $meta_key){ global $woocommerce; foreach ( $items['order_item_id'] as $item_id ) { wc_delete_order_item_meta( $item_id, 'Customs in USD', true ); } }
i’m able to delete it from the DB by running this query DELETE FROM wp_woocommerce_order_itemmeta WHERE meta_key = ‘Customs in USD’
from functions.php nothing happens, please help
https://wordpress.org/plugins/woocommerce/
(@icaleb)
Automattic Happiness Engineer
Where are you finding the wc_delete_order_item_meta hook? Your code is probably never running.
wc_delete_order_item_meta
You need to hook into a hook that will for sure run, and then you need to cycle through all orders.
The topic ‘Delete Order metadata’ is closed to new replies.