public function get_product_categories($product_id)
        {
            $categories = array();
            $current_categories = wp_get_post_terms($product_id, 'product_cat');
            foreach ($current_categories as $category) {
                $categories[] = $category->term_id;
            }
            return $categories;
        }
        /**
         * Check WooCommerce version
         * 
         * @access public
         * @param string $version
         * @return bool
         */
        public function wc_version_gte($version)
        {
            if (defined('WC_VERSION') && WC_VERSION) {
                return version_compare(WC_VERSION, $version, '>=');
            } else {
                if (defined('WOOCOMMERCE_VERSION') && WOOCOMMERCE_VERSION) {
                    return version_compare(WOOCOMMERCE_VERSION, $version, '>=');
                } else {
                    return false;
                }
            }
        }
    }
    $GLOBALS['RP_WCDPD'] = RP_WCDPD::get_instance();
}
function product_page_pricing_table_data()
{
    $RP_WCDPD = RP_WCDPD::get_instance();
    $this_option = $RP_WCDPD->get_options();
    if ($this_option['settings']['display_table'] == 'hide' && (!isset($this_option['settings']['display_offers']) || $this_option['settings']['display_offers'] == 'hide')) {
        return;
    }
    global $product;
    if (!$product) {
        return;
    }
    // Load required classes
    require_once RP_WCDPD_PLUGIN_PATH . 'includes/classes/Pricing.php';
    $selected_rule = null;
    // Iterate over pricing rules and use the first one that has this product in conditions (or does not have if condition "not in list")
    if (isset($this_option['pricing']['sets']) && count($this_option['pricing']['sets'])) {
        foreach ($this_option['pricing']['sets'] as $rule_key => $rule) {
            if ($rule['method'] == 'quantity' && ($validated_rule = RP_WCDPD_Pricing::validate_rule($rule))) {
                if ($validated_rule['selection_method'] == 'all' && $RP_WCDPD->user_matches_rule($validated_rule)) {
                    $selected_rule = $validated_rule;
                    break;
                }
                if ($validated_rule['selection_method'] == 'categories_include' && count(array_intersect($RP_WCDPD->get_product_categories($product->id), $validated_rule['categories'])) > 0 && $RP_WCDPD->user_matches_rule($validated_rule)) {
                    $selected_rule = $validated_rule;
                    break;
                }
                if ($validated_rule['selection_method'] == 'categories_exclude' && count(array_intersect($RP_WCDPD->get_product_categories($product->id), $validated_rule['categories'])) == 0 && $RP_WCDPD->user_matches_rule($validated_rule)) {
                    $selected_rule = $validated_rule;
                    break;
                }
                if ($validated_rule['selection_method'] == 'products_include' && in_array($product->id, $validated_rule['products']) && $RP_WCDPD->user_matches_rule($validated_rule)) {
                    $selected_rule = $validated_rule;
                    break;
                }
                if ($validated_rule['selection_method'] == 'products_exclude' && !in_array($product->id, $validated_rule['products']) && $RP_WCDPD->user_matches_rule($validated_rule)) {
                    $selected_rule = $validated_rule;
                    break;
                }
            }
        }
    }
    if (is_array($selected_rule)) {
        // Quantity
        if ($selected_rule['method'] == 'quantity' && in_array($this_option['settings']['display_table'], array('modal', 'inline')) && isset($selected_rule['pricing'])) {
            if ($product->product_type == 'variable') {
                $product_variations = $product->get_available_variations();
            }
            // For variable products only - check if prices differ for different variations
            $multiprice_variable_product = false;
            if ($product->product_type == 'variable' && !empty($product_variations)) {
                $last_product_variation = array_slice($product_variations, -1);
                $last_product_variation_object = new WC_Product_Variable($last_product_variation[0]['variation_id']);
                $last_product_variation_price = $last_product_variation_object->get_price();
                foreach ($product_variations as $variation) {
                    $variation_object = new WC_Product_Variable($variation['variation_id']);
                    if ($variation_object->get_price() != $last_product_variation_price) {
                        $multiprice_variable_product = true;
                    }
                }
            }
            if ($multiprice_variable_product) {
                $variation_table_data = array();
                foreach ($product_variations as $variation) {
                    $variation_product = new WC_Product_Variation($variation['variation_id']);
                    $variation_table_data[$variation['variation_id']] = $RP_WCDPD->pricing_table_calculate_adjusted_prices($selected_rule['pricing'], $variation_product->get_price());
                }
            } else {
                if ($product->product_type == 'variable' && !empty($product_variations)) {
                    $variation_product = new WC_Product_Variation($last_product_variation[0]['variation_id']);
                    $table_data = $RP_WCDPD->pricing_table_calculate_adjusted_prices($selected_rule['pricing'], $variation_product->get_price());
                } else {
                    $table_data = $RP_WCDPD->pricing_table_calculate_adjusted_prices($selected_rule['pricing'], $product->get_price());
                }
            }
        }
        return $table_data;
    }
    return false;
}