【发布时间】:2016-10-12 14:46:04
【问题描述】:
在我的帐户页面中,
我想使用下面类似的代码在特定的“城市”或“邮政编码”进行销售,下面的代码用于在特定的“州”进行销售:
/**
* Sell only in Alger & Zeralda
*/
function wc_sell_only_states( $states ) {
$states['DZ'] = array(
'ALG' => __( 'Alger', 'woocommerce' ),
'ZLD' => __( 'Zeralda', 'woocommerce' ),
);
return $states;
}
add_filter( 'woocommerce_states', 'wc_sell_only_states' );
我应该使用或修改什么?
我试过了,但它显示“错误代码 500”:
// define the woocommerce_countries_base_city callback
function filter_woocommerce_countries_base_city( $var ) {
// make filter magic happen here...
$var['DZ'] = array(
'ALG' => __( 'Alger', 'woocommerce' ),
'ZLD' => __( 'Zeralda', 'woocommerce' ),
);
return $var;
};
// add the filter
add_filter( 'woocommerce_countries_base_city', 'filter_woocommerce_countries_base_city', 10, 1 );
谢谢你!
【问题讨论】:
-
发现我的问题不清楚或有用的人请告诉我有什么问题?!
-
这不是标准的 wocommerce 钩子,而是智利比索插件的一部分?这是标准 WooCommerce 钩子的列表 -> docs.woothemes.com/wc-apidocs/hook-docs.html
-
我在这里找到了它gist.github.com/woogist/b81742981ca6297b03e6,它对我有用,现在我还需要指定一些城市
-
你有没有尝试过?
-
不,还没有,我还在努力!
标签: wordpress woocommerce registration