Woocommerce 欧盟增值税号插件 - 如何从自定义下拉列表中添加增值税豁免的额外条件?

问题描述 投票:0回答:1

https://woocommerce.com/products/eu-vat-number/

在文档中提到了有关排除或包含特定国家/地区的内容。

add_filter( 'woocommerce_eu_vat_number_country_codes', 'woo_custom_eu_vat_number_country_codes' );
function woo_custom_eu_vat_number_country_codes( $vat_countries ) {
    $display_vat = array_diff($vat_countries, ['SE', 'GB']); // remove countries in second array
    return array_values($display_vat); // reindex array
}

我想做同样的事情,但是对于自定义下拉字段的值。 例如。如果是私人客户,则不要显示增值税号字段,也不要删除增值税。

我怎样才能实现这个目标?

谢谢!

php wordpress woocommerce checkout
1个回答
0
投票

我已经通过使用 jQuery 分离和前置字段来解决这个问题。

  if (jQuery('#wc_billing_field_7378 :selected').text() === 'Zakelijk') {
        jQuery('.woocommerce-billing-fields__fieldwrapper').prepend(vatfieldprepend);
        } 

  else{
        vatfieldprepend = jQuery('#woocommerce_eu_vat_number_field').detach();
    }   
  }).change();
© www.soinside.com 2019 - 2024. All rights reserved.