=== Precios al Día for WooCommerce ===
Contributors: preciosaldia
Tags: dollar, prices, woocommerce, inflation, argentina
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Set a base price in US dollars and your peso prices update every day with the Argentine official, MEP or blue dollar rate. With preview.

== Description ==

**Precios al Día** is built for Argentine WooCommerce stores that sell dollar-priced goods and today update their peso prices by hand every time the exchange rate moves.

Enter a **base price in USD** once for each product (or each variation) and the plugin calculates the price in Argentine pesos:

`price = USD base price × exchange rate × (1 + margin / 100)`, then applies the rounding you choose.

The interface is in English and includes Spanish translations for Argentina (es_AR), Spain (es_ES) and Mexico (es_MX).

= Features =

* **Automatic daily rate**: uses the selling rate of the official, MEP (bolsa) or blue dollar published by dolarapi.com and updates prices once a day, without you having to open the dashboard.
* **Preview before applying**: a table with the current and new price of every product, the current and new sale price, and the reason for anything that does not change. If it looks right, apply it with exactly the same rate you previewed.
* **Protection against bad data**: if dolarapi.com does not answer, returns an error, an invalid or ambiguous value, or a rate older than 4 days, **no price is changed at all** and the error is shown on the plugin screen. If something fails halfway through an update, the products already changed in that run are reverted.
* **Change limit**: if a price would go up or down by more than the percentage you set (30% by default), that product is left untouched and reported so you can review it.
* **Simple and variable products**: each variation can have its own USD base price; the variable product price range is synced automatically.
* **Sale prices**: an existing sale price is scaled by the same ratio as the regular price. If it would end up equal to or higher than the regular price, it is left as is and you get a warning.
* **Margin and rounding**: margin in % (can be 0 or negative) and rounding to the nearest integer or up to the next multiple of 10, 100 or 1000.
* **Only touches what you mark**: products without a USD base price are never modified.

Prices are saved through the WooCommerce product API, so price caches and lookup tables stay in sync. Compatible with WooCommerce High-Performance Order Storage (HPOS).

A Pro version with CPI (inflation) adjustments and per-category rules is planned.

== Installation ==

1. Install and activate WooCommerce.
2. Upload the `precios-al-dia` folder to `/wp-content/plugins/`, or install the plugin from **Plugins > Add New**, and activate it.
3. Go to **WooCommerce > Precios al Día** and choose the rate, margin, rounding and change limit. Save.
4. In every product you want to manage, fill in **USD base price** (General tab for simple products, or inside each variation).
5. Click **Preview**, check the table and, if everything is right, click **Apply these changes**. From then on, if automatic update is enabled, prices update by themselves once a day.

== Frequently Asked Questions ==

= What happens if dolarapi.com fails or the rate is old? =

No price is changed. The plugin makes a single request; if the connection fails, takes more than 10 seconds, returns an HTTP error, returns something that cannot be read, does not include the selected rate, includes an invalid value or a date older than 4 days, the whole update is cancelled and the error is recorded under **WooCommerce > Precios al Día > Status**.

= Which exchange rate does it use? =

The **selling** rate of the official, MEP (bolsa) or blue dollar, as you choose, as published by dolarapi.com. The default is the official rate.

= Does it work with variable products? =

Yes. Each variation has its own "USD base price" field, and the variable product price (the range customers see) is synced at the end of each update.

= What about sale prices? =

If a product has a sale price, it is adjusted by the same ratio as the regular price and with the same rounding. If the result would be equal to or higher than the new regular price, the sale price is left unchanged and a warning is shown in the preview and in the status section.

= What is the change limit for? =

So that an odd value cannot change your prices all at once. If the new price differs from the current one by more than the configured percentage (30% by default), that product is not updated and is listed in the report for you to review. A change exactly at the limit is applied. 0 means no limit. A product that has no price yet gets its first price without a limit.

= Will it change my prices without telling me? =

It only changes products where you entered a USD base price. The automatic daily update can be turned off in the settings; you can always see what will happen first with the preview, and every run is recorded with the rate used and what was changed, blocked or skipped.

= Does it handle multiple currencies or show prices in dollars to customers? =

No. The store keeps selling in pesos; the dollar is only the basis for the calculation. It is not a multi-currency plugin.

= What happens when I uninstall the plugin? =

Deleting the plugin from **Plugins** removes its settings, its run history and the **USD base price** you entered in your products. Peso prices stay as they are at that moment. Simply deactivating it deletes nothing (it only stops the automatic update).

= What are the server requirements? =

WordPress 6.4+, WooCommerce and PHP 7.4+ on a 64-bit server (prices are calculated with exact integer arithmetic). On 32-bit PHP the plugin shows a notice and does nothing. On multisite, uninstalling cleans every site of the network.

= Do I need an account or an API key? =

No. dolarapi.com is a free public service, and the plugin does not send any data about your store to any server.

== Screenshots ==

1. Settings (WooCommerce > Precios al Día): exchange rate (official, MEP or blue dollar), margin, rounding, change limit and automatic daily update, plus the Preview and Update now buttons.
2. Preview before applying: current and new price of each product and variation, the sale price scaled by the same ratio, and a product blocked because the change exceeds the limit.
3. "USD base price" field in the General tab of a simple product, next to the regular and sale prices.
4. "USD base price" field in each variation of a variable product.
5. After applying: summary notice, next automatic update and last result, listing the product that was blocked by the change limit.

== External services ==

This plugin connects to **dolarapi.com** (https://dolarapi.com), a public service that publishes Argentine dollar exchange rates, to get the selling rate of the official, MEP or blue dollar.

* What is sent: a GET request to `https://dolarapi.com/v1/dolares`, with no data about the store, its products or its customers (only the technical data of any web connection, such as the server IP address).
* When: when you click **Preview** or **Update now**, and once a day if automatic update is enabled.
* Service website, terms of use and privacy information: https://dolarapi.com

The plugin uses no other external services, does no tracking and loads no remote assets.

== Changelog ==

= 1.0.0 =
* First release: English interface with es_AR, es_ES and es_MX translations, USD base price for simple products and variations, official/MEP/blue rate from dolarapi.com, margin, rounding, change limit, scaled sale prices, preview, manual and automatic daily update, protection against bad data and clean uninstall.

== Upgrade Notice ==

= 1.0.0 =
First release.
