Woocommerce - 自定义结帐字段

时间:2017-07-19 09:59:44

标签: wordpress woocommerce

我希望你们能帮助我解决woo-commerce问题。

我使用this guide删除整个结帐并将其替换为我自己的结帐。我使用此代码删除标准字段。

我的问题是: 当我填写表格时,我不断失败(从丹麦语翻译成英语):请填写地址栏以继续。

// Hook in
add_filter( 'woocommerce_default_address_fields' , 'custom_override_default_address_fields' );
// Our hooked in function - $address_fields is passed via the filter!
function custom_override_default_address_fields( $address_fields ) {
 $address_fields['address_1']['required'] = false;

 return $address_fields;
}

1 个答案:

答案 0 :(得分:0)

add_filter( 'woocommerce_checkout_fields' , 'xa_checkout_change_required_fields_to_optional' );
function xa_checkout_change_required_fields_to_optional( $fields ) {
     $fields['billing']['billing_address_1']['required'] = false;
     $fields['billing']['billing_address_2']['required'] = false;
     $fields['billing']['billing_postcode']['required'] = false;
     $fields['billing']['billing_city']['required'] = false;
     $fields['billing']['billing_phone']['required'] = false;

     return $fields;
}

尝试like this