从WooCommerce的仅运送选项中排除状态

时间:2019-10-13 17:44:58

标签: woocommerce

我想从仅运输状态字段中删除特定状态。但是它将保持计费状态。

但是我当前的代码从两个状态列表中删除了状态。有什么办法可以解决这个问题?

这是我当前的代码

function remove_states_for_us( $states ) {
    $not_allowed_us_states = array('MA'); 

    // Loop through not allowed us states and remove them
    foreach( $not_allowed_us_states as $state_code ) {
        if( isset($states['US'][$state_code]) ){
            unset( $states['US'][$state_code] );
        }
    }
    return $states;
}
add_filter( 'woocommerce_states', 'remove_states_for_us', 10, 1 );

0 个答案:

没有答案