Follow these steps to register a new product type with WooCommerce:
- Open the wpcookbookchapter9.php file of the new WPCookbook Chapter 9 plugin in the code editor.
- Add the following code to register a new WooCommerce product type called Support Packages:
add_action( 'plugins_loaded', 'wpccp_chapter9_register_product_type');function wpccp_chapter9_register_product_type() { if(class_exists('WC_Product')){ class WC_Product_Simple_WPCCP_Support_Package extends WC_Product { public function __construct( $product ) { $this->virtual = 'yes'; $this->downloadable = 'yes'; parent::__construct( $product ); } public function get_type( ) { return 'simple_wpccp_support_package'; } } }}// Step 3 code should be placed after this line