Search code examples
phpwordpresswoocommerceordersstock

Change the "→" character on backend Orders stock notes in Woocommerce


In woocommerce order stock notes, before and after order qty is separated by → symbol like this:

Product xyz 25→22

How can i Change the → symbol to another symbol?

thanks a lot.


Solution

  • This can be done with the following code that will search for " → " character in Order notes content before saving the data.

    This order note is added using the wc_trigger_stock_change_notifications() function that uses '→' to add the " → " character.

    The code:

    add_filter( 'woocommerce_new_order_note_data', 'filter_new_order_note_data', 10, 3 );
    function filter_new_order_note_data( $data, $args ) {
        $replacement = ' to ';
    
        $data['comment_content'] = str_replace('→', $replacement, $data['comment_content']);
    
        return $data;
    }
    

    Code goes in function.php file of your active child theme (or active theme). Tested and work.

    The order note before (without this code):

    enter image description here

    Then changing the order status to pending and back to processing (with the code):

    enter image description here enter image description here