/*
Theme Name: Tobel
Theme URI: https://tobel.qodeinteractive.com
Description: Modern Furniture Store
Author: Elated Themes
Author URI: https://qodeinteractive.com
Text Domain: tobel
Tags: one-column, two-columns, three-columns, four-columns, left-sidebar, right-sidebar, custom-menu, featured-images, flexible-header, post-formats, sticky-post, threaded-comments, translation-ready
Version: 1.3
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
add_filter('woocommerce_get_price_html', 'modify_product_price_display', 10, 2);

function modify_product_price_display($price_html, $product) {
    // Check if the product is a variable product
    if ($product->is_type('variable')) {
        // Get all variations of the variable product
        $variations = $product->get_available_variations();
        
        // Initialize an empty array to store prices
        $prices = array();
        
        // Loop through each variation
        foreach ($variations as $variation) {
            // Get the variation object
            $variation_obj = wc_get_product($variation['variation_id']);
            
            // Get the variation price
            $variation_price = $variation_obj->get_price();
            
            // Add the variation price to the prices array
            $prices[] = $variation_price;
        }
        
        // Find the minimum price from the prices array
        $min_price = min($prices);
        
        // Return the minimum price formatted
        return wc_price($min_price);
    } else {
        // For other product types, return the original price HTML
        return $price_html;
    }
}


