<?php

defined('ABSPATH') || exit;

class BundlePress_Bundle_Product
{
    public function __construct()
    {
        add_filter('product_type_selector', [$this, 'add_bundle_type']);
        add_action('plugins_loaded', [$this, 'register_bundle_product_type']);
        add_filter('woocommerce_product_class', [$this, 'get_bundle_product_class'], 10, 2);
    }

    public function get_bundle_product_class($classname, $product_type)
    {
        if ($product_type === 'bundlepress') {
            return 'WC_Product_BundlePress_Product';
        }
        return $classname;
    }

    public function add_bundle_type($types)
    {
        $types['bundlepress'] = __('BundlePress Product', 'bundlepress');
        return $types;
    }

    public function register_bundle_product_type()
    {
        if (class_exists('WC_Product')) {
            require_once BUNDLEPRESS_PATH . 'includes/class-wc-product-bundlepress-product.php';
        }
    }
}
