=== Futurecode Döviz Kuru Fiyatlandırma for WooCommerce ===
Contributors: futurecodetr
Tags: exchange rate, currency, tcmb, doviz, woocommerce
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Requires Plugins: woocommerce
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Price WooCommerce products in USD or EUR; lira prices follow the daily TCMB rate with margin, rounding, bulk edit and CSV.

== Description ==

**Türkçe**

Dövizle mal alan ve TL ile satan mağazalar için: ürün ve varyasyon fiyatlarını USD, EUR, GBP ya da TCMB'nin yayımladığı herhangi bir para biriminde girin. Mağazadaki TL fiyat, Türkiye Cumhuriyet Merkez Bankası'nın (TCMB) günlük gösterge kuruyla her gün kendiliğinden hesaplanır.

* **TCMB günlük kurları** her gün sizin seçtiğiniz saatte WP-Cron ile indirilir. Döviz alış, döviz satış, efektif alış ya da efektif satış kuru seçilebilir.
* **Kur alınamazsa** fiyatlar son geçerli kurla hesaplanmaya devam eder, yönetim panelinde uyarı çıkar ve bir saat sonra yeniden denenir.
* **Ürün ve varyasyon bazında** "Fiyat para birimi", döviz cinsinden normal fiyat ve indirimli fiyat alanları.
* **Marj ve yuvarlama**: yüzde ya da sabit TL marj; yuvarlama yok, ,90, ,99 ya da tam sayıya yukarı yuvarlama. Kategoriye göre ayrı kural (alt kategoriler de kapsanır).
* **Toplu düzenleme**: seçili ürünlerin para birimini değiştirin, döviz fiyatını yüzdeyle artırın ya da yeni fiyat verin; tablodan satır satır düzenleyin.
* **CSV içe aktarma, dışa aktarma ve şablon**: Excel ile açılan, Türkçe ondalık virgülü anlayan dosyalar. Satırlar ürün ID'si ya da SKU ile eşleşir.
* **Siparişte kur sabitlenir**: siparişte kullanılan kurlar siparişe ve kalemlerine kaydedilir, sipariş notuna yazılır. Sonraki kur değişiklikleri eski siparişleri etkilemez.
* **Önbellek ve fiyat hash'i**: kur değişince TL fiyatlar yeniden yazılır, ürün geçici verileri (transient) ve varyasyon fiyat önbelleği temizlenir.
* **WooCommerce ile tam uyum**: TL fiyatlar WooCommerce'in kendi fiyat alanlarına yazıldığı için REST API, Store API (blok sepet/ödeme), sıralama, filtreler ve raporlar doğru TL fiyatı görür. HPOS (yüksek performanslı sipariş tabloları) ve blok ödeme ile uyumludur.
* Ziyaretçi tarafına hiçbir dosya, bağlantı ya da imza eklenmez.

**Yakında (Pro sürüm, ayrı eklenti olarak planlanıyor)**

* Çoklu kur kaynağı
* Gün içinde birden çok güncelleme
* Fiyat geçmişi

Bu ücretsiz sürümdeki hiçbir özellik kilitli değildir ve hiçbir zaman kilitlenmeyecektir.

**English**

For shops that buy in foreign currency and sell in Turkish lira: enter product and variation prices in USD, EUR, GBP or any currency published by the Central Bank of the Republic of Türkiye (TCMB). The lira price in your shop is calculated automatically from the daily TCMB indicative rate.

* Daily TCMB rates over WP-Cron at the time you choose; forex buying, forex selling, banknote buying or banknote selling rate.
* When the download fails, the last valid rates stay in use, an admin warning is shown and a retry runs an hour later.
* "Price currency", foreign regular price and foreign sale price for every product and variation.
* Margin (percent or fixed lira amount) and rounding (none, up to ,90, up to ,99, up to a whole number), with separate rules per product category.
* Bulk editing of currency and foreign prices, CSV import, export and template.
* The rates used for an order are locked on the order and written to an order note.
* Product transients, the variation price cache and the price hash are refreshed when rates change.
* Lira prices are stored in the normal WooCommerce price fields, so the REST API, Store API, sorting and filters return correct lira prices. Compatible with HPOS and block checkout.

Coming soon (planned as a separate Pro plugin): multiple rate sources, intraday updates, price history.

== External services ==

This plugin connects to the **Central Bank of the Republic of Türkiye (TCMB)** to download the public daily exchange rate bulletin, which is needed to convert foreign currency prices to Turkish lira.

