How it works...
We need to register a WooCommerce custom product type in order to make it available for selection in product creation. WooCommerce provides a base class for products, which we can extend to create custom product types. In the first section, we used a callback function on the plugins_loaded action. Inside this function, we have to check whether WooCommerce is already activated by using the class_exists('WC_Product') check.
Then, we define a new class called WC_Product_Simple_WPCCP_Support_Packages that extends the base WC_Product class. The class only has a constructor and get_type function. We set the product to virtual and downloadable inside the constructor.
Support Package is a type of product where the purchased user will ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access