I’m trying to set up a woocommerce custom product type so that its as minimal as possible – no options I don’t specifically designate.
Still, despite the declaration below, the custom product meta box still shows “shipping” shipping options.
How do I get rid of the shipping options? And on that note, any other that I may wish to remove.
add_action('plugins_loaded', 'ss_create_custom_product_type');
function ss_create_custom_product_type() {
// declare the product class
class WC_Product_Wdm extends WC_Product {
public function __construct($product) {
$this->product_type="ss_stock_image";
$this->virtual="yes";
$this->downloadable="yes";
$this->manage_stock = 'no';
parent::__construct($product);
// add additional functions here
}
}
}
UPDATE:
I’ve updated the class per suggestion. Yet I wonder why the code is not getting fired.
add_action('plugins_loaded', 'ss_create_custom_product_type');
function ss_create_custom_product_type() {
// declare the product class
class WC_Product_Wdm extends WC_Product {
public function __construct($product) {
$this->product_type="ss_stock_image";
add_filter('woocommerce_product_data_tabs', array($this, 'remove_tabs'), 10, 1);
parent::__construct($product);
}
public function remove_tabs($tabs) {
/**
* The available tab array keys are:
*
* general
* inventory
* shipping
* linked_product
* attribute
* variations
* advanced
*/
unset($tabs['shipping']);
return $tabs;
}
}
}