I'm creating a plugin that works with WooCommerce.
My plugin adds a tab in the "Product data" section of the WooCommerce product page.
add_filter( 'woocommerce_product_data_tabs', array($this, 'filter_woocommerce_product_data_tabs'), 10, 2);
public function filter_woocommerce_product_data_tabs($product_data_tabs) {
$product_data_tabs ['inventory']['class'] = implode( " ", $product_data_tabs ['inventory']['class']) . ' hide_if_serial_key';
$product_data_tabs['serial_key'] = array(
'label' => __( 'Serial Key', 'woocommerce_digital_products'),
'target' => 'serial_key_options',
'class' => array( 'show_if_serial_key' ),
'priority' => 19
);
return $product_data_tabs;
}
In this tab, I added a WP_List_Table that works very well for display.
add_filter( 'woocommerce_product_data_panels', array($this, 'filter_woocommerce_product_data_panels'), 10, 2);
public function filter_woocommerce_product_data_panels() {
$myListTable = WooCommerce_Digital_Products_Simplified_Licenses_Table::get_instance();
$myListTable->prepare_items();
echo '<div id="serial_key_options" class="panel hidden" style="padding: 20px;">';
echo $myListTable->display();
echo '</div>';
}
On the other hand, it creates a strange behavior with the "Update" button, since it redirects me to the "Articles" administration page, rather than updating the product.
I know this is due to the WP_List_Table because if I comment this line in my code, the update function works again:
echo $myListTable->display();
Is that possible to use WP_List_Table in Product settings page ? If so, how to make it works ?
I apologize for my English, it is not my mother tongue.
Thanks for you help. Thomas.