* **What is requested:** `https://www.tcmb.gov.tr/kurlar/today.xml` with a plain HTTP GET request.
* **What is sent:** nothing about your site, your products, your customers or your orders. The request carries only what any web request carries (your server's IP address and a User-Agent string naming this plugin and its version).
* **When:** once a day at the time set under *Exchange Rates → Rates* (default 15:45, site time zone), shortly after activation, when an administrator clicks *Update now*, and one hour after a failed attempt.
* TCMB disclaimer (terms of use): https://www.tcmb.gov.tr/wps/wcm/connect/EN/TCMB+EN/Bottom+Menu/Other/Disclaimer
* TCMB privacy policy: https://www.tcmb.gov.tr/wps/wcm/connect/EN/TCMB+EN/Bottom+Menu/Other/Privacy+Policy

**Türkçe:** Eklenti yalnızca TCMB'nin herkese açık günlük kur bültenini (`https://www.tcmb.gov.tr/kurlar/today.xml`) indirir. Sitenize, ürünlerinize, müşterilerinize ya da siparişlerinize ait hiçbir veri gönderilmez. İstek her gün ayarlardaki saatte, etkinleştirmeden kısa süre sonra, "Şimdi güncelle" düğmesine basıldığında ve başarısız bir denemeden bir saat sonra yapılır.

== Installation ==

1. Install and activate WooCommerce.
2. Upload the plugin and activate it. The first TCMB bulletin is downloaded a few seconds after activation (or click *Update now*).
3. Open *Exchange Rates* in the admin menu: choose the rate type and update time, then set margin and rounding under *Price rules*.
4. Edit a product, choose a *Price currency* under the prices and enter the foreign regular / sale price. The lira price is filled in when you save.

**Türkçe:** WooCommerce'i kurun, eklentiyi etkinleştirin. Yönetim menüsündeki *Döviz Kuru* ekranından kur türünü ve güncelleme saatini seçin, *Fiyat kuralları* sekmesinden marj ve yuvarlamayı ayarlayın. Ürün düzenleme ekranında fiyatların altındaki *Fiyat para birimi* alanından dövizi seçip döviz fiyatını girin; kaydedince TL fiyat hesaplanır.

== Frequently Asked Questions ==

= TCMB kurları ne zaman güncellenir? / When are TCMB rates published? =

TCMB gösterge kurlarını iş günleri yaklaşık 15:30'da yayımlar. Hafta sonu ve tatillerde son bülten geçerli kalır. Varsayılan güncelleme saati 15:45'tir. / TCMB publishes indicative rates on business days at about 15:30 Türkiye time; the default update time is 15:45.

= WP-Cron çalışmazsa ne olur? / What if WP-Cron does not run? =

WP-Cron sitenize ziyaret geldikçe çalışır. Az ziyaret alan sitelerde sunucunuzda gerçek bir cron görevi tanımlamanızı öneririz. "Şimdi güncelle" düğmesiyle istediğiniz an elle güncelleyebilirsiniz. / WP-Cron runs on site visits; for low-traffic sites set up a real server cron. You can always click *Update now*.

= Kur alınamazsa fiyatlar ne olur? / What happens when rates cannot be downloaded? =

Fiyatlar son geçerli kurla kalır, yönetim panelinde tarihli bir uyarı görünür ve bir saat sonra yeniden denenir. / Prices keep the last valid rates, an admin warning is shown and the plugin retries an hour later.

= Marj ve yuvarlama nasıl hesaplanır? / How are margin and rounding applied? =

TL fiyat = döviz fiyatı × kur; sonra yüzde marj çarpılır ya da sabit TL marj eklenir; en son seçilen bitişe yukarı yuvarlanır (ör. 1.234,12 → ,90 ile 1.234,90). / Lira price = foreign price × rate, then the margin, then rounding up to the chosen ending.

= Bir ürün birden çok kategorideyse hangi kural geçerli? / Which rule wins for a product in several categories? =

Kategori kuralları listesinde ilk eşleşen kural. Bir kategori kuralı alt kategorileri de kapsar. Hiçbiri eşleşmezse varsayılan kural kullanılır. / The first matching category rule in the list (sub-categories included), otherwise the default rule.

= Eski siparişlerin tutarı kur değişince değişir mi? / Do old orders change when rates change? =

Hayır. Sipariş anındaki kur siparişe ve kalemlerine kaydedilir ve sipariş notuna yazılır. / No. The rates are locked on the order and written to an order note.

= REST API ve önbellek eklentileri doğru fiyatı görür mü? / Do the REST API and cache plugins see correct prices? =

Evet. TL fiyatlar WooCommerce'in kendi fiyat alanlarına yazılır. Sayfa önbelleği kullanıyorsanız `fcdk_prices_recalculated` eylemine bağlanıp önbelleği temizleyebilirsiniz. / Yes. Lira prices are stored in the normal WooCommerce fields. Page cache plugins can purge on the `fcdk_prices_recalculated` action.

= CSV dosyasının biçimi nedir? / What is the CSV format? =

Noktalı virgülle ayrılmış, UTF-8. Sütunlar: id, parent_id, type, sku, name, currency, regular_price, sale_price, tl_regular_price, tl_sale_price. İçe aktarmada yalnız id/sku, currency, regular_price ve sale_price okunur. "Şablonu indir" düğmesi örnek dosya verir. / Semicolon separated UTF-8; import reads only id/sku, currency, regular_price and sale_price.

== Screenshots ==

1. Rates: TCMB rates, change against the previous bulletin, last update and the "Update now" button. / Kurlar ekranı.
2. Price rules: default margin and rounding plus category rules with a live example. / Fiyat kuralları.
3. Bulk editing: CSV import / export / template and the product table. / Toplu düzenleme.
4. Product editor: price currency and foreign prices. / Ürün düzenleme ekranı.
5. The order note with the locked rates. / Sipariş notunda sabitlenen kur.

== Changelog ==

= 1.0.0 =
* First release: daily TCMB rates, product and variation foreign prices, margin and rounding rules per category, bulk editing, CSV import / export / template, rate lock on orders, HPOS and block checkout compatibility.

== Upgrade Notice ==

= 1.0.0 =
First release.
