WooDiscuz 사용중에 우커머스 K 상품문의 로 데이터를 마이그레이션 하려면 다음 코드를 스니펫 또는 테마 functions.php 에 삽입후 1회 실행 되어야 합니다.
다음 코드는 WooDiscuz 에서 작성한 글의 타입을 우커머스 K 상품문의 타입으로 변경하는 코드이며,
우커머스 설정 > 우커머스 K 탭에 접속시에만 동작 합니다.
‘DB 내용을 업데이트 하기 때문에 반드시 DB 를 백업후 진행하시기 바랍니다.’
add_action('admin_head', function(){
global $wpdb;
if ( current_user_can( 'manage_options' ) && ( ! wp_doing_ajax() ) ) {
$screen = get_current_screen();
if( 'woocommerce_page_wc-settings' == $screen->base && isset($_GET['tab']) && $_GET['tab'] == 'danbi-woowow' ){
$tablename = $wpdb->prefix . 'comments';
$update_type = 'wook_comment';
$where_type = 'woodiscuz';
$update_row = $wpdb->query(
$wpdb->prepare( "UPDATE $tablename SET comment_type = %s WHERE comment_type = %s", $update_type, $where_type )
);
if( $update_row > 0 ){
$class = 'notice notice-success';
$message = $update_row . '건이 우커머스k 상품 문의로 변경되었습니다.';
printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), esc_html( $message ) );
}
}
}
});
Code language: PHP (php)우커머스 K 설정화면에 접속하시면 아래와 같이 변경된 건수가 1회만 확인됩니다.