<?php

add_action( 'wp_enqueue_scripts', 'woodmart_child_enqueue_styles', 1000 );

function woodmart_child_enqueue_styles() {
    wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( 'woodmart-style' ), woodmart_get_theme_info( 'Version' ) );
}

// ==================== ساده‌سازی فرم چک‌اوت ووکامرس ====================
add_filter( 'woocommerce_checkout_fields', 'custom_simple_checkout_fields' );
function custom_simple_checkout_fields( $fields ) {
    // حذف فیلدهای غیرضروری
    unset($fields['billing']['billing_company']);
    unset($fields['billing']['billing_address_2']);
    unset($fields['billing']['billing_city']);
    unset($fields['billing']['billing_state']);
    unset($fields['billing']['billing_email']);

    // تغییر برچسب‌ها برای ساده‌سازی
    $fields['billing']['billing_first_name']['label'] = 'نام';
    $fields['billing']['billing_last_name']['label'] = 'نام خانوادگی';
    $fields['billing']['billing_phone']['label'] = 'شماره تماس';
    $fields['billing']['billing_address_1']['label'] = 'آدرس';
    $fields['billing']['billing_postcode']['label'] = 'کد پستی';

    // فیلدهای اجباری
    $fields['billing']['billing_postcode']['required'] = true;
    $fields['billing']['billing_phone']['required'] = true;

    // کشور پیش‌فرض و مخفی
    $fields['billing']['billing_country']['type'] = 'hidden';
    $fields['billing']['billing_country']['default'] = 'IR';

    return $fields;
}

add_filter( 'woocommerce_shipping_fields', 'custom_simple_shipping_fields' );
function custom_simple_shipping_fields( $fields ) {
    unset($fields['shipping_company']);
    return $fields;
}
