• Resolved mike8040

    (@mike8040)


    Hello,

    I would like to deactivate this feature of logging the IP of customers in the orders. I found a php snippet on the net but this doesn’t work. Anyone knows a solution? Is there an option that I did not find bc I wonder why one needs to hardcode it?

    /** Stop saving customer IP */
    add_filter( ‚update_post_metadata‘, ‚wc_customer_ip_delete‘, 10, 3 );

    function wc_customer_ip_delete( $null, $id, $key ) {
    if ( ‚_customer_ip_address‘ === $key )
    return FALSE;

    return $null;
    }

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @mike8040

    This is a fairly complex development topic.

    However, looks like you are not enclosing your strings properly, instead of using commas, you’ll need to use single quotes.

    It should be changed to something like this:

    /** Stop saving customer IP */
    add_filter( ‘update_post_metadata‘, ‘wc_customer_ip_delete‘, 10, 3 );

    function wc_customer_ip_delete( $null, $id, $key ) {
    if ( ‘_customer_ip_address‘ === $key )
    return FALSE;

    return $null;
    }

    That way, the strings are enclosed properly. I didn’t test it, but even double-checking your code, if you’re still having issues with that I’d recommend
    the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack.

    We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    I hope that helps! Thank you!

    Thread Starter mike8040

    (@mike8040)

    Well it is not my code as I said I found it on Google searching this topic. So credit goes to that dev who was willing to share it. The problem with the commas maybe be due to copying it over from a text editor. Have to check if it was already in place in the source code.
    Anyway thanks. I have a look. Still in my opinion it’s not a an exotic request I really wonder why this is not an option in Woo. At least in the EU, privacy is a big topic which one needs to comply with. So it is not nessary to save customer data if one don’t need em and this should be a customizable option for the shop owner and not just a task for a dev…

    If anyone out there has a solution, please post it here.

    • This reply was modified 2 years, 2 months ago by mike8040.

    Hello there,

    It is highly recommended to use a plugin like Code Snippets to add custom PHP code into your site without directly accessing the functions.php file. Here is an article that explains how to use the Code Snippets plugin:

    https://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/

    And yes, we understand your opinion, WooCommerce has a lot of plugins to comply with privacy requirements depending on the user’s needs.

    Let us know if there are any questions.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to deactivate IP saving for orders?’ is closed to new replies.