Function to get variable content and strip variable to only return numbers

Viewed 41

Attempting to extract the shipping tracking number from the content of a Woocommerce note to customer to eventually pass to a custom field as a value

Original function

    function get_value( $comment, $parameters ) {
    return $comment->content;
}

Modified function (not working)

function get_value( $comment, $parameters ) {
    $tracking_note = $comment->content;
    $new_output = preg_replace( '/[^0-9]/', '', $tracking_note );
    return $new_output->content;
    
}
1 Answers
Related