Im trying to clean up some default database entries that WooCommerce adds to the postmeta table. The two primary entries that I do not need are _customers_ip_address
& _customer_user_agent
.
I found _customers_ip_address
in create_order()
function in file class-wc-checkout.php
do_action( 'woocommerce_checkout_create_order', $order, $data );
seems to be what is setting the data. Although I also found it was being set in wc-core-functions.php
@ function wc_create_order()
Im not 100% sure how to edit this. Im thinking a simple do_filter
, but unset
seems to not work inside the do_filter
, but obviously I am doing it all wrong. Im not that familiar with do_filter
but seems like something simple like the code below.
function cleanup_woocommerce_checkout_create_order($order, $data) {
unset($order->set_customer_ip_address());
return $order;
}
add_filter('woocommerce_checkout_create_order', 'cleanup_woocommerce_checkout_create_order');
The code above gives a WordPress Error of :
Fatal error: Can't use method return value in write context