<?php
/**
 * Enqueue child styles.
 */
function child_enqueue_styles() {
    wp_enqueue_style( 'child-theme', get_stylesheet_directory_uri() . '/style.css', array(), 100 );
}

add_action( 'wp_enqueue_scripts', 'child_enqueue_styles' );


// remove price
// remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
// remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );

// remove add to cart
// remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
// remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );

// Show custom price labels based on product status
add_filter( 'woocommerce_get_price_html', 'walton_custom_price_label', 10, 2 );
function walton_custom_price_label( $price_html, $product ) {
    $price_status = get_field( 'product_price_status', $product->get_id() );

    if ( $price_status === 'coming_soon' ) {
        return '<span class="price-label coming-soon-badge">Coming Soon</span>';
    } elseif ( $price_status === 'sold_with_base' ) {
        return '<span class="price-label sold-with-base-badge">Sold with base unit</span>';
    }

    return $price_html; // Default: show normal price
}

// Hide add to cart for coming soon products
add_filter( 'woocommerce_is_purchasable', 'walton_custom_price_purchasable', 10, 2 );
function walton_custom_price_purchasable( $purchasable, $product ) {
    $price_status = get_field( 'product_price_status', $product->get_id() );

    if ( $price_status === 'coming_soon' ) {
        return false;
    }

    return $purchasable;
}