Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hamidrezayazdani/c3c79073082f5d5a85785446c4a1b48a to your computer and use it in GitHub Desktop.
Save hamidrezayazdani/c3c79073082f5d5a85785446c4a1b48a to your computer and use it in GitHub Desktop.
Add customer billing phone to review list
<?php
/**
* @param $columns
*
* @return mixed
*/
function ywp_add_billing_phone_column_in_review_list( $columns ): mixed {
$columns['billing_phone'] = __( 'Billing Phone' );
return $columns;
}
add_filter( 'woocommerce_product_reviews_table_columns', 'ywp_add_billing_phone_column_in_review_list' );
/**
* @param $output
* @param $review
*
* @return void
*/
function ywp_show_billing_phone_in_review_list( $output, $review ) {
$user_id = ! empty( $review->user_id ) ? $review->user_id : 0;
if ( ! empty( $user_id ) ) {
$billing_phone = get_user_meta( $author, 'billing_phone', true );
if ( $billing_phone ) {
echo $billing_phone;
} else {
echo '-';
}
}
}
add_filter( 'woocommerce_product_reviews_table_column_billing_phone_content', 'ywp_show_billing_phone_in_review_list', 10, 2 );
// The code goes to your active theme(or child theme) functions.php file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment