我在网上搜索了所有的代码段,插件或有关Wordpress WooCommerce的任何帮助,并在每个州的标准州销售税中增加了佛罗里达州的全权委托附加税。最初,我认为我可以通过创建所有佛罗里达州邮政编码的复杂列表并将其按县分组并为组设置每个费率来实现。似乎经过数天的数据输入后它就会工作,但我发现一些邮政编码跨越多个县,实际上,几个邮政编码跨越4个不同的县,每个县都有自己的附加税率。更糟的是,每年利率都会改变并且经常改变。我虽然也打算使用City,但是存在相同的问题。
自2009年以来,我已经见过好几个人在尝试解决此问题,但是并没有发布真正的解决方案。有人建议编辑州下拉列表,将所有县都添加到佛罗里达州(例如:佛罗里达州-阿拉卡瓦,佛罗里达州-贝克州,佛罗里达州-布拉德福德),但这将在50多个州列表中创建67个新条目,州外客户将是被迫滚动。最重要的是,有传言说,在线业务将来可能需要从州征收销售税,而其他州对每个县,教区等征收其他税率,并且似乎很少基于邮政编码。
我能看到的针对佛罗里达自由式附加税混乱的唯一解决方案是让我所有的佛罗里达州客户都显示一个额外的强制性“县”下拉列表(列出了67个可用的佛罗里达州),并且额外的营业税基于该选择。如果某个其他州有多个税收管辖区,则可以使用特定于该州的下拉菜单。必须确保在编辑地址页面,运送计算器区域和结帐页面中显示此新下拉列表(基本上是输入/编辑地址的任何地方)。在WooCommerce中-设置-税-标准税率-列(最好是在州代码列后面)中都是一种选择,以便可以将每个税率添加到适当的县/税收管辖区。
这是我到目前为止所得到的...
我需要整件事来以将“州”下拉列表设置为佛罗里达州为条件。如果输入了加拿大或佛罗里达州以外的任何其他美国州,则此代码不应运行。
function custom_admin_shipping_fields( $shipping_fields ) {
$shipping_fields['county'] = array(
'label' => __( 'Florida County', 'woocommerce' ),
'description' => 'Needed to calculate discretionary surtax.',
'desc_tip' => true,
'class' => array( 'form-row-wide', 'update_totals_on_change' ),
'priority' => 85,
'required' => true,
'show' => true,
'type' => 'select',
'options' => array(
'' => __( 'Select a Florida county...', 'woocommerce' ),
1 => __( 'Alachua', 'woocommerce' ),
2 => __( 'Baker', 'woocommerce' ),
3 => __( 'Bay', 'woocommerce' ),
4 => __( 'Bradford', 'woocommerce' ),
5 => __( 'Brevard', 'woocommerce' ),
6 => __( 'Broward', 'woocommerce' ),
7 => __( 'Calhoun', 'woocommerce' ),
8 => __( 'Charlotte', 'woocommerce' ),
9 => __( 'Citrus', 'woocommerce' ),
10 => __( 'Clay', 'woocommerce' ),
11 => __( 'Collier', 'woocommerce' ),
12 => __( 'Columbia', 'woocommerce' ),
13 => __( 'DeSoto', 'woocommerce' ),
13 => __( 'Dixie', 'woocommerce' ),
14 => __( 'Duval', 'woocommerce' ),
15 => __( 'add_more_counties_here', 'woocommerce' ),
),
);
return $shipping_fields;
}
add_filter( 'woocommerce_shipping_fields', 'custom_admin_shipping_fields');
add_filter( 'woocommerce_admin_shipping_fields', 'custom_admin_shipping_fields');
// ******************* ADMIN USER PROFILE PAGE ****************
// Would love to not have to double entry the county arrays but I could not figure out how
// to get the above code to work in the admin edit view profile page.
add_filter( 'woocommerce_customer_meta_fields', 'custom_customer_meta_fields' );
function custom_customer_meta_fields( $fields ) {
$fields['shipping']['fields']['county'] = array(
'label' => __( 'Florida County', 'woocommerce' ),
'description' => 'Needed to calculate discretionary surtax.',
'desc_tip' => true,
'class' => array( 'form-row-wide', 'update_totals_on_change' ),
'priority' => 85, // this does not move the county field to just after the state field like it does elsewhere, not sure why
'required' => true,
'show' => true,
'type' => 'select',
'options' => array(
'' => __( 'Select a Florida county...', 'woocommerce' ),
1 => __( 'Alachua', 'woocommerce' ),
2 => __( 'Baker', 'woocommerce' ),
3 => __( 'Bay', 'woocommerce' ),
4 => __( 'Bradford', 'woocommerce' ),
5 => __( 'Brevard', 'woocommerce' ),
6 => __( 'Broward', 'woocommerce' ),
7 => __( 'Calhoun', 'woocommerce' ),
8 => __( 'Charlotte', 'woocommerce' ),
9 => __( 'Citrus', 'woocommerce' ),
10 => __( 'Clay', 'woocommerce' ),
11 => __( 'Collier', 'woocommerce' ),
12 => __( 'Columbia', 'woocommerce' ),
13 => __( 'DeSoto', 'woocommerce' ),
13 => __( 'Dixie', 'woocommerce' ),
14 => __( 'Duval', 'woocommerce' ),
15 => __( 'add_more_counties_here', 'woocommerce' ),
),
);
return $fields;
}
// ***********************************************************
// the below is for the order screen, needs a little more work to display second array value field
// Would like it the save the actual name of the county and not the number for each order.
// Also, can't seem to get it to show up in the order details shipping area
/** * Update the order meta with field value */
add_action( 'woocommerce_checkout_update_order_meta', 'my_custom_checkout_field_update_order_meta');
function my_custom_checkout_field_update_order_meta( $order_id ) {
if ( ! empty( $_POST['county'] ) ) {
update_post_meta( $order_id, 'Florida County', sanitize_text_field( $_POST['county' ]) );
}
}
据我所知。但是,所有这些的全部要点是,这样我可以在WooCommerce>设置>税收>标准税率表中有一个County列。这样,我可以为每个县分别设置0.5%,1%,1.5%,2%和2.5%的附加税。