

   /**
 * Shikdo - Ensure Iran country for WooCommerce customers
 *
 * اگر کاربر آدرس دارد ولی Country خالی است،
 * Country به صورت خودکار IR می‌شود.
 */

/* =========================================================
 * 1. هنگام ذخیره آدرس WooCommerce
 * ========================================================= */
add_action( 'woocommerce_customer_save_address', 'shikdo_ensure_iran_customer_country', 20, 2 );

function shikdo_ensure_iran_customer_country( $user_id, $load_address ) {

    if ( ! $user_id ) {
        return;
    }

    if ( 'billing' === $load_address ) {

        $address = get_user_meta( $user_id, 'billing_address_1', true );
        $country = get_user_meta( $user_id, 'billing_country', true );

        if ( ! empty( $address ) && empty( $country ) ) {
            update_user_meta( $user_id, 'billing_country', 'IR' );
        }
    }

    if ( 'shipping' === $load_address ) {

        $address = get_user_meta( $user_id, 'shipping_address_1', true );
        $country = get_user_meta( $user_id, 'shipping_country', true );

        if ( ! empty( $address ) && empty( $country ) ) {
            update_user_meta( $user_id, 'shipping_country', 'IR' );
        }
    }
}


/* =========================================================
 * 2. هنگام ساخت کاربر جدید
 * ========================================================= */
add_action( 'user_register', 'shikdo_set_default_country_for_new_user', 20 );

function shikdo_set_default_country_for_new_user( $user_id ) {

    if ( ! $user_id ) {
        return;
    }

    // فقط اگر Country قبلاً تنظیم نشده باشد
    if ( ! get_user_meta( $user_id, 'billing_country', true ) ) {
        update_user_meta( $user_id, 'billing_country', 'IR' );
    }

    if ( ! get_user_meta( $user_id, 'shipping_country', true ) ) {
        update_user_meta( $user_id, 'shipping_country', 'IR' );
    }
} <?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//shikdo.com/main-sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<sitemap>
		<loc>https://shikdo.com/post-sitemap.xml</loc>
		<lastmod>2025-08-12T13:21:49+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://shikdo.com/page-sitemap.xml</loc>
		<lastmod>2026-06-23T10:41:57+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://shikdo.com/product-sitemap1.xml</loc>
		<lastmod>2026-09-14T12:29:44+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://shikdo.com/product-sitemap2.xml</loc>
		<lastmod>2026-09-14T12:29:41+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://shikdo.com/product-sitemap3.xml</loc>
		<lastmod>2026-09-14T12:29:39+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://shikdo.com/category-sitemap.xml</loc>
		<lastmod>2025-08-12T13:21:49+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://shikdo.com/cms_block_cat-sitemap.xml</loc>
		<lastmod>2026-06-22T09:19:51+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://shikdo.com/product_cat-sitemap.xml</loc>
		<lastmod>2026-09-14T12:29:44+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://shikdo.com/product_tag-sitemap.xml</loc>
		<lastmod>2026-09-12T11:11:28+00:00</lastmod>
	</sitemap>
</sitemapindex>
<!-- XML Sitemap generated by Rank Math SEO Plugin (c) Rank Math - rankmath.com -->