Last active
July 31, 2022 07:31
-
-
Save hamidrezayazdani/c3c79073082f5d5a85785446c4a1b48a to your computer and use it in GitHub Desktop.
Add customer billing phone to review list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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