繁体   English   中英

Woocommerce中国家的自定义列表

[英]Custom list of states countries in Woocommerce

我正在尝试按国家列出清单。 我知道如何为各州做到这一点。 我用过

add_filter( 'woocommerce_states', 'custom_woocommerce_states' );

function custom_woocommerce_states( $states ) {
  $states['IN'] = array(
    'PB' => 'Punjab'
  );

  return $states;
}

为了达到国家的目的。 但是如何制作自定义国家列表?

这是你想要的吗 ?

add_filter('woocommerce_countries','custom_country', 10, 1);

function custom_country($mycountry){
    $mycountry = array(
        'AF' => __( 'Afghanistan', 'woocommerce' ),
        'IN' => __( 'India', 'woocommerce' )
    );
    return $mycountry;
}

您可以将此粘贴到您的主题functions.php文件中

/* Add a new country to countries list */
function woo_add_my_country( $country ) {
  $country["AE-DU"] = 'Dubai';  
    return $country; 
}
add_filter( 'woocommerce_countries', 'woo_add_my_country', 10, 1 );

你是这个意思吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM