在我的 Woocommerce-Shop 结账处有一个下拉菜单,可以选择您所在的国家/地区。
默认情况下,美国已被自动选择。
如何只使用“选择您所在国家/地区”的占位符?
我找不到这个主题的任何解决方案有人有什么想法吗?
我更改了其他不是下拉菜单但位于同一表单内的占位符:
add_filter( 'woocommerce_checkout_fields' , 'override_billing_checkout_fields', 20, 1 );
function override_billing_checkout_fields( $fields ) {
$fields['billing']['billing_first_name']['placeholder'] = 'First Name*';
$fields['billing']['billing_last_name']['placeholder'] = 'Last Name*';
$fields['billing']['billing_city']['placeholder'] = 'Town / City*';
$fields['billing']['billing_postcode']['placeholder'] = 'ZIP*';
$fields['billing']['billing_email']['placeholder'] = 'Email Address*';
return $fields;
}
我现在糟糕的解决方案是:我创建了一个新的“下拉列表中的国家/地区”,我刚刚将其命名为:选择您的国家/地区*,然后默认选择它而不是美国。但问题在于,系统认为已经选择了一个真实的国家/地区,因此它不再是必填字段,而且事实上,当用户选择自己的国家/地区时,它看起来并不常见:
function woo_add_my_country( $country ) {
$country["PLACE"] = 'select your country*';
return $country;
}
add_filter( 'woocommerce_countries', 'woo_add_my_country', 10, 1 );
add_filter( 'default_checkout_billing_country', 'bbloomer_change_default_checkout_country' );
function bbloomer_change_default_checkout_country() {
return 'PLACE';
}
我将不胜感激任何帮助或提示!
这对我这边有用试试这个
// Change the default country and state on checkout page.
// This works for a new session.
add_filter( 'default_checkout_country', 'xa_set_default_checkout_country' );
add_filter( 'default_checkout_state', 'xa_set_default_checkout_state' );
function xa_set_default_checkout_country() {
// Returns empty country by default.
return null;
// Returns India as default country.
// return 'IN';
}
function xa_set_default_checkout_state() {
// Returns empty state by default.
return null;
// Returns Madhya Pradesh as default state.
// return 'MP';
}
function woo_add_my_country( $country ) {
$country["PLACE"] = 'select your country*';
return $country;
}
add_filter( 'woocommerce_countries', 'woo_add_my_country', 10, 1 );
add_filter( 'default_checkout_billing_country', 'bbloomer_change_default_checkout_country' );
function bbloomer_change_default_checkout_country() {
return 'PLACE';
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)