问题描述
我在我的Wordpress网站上使用 WooCommerce 。默认情况下,在结帐页面上会填充客户的帐单和运输详细信息。我希望默认情况下不会设置国家/地区。相反,即使用户已登录,它也会要求选择国家。
I am using WooCommerce in my Wordpress web site. The customers billing and shipping details are populated by default on checkout page. I want that the country will not be set by default. Instead it will asked to select country even if user is logged in.
有什么建议吗?为了实现这一目标,我应该怎么做?
Any suggestions? What I should do in order to achieve this?
推荐答案
这是为此目的的woocommerce挂钩(请参见 )。我不确定,但是您可以尝试以下(未试用):
This are the woocommerce hooks for this purpose (see in here). I am not sure, but you could try this (untested):
/**
* Manipulate default state and countries
*/
add_filter( 'default_checkout_country', 'change_default_checkout_country' );
add_filter( 'default_checkout_state', 'change_default_checkout_state' );
function change_default_checkout_country() {
return null;
}
function change_default_checkout_state() {
return null;
}
您必须将该代码粘贴到活动孩子的function.php文件中主题或主题...
我用 null
替换了国家代码'xx'
...
You have to paste that code in the function.php file of your active child theme or theme…
I have replaced the country code 'xx'
by null
…
这篇关于WooCommerce:默认在结帐页面中设置国家的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!