I want Woocommerce pre-order plugin to add itself to my custom product type i have created. If i choose Woocommerce standard product types i get a pre-order tab.
Is there a hook to pass in my "custom product type" to the plugin so it knows that it should be visible?
I have follow this guide: http://jeroensormani.com/adding-a-custom-woocommerce-product-type/ to actually add the custom product and it works.
I dont have a code sample because i dont know how this could be done .
EDIT #1 - User wanted to have reference code from the plugin .
This is taken from the "class-wc-pre-orders-admin.php"
/** product hooks */
// add 'Pre-Orders' product writepanel tab
add_action( 'woocommerce_product_write_panel_tabs', array( $this, 'add_product_tab' ), 11 );
// Add 'Pre-Orders' tab content
add_action( 'woocommerce_product_write_panels', array( $this, 'add_product_tab_options' ), 11 );
/** Functions **/
<?php
/**
* Add 'Pre-Orders' tab to product writepanel
*
* @since 1.0
*/
public function add_product_tab() {
?>
<li class="wc_pre_orders_tab wc_pre_orders_options">
<a href="#wc_pre_orders_data"><?php _e( 'Pre-Orders', WC_Pre_Orders::TEXT_DOMAIN ); ?></a>
</li>
<?php
}
Cant find where they filter the tabs, just adds it to the array that prints.
At the moment i do not have a filter on the hook "product_data_tabs"
EDIT #2 - Added my code .
/* STEP 1 */
function register_simple_custom_product_type() {
class WC_Product_Simple_Custom_Product extends WC_Product_Simple {
public function __construct( $product ) {
$this->product_type = 'simple_custom';
parent::__construct( $product );
}
}
}
add_action( 'init', 'register_simple_custom_product_type' );
/* STEP 2 */
function add_simple_custom_product( $types ){
$types[ 'simple_custom' ] = __( 'Simple custom' );
return $types;
}
add_filter( 'product_type_selector', 'add_simple_custom_product' );
/* STEP 3*/
function custom_product_tabs( $tabs) {
$tabs['custom'] = array(
'label' => __( 'Custom', 'woocommerce' ),
'target' => 'custom_options',
'class' => array( 'show_if_simple_custom', 'show_if_variable_custom' ),
);
/* filter to show pre_order tab with this product-type */
tabs['pre_order']['class'][] = 'show_if_simple_custom show_if_variable_custom';
return $tabs;
}
add_filter( 'woocommerce_product_data_tabs', 'custom_product_tabs' );
But this does not .
show a new tab with the name of Custom .
Show the pre-order tab when i select Simple custom as product-type in the drop-down field .
EDIT #3 .
Correct answer is marked and here is link to corrected code http://pastebin.com/GM1UmDwC