워드프레스에서 결제를 위해선 우커머스 플러그인을 사용하는게 가장 쉬운 방법인데, 외국애들이 쓰는거라 이름,성 순서로 되어있다. 게다가 입력정보도 한국 정서와 많이 다르고.
나같은 경우는 결제만 되면 되고 다른 정보는 필요없기에 다 없애려고 하는데, 한국 PG사 결제정책상 이메일이랑 폰번호는 꼭 필요하다고 한다. 그래서 그것만 남겨두기 위해서 자식테마의 functions.php 파일을 좀 수정을 했다.
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 | //성이름으로 순서 변경 add_filter( 'woocommerce_checkout_fields' , 'hj_reorder_woocommerce_fields' ); function hj_reorder_woocommerce_fields( $fields ){ $fields2 [ 'billing' ][ 'billing_last_name' ] = $fields [ 'billing' ][ 'billing_last_name' ]; $fields2 [ 'billing' ][ 'billing_first_name' ] = $fields [ 'billing' ][ 'billing_first_name' ]; $fields2 [ 'billing' ][ 'billing_phone' ] = $fields [ 'billing' ][ 'billing_phone' ]; $fields2 [ 'billing' ][ 'billing_email' ] = $fields [ 'billing' ][ 'billing_email' ]; $fields2 [ 'billing' ][ 'billing_company' ] = $fields [ 'billing' ][ 'billing_company' ]; $fields2 [ 'billing' ][ 'billing_address_1' ] = $fields [ 'billing' ][ 'billing_address_1' ]; $fields2 [ 'billing' ][ 'billing_address_2' ] = $fields [ 'billing' ][ 'billing_address_2' ]; $fields2 [ 'billing' ][ 'billing_city' ] = $fields [ 'billing' ][ 'billing_city' ]; $fields2 [ 'billing' ][ 'billing_postcode' ] = $fields [ 'billing' ][ 'billing_postcode' ]; $fields2 [ 'billing' ][ 'billing_country' ] = $fields [ 'billing' ][ 'billing_country' ]; $fields2 [ 'order' ] = $fields [ 'order' ]; return $fields2 ; } |
자식테마 functions.php 에 이 코드를 추가하면 이름과 성 순서가 변경된다.
그리고 $fields2 를 받아서 안보이게 하고 싶은 것들은 이렇게.
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | // 결제시 폰번호말고 나머지것들 삭제 add_filter( 'woocommerce_checkout_fields' , 'woo_remove_billing_checkout_fields1' ); function woo_remove_billing_checkout_fields1( $fields2 ) { global $woocommerce ; $products = $woocommerce ->cart->get_cart(); if (woo_cart_has_virtual_product()) { unset( $fields2 [ 'billing' ][ 'billing_company' ]); unset( $fields2 [ 'billing' ][ 'billing_address_1' ]); unset( $fields2 [ 'billing' ][ 'billing_address_2' ]); unset( $fields2 [ 'billing' ][ 'billing_city' ]); unset( $fields2 [ 'billing' ][ 'billing_postcode' ]); unset( $fields2 [ 'billing' ][ 'billing_country' ]); unset( $fields2 [ 'billing' ][ 'billing_state' ]); // unset($fields2['billing']['billing_phone']); unset( $fields2 [ 'billing' ][ 'billing_address_2' ]); unset( $fields2 [ 'billing' ][ 'billing_postcode' ]); unset( $fields2 [ 'billing' ][ 'billing_company' ]); unset( $fields2 [ 'billing' ][ 'billing_city' ]); } return $fields2 ; }; |
사실 우커머스 플러그인을 직접 수정하면 훨씬 쉽고 간편하지만 그럼 업데이트 될때마다 수정해야 하는 번거로움이 생긴다.
그렇다고 결제 문제니까 보안상 업뎃안할수도 없고.
그건 그렇고 자식테마 functions.php 에 php테그를 닫으니 작동이 안되는 함수들이 생긴다. 왜그러지.ㅋ
아는게 별로 없으니까 사소한 문제 하나 발생해도 시간이 꽤 걸린다.ㅠㅠ
Edit Account 페이지에서 last_name 을 unset 시키는 법을 혹시 아시는지요? 검색해봐도 체크아웃 페이지만 올라와 있어서 난감하네요.
아 이제야 봤네요!! Edit account 페이지는 잘 모르겠네요 ㅠㅠ