I dont know is this a bug of WooCommerce or I am doing something wrong.this is my code to add a custom settings tab for and adding fields.but whenever I add a fields with $settings array it outputting two same field.its happening for all type of fields including text,title etc.
<?php
/**
* Main Class for WooFees
* @package WooFees
*/
namespace src\classes;class WooFees{
public function __construct(){
add_action("woocommerce_cart_calculate_fees",[$this, 'woofees']);
add_action("woocommerce_settings_tabs_array", [$this, 'add_vat_rate_tab'], 50);
add_action("woocommerce_settings_tabs_vat_rate_tab", [$this, "settings_tab"]);
}
public function woofees(){
global $woocommerce;
$vat = $woocommerce->cart->cart_contents_total * 0.05;
$woocommerce->cart->add_fee(__("VAT (5%) ", 'woofees'), $vat);
}
public function add_vat_rate_tab($tabs){
$tabs['vat_rate_tab'] = __("Extra Fee", 'woofees');
return $tabs;
}
public function settings_tab(){
woocommerce_admin_fields($this->vat_rate_tab_fields());
}
public function vat_rate_tab_fields(){
$settings = [
'sections_title' => [
'id' => 'vat_rate_tab_title',
'name' => __("Configure Addition VAT rate for Customers", 'woofees'),
'desc' => __("Configure Addition VAT or TAX for Your Products That Your Castomers Will See in The Checkout Page and They Have to Pay The Extra"),
'type' => 'title'
],
];
return apply_filters("vat_rate_tab_fields", $settings);
}
}