반응형
WooCommerce Billing 양식에 사용자 정의 필드를 추가하시겠습니까?
WooCommerce Billing 양식에 사용자 정의 필드를 추가하는 코드를 받습니다.
필드가 표시되지만 문제는 필드에 nor도 없다는 것입니다.
내가 뭘 놓치고 있는 거지?기능에 이 코드를 추가했습니다.내 아이 테마에 php가 있습니다.
/*******************************
CUSTOM BILLING FIELD
******************************** */
add_filter('woocommerce_billing_fields', 'custom_woocommerce_billing_fields');
function custom_woocommerce_billing_fields($fields)
{
$fields['billing']['billing_options'] = array(
'label' => __('NIF', 'woocommerce'), // Add custom field label
'placeholder' => _x('Your NIF here....', 'placeholder', 'woocommerce'), // Add custom field placeholder
'required' => false, // if field is required or not
'clear' => false, // add clear or not
'type' => 'text', // add field type
'class' => array('my-css') // add class name
);
return $fields;
}
사용하시는 경우
woocommerce_billing_fields
그러면 자동으로 청구 필드에 할당되는 필드를 지정할 필요가 없습니다.하지만 당신이 사용하는 것은woocommerce_checkout_fields
그런 다음 필드를 사용하도록 지정하기만 하면 됩니다.shipping
아니면billing
.
위해서woocommerce_billing_fields
add_filter('woocommerce_billing_fields', 'custom_woocommerce_billing_fields');
function custom_woocommerce_billing_fields($fields)
{
$fields['billing_options'] = array(
'label' => __('NIF', 'woocommerce'), // Add custom field label
'placeholder' => _x('Your NIF here....', 'placeholder', 'woocommerce'), // Add custom field placeholder
'required' => false, // if field is required or not
'clear' => false, // add clear or not
'type' => 'text', // add field type
'class' => array('my-css') // add class name
);
return $fields;
}
위해서
woocommerce_checkout_fields
add_filter('woocommerce_checkout_fields', 'custom_woocommerce_billing_fields');
function custom_woocommerce_billing_fields($fields)
{
$fields['billing']['billing_options'] = array(
'label' => __('NIF', 'woocommerce'), // Add custom field label
'placeholder' => _x('Your NIF here....', 'placeholder', 'woocommerce'), // Add custom field placeholder
'required' => false, // if field is required or not
'clear' => false, // add clear or not
'type' => 'text', // add field type
'class' => array('my-css') // add class name
);
return $fields;
}
참조:
언급URL : https://stackoverflow.com/questions/42341548/add-a-custom-field-to-woocommerce-billing-form
반응형
'it-source' 카테고리의 다른 글
장고 모델:부울 필드의 기본값이 Maria에서 설정되지 않았습니다.DB (0) | 2023.10.18 |
---|---|
다중 컬럼 ASC 및 DESC별 MySQL 주문 (0) | 2023.10.18 |
Mysql cut string, 첫번째 캐릭터? (0) | 2023.10.13 |
MySQL에서 <> 연산자와 != 연산자의 차이점은 무엇입니까? (0) | 2023.10.13 |
(정규 객체에 대한 포인터와 반대로) 정칙 포인터는 어떤 용도로 사용됩니까? (0) | 2023.10.13 |