更新日期:2021-10-28
如果要重新客製化結帳欄位或是更改順序,勢必要先知道相關定義變數名稱及順序。
先利用 woocommerce_checkout_fields 這個 hook 去輸出 $fields 資料,取的預設的欄位資訊如下:
Array
(
[billing] => Array
(
[billing_first_name] => Array
(
[label] => 名字
[required] => 1
[class] => Array
(
[0] => form-row-first
)
[autocomplete] => given-name
[priority] => 10
)
[billing_last_name] => Array
(
[label] => 姓氏
[required] => 1
[class] => Array
(
[0] => form-row-last
)
[autocomplete] => family-name
[priority] => 20
)
[billing_company] => Array
(
[label] => 公司名稱
[class] => Array
(
[0] => form-row-wide
)
[autocomplete] => organization
[priority] => 30
[required] =>
)
[billing_country] => Array
(
[type] => country
[label] => 國家/地區或區域
[required] => 1
[class] => Array
(
[0] => form-row-wide
[1] => address-field
[2] => update_totals_on_change
)
[autocomplete] => country
[priority] => 40
)
[billing_address_1] => Array
(
[label] => 街道地址
[placeholder] => 門牌號碼與街道名稱
[required] => 1
[class] => Array
(
[0] => form-row-wide
[1] => address-field
)
[autocomplete] => address-line1
[priority] => 50
)
[billing_address_2] => Array
(
[label] => Apartment, suite, unit, etc.
[label_class] => Array
(
[0] => screen-reader-text
)
[placeholder] => 公寓、套房、單元等(選填)
[class] => Array
(
[0] => form-row-wide
[1] => address-field
)
[autocomplete] => address-line2
[priority] => 60
[required] =>
)
[billing_city] => Array
(
[label] => 鄉鎮市
[required] => 1
[class] => Array
(
[0] => form-row-wide
[1] => address-field
)
[autocomplete] => address-level2
[priority] => 70
[type] => city
)
[billing_state] => Array
(
[type] => state
[label] => 縣 / 市
[required] => 1
[class] => Array
(
[0] => form-row-wide
[1] => address-field
)
[validate] => Array
(
[0] => state
)
[autocomplete] => address-level1
[priority] => 80
[country_field] => billing_country
[country] => TW
)
[billing_postcode] => Array
(
[label] => 郵遞區號
[required] => 1
[class] => Array
(
[0] => form-row-wide
[1] => address-field
)
[validate] => Array
(
[0] => postcode
)
[autocomplete] => postal-code
[priority] => 90
)
[billing_phone] => Array
(
[label] => 聯絡電話
[required] => 1
[type] => tel
[class] => Array
(
[0] => form-row-wide
)
[validate] => Array
(
[0] => phone
)
[autocomplete] => tel
[priority] => 100
)
[billing_email] => Array
(
[label] => 電子郵件
[required] => 1
[type] => email
[class] => Array
(
[0] => form-row-wide
)
[validate] => Array
(
[0] => email
)
[autocomplete] => email username
[priority] => 110
)
)
[shipping] => Array
(
[shipping_first_name] => Array
(
[label] => 名字
[required] => 1
[class] => Array
(
[0] => form-row-first
)
[autocomplete] => given-name
[priority] => 10
)
[shipping_last_name] => Array
(
[label] => 姓氏
[required] => 1
[class] => Array
(
[0] => form-row-last
)
[autocomplete] => family-name
[priority] => 20
)
[shipping_company] => Array
(
[label] => 公司名稱
[class] => Array
(
[0] => form-row-wide
)
[autocomplete] => organization
[priority] => 30
[required] =>
)
[shipping_country] => Array
(
[type] => country
[label] => 國家/地區或區域
[required] => 1
[class] => Array
(
[0] => form-row-wide
[1] => address-field
[2] => update_totals_on_change
)
[autocomplete] => country
[priority] => 40
)
[shipping_address_1] => Array
(
[label] => 街道地址
[placeholder] => 門牌號碼與街道名稱
[required] => 1
[class] => Array
(
[0] => form-row-wide
[1] => address-field
)
[autocomplete] => address-line1
[priority] => 50
)
[shipping_address_2] => Array
(
[label] => Apartment, suite, unit, etc.
[label_class] => Array
(
[0] => screen-reader-text
)
[placeholder] => 公寓、套房、單元等(選填)
[class] => Array
(
[0] => form-row-wide
[1] => address-field
)
[autocomplete] => address-line2
[priority] => 60
[required] =>
)
[shipping_city] => Array
(
[label] => 鄉鎮市
[required] => 1
[class] => Array
(
[0] => form-row-wide
[1] => address-field
)
[autocomplete] => address-level2
[priority] => 70
[type] => city
)
[shipping_state] => Array
(
[type] => state
[label] => 縣 / 市
[required] => 1
[class] => Array
(
[0] => form-row-wide
[1] => address-field
)
[validate] => Array
(
[0] => state
)
[autocomplete] => address-level1
[priority] => 80
[country_field] => shipping_country
[country] => TW
)
[shipping_postcode] => Array
(
[label] => 郵遞區號
[required] => 1
[class] => Array
(
[0] => form-row-wide
[1] => address-field
)
[validate] => Array
(
[0] => postcode
)
[autocomplete] => postal-code
[priority] => 90
)
)
[account] => Array
(
)
[order] => Array
(
[order_comments] => Array
(
[type] => textarea
[class] => Array
(
[0] => notes
)
[label] => 訂單備註
[placeholder] => 您的訂單的備註,例如: 運送時的特別註記。
)
)
)