=== Bilibú Sync ===
Contributors: {{WPORG_USERNAME}}
Tags: car dealer, vehicles, used cars, listings, marketplace
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.3
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Publish the vehicles on your dealer website to Bilibú, the Spanish used vehicle marketplace, and keep them up to date automatically.

== Description ==

[Bilibú](https://bilibu.es/) is a marketplace for used vehicles sold by professional dealers in Spain. This plugin connects your WordPress website with your Bilibú dealer account, so your website stock and your Bilibú listings are always the same:

* When you publish or update a vehicle, it is sent to Bilibú with its photos.
* When you change the price, or mark it as reserved or sold, the listing is updated.
* When you unpublish it or move it to the trash, it stops being shown on Bilibú; when you delete it permanently, it is removed.
* Every night a full sync reviews the whole stock, so nothing gets out of step.
* Under «Bilibú → Enquiries» you can read the enquiries that buyers send through Bilibú.

It works with any way of storing vehicles in WordPress: a custom post type, custom fields (post meta or Advanced Custom Fields), taxonomies, or dealer themes such as Vehica. For each piece of data you choose where it comes from, and you can preview exactly what will be sent before syncing.

All kinds of used vehicles are supported: cars, motorcycles, vans, trucks, motorhomes, caravans, boats, aircraft and machinery.

The plugin interface is available in English and Spanish.

= Requirements =

* A dealer account on Bilibú, approved by Bilibú (free during the launch phase).
* An API key, created in your dealer panel at bilibu.es (API section).

== External services ==

This plugin connects to the **Bilibú API** (`https://bilibu.es/api/v1`), a service run by Bilibú, to publish your vehicles on the bilibu.es marketplace and to read the enquiries buyers send about them. This is the whole purpose of the plugin.

Nothing is sent until an administrator saves a Bilibú API key in the plugin settings. From then on:

* **Vehicle data is sent** when a vehicle is saved, unpublished, trashed or deleted (if automatic sync is enabled), once a day for the full sync (if enabled), and when an administrator presses «Sync everything now». The data sent is what you map in the settings: make, model, version, year, mileage or engine hours, price, fuel, transmission, body type, power, colour, description, status, the post ID as a reference, and the public URLs of the vehicle photos (Bilibú downloads those images). The request also identifies your site URL in the User-Agent header.
* **Enquiries are read** only when an administrator opens «Bilibú → Enquiries». They contain the buyer's name, email, phone and message; they are shown on screen and not stored in WordPress.
* **«Test connection»** sends a request to check that the API key is valid.

No data about your website visitors is sent, and the plugin adds nothing to the front end of your site.

* Bilibú terms of use: https://bilibu.es/legal/condiciones-empresas/
* Bilibú privacy policy: https://bilibu.es/legal/privacidad/
* API documentation: https://bilibu.es/desarrolladores/

== Installation ==

1. Install the plugin from «Plugins → Add New» (search for «Bilibú Sync») or upload the zip file, and activate it.
2. In your Bilibú dealer panel (https://bilibu.es/panel/), API section, create an API key.
3. In WordPress, open the «Bilibú» menu: paste the key, choose the post type of your vehicles and set where each field comes from.
4. Press «Preview data» to check what will be sent and, if it looks right, «Sync everything now».

Available sources for each field:

* `title`, `content`, `excerpt`, `featured` (featured image)
* `meta:key` (custom field), `acf:field` (Advanced Custom Fields), `tax:taxonomy`
* `rest:field` (the field as returned by the WordPress REST API; useful with themes such as Vehica)
* `fixed:value` (always the same value)
* Several alternatives separated by `|`, and `*100` at the end to multiply (metres → centimetres).

== Frequently Asked Questions ==

= Do I need a Bilibú account? =

Yes. The plugin publishes your vehicles on your own Bilibú dealer account. Dealers can register at https://bilibu.es/vender/.

= Will my listings be duplicated if they are already on Bilibú? =

No. Each vehicle is identified as prefix + post ID (by default `wp-123`). If it already exists on Bilibú with that reference, it is updated.

= What happens to vehicles on Bilibú that are not on my website? =

The full sync only deactivates vehicles that have a reference from this website and are no longer published here. Vehicles you created by hand in the Bilibú panel are never touched.

= My theme stores vehicles in its own way. Will it work? =

Most likely. Use «Preview data» to see what the plugin reads from your latest vehicle, and adjust the sources. If your theme only exposes some fields through the REST API, use `rest:field`. Bilibú can also send you a ready-made configuration for your theme to paste in «Export / import configuration».

= Does it send data about my visitors or customers? =

No. Only the data of your vehicles is sent. See the «External services» section.

== Screenshots ==

1. Settings: connection, post type and automation.
2. Field mapping: where each piece of data comes from.
3. The «Bilibú» column in the vehicle list, with a link to each listing.
4. Enquiries received on Bilibú.

== Changelog ==

= 1.0.3 =
* Photos: without a gallery field mapped, the theme gallery (Vehica and similar) is detected and sent in the same order as on the vehicle page.

= 1.0.2 =
* The sync is only shown as complete once Bilibú has processed every photo; meanwhile the settings page shows how many are left.

= 1.0.1 =
* Photos: when no gallery field is mapped, all the images uploaded to the vehicle are sent, not only the featured one.

= 1.0.0 =
* First public version.

== Upgrade Notice ==

= 1.0.3 =
Photos keep the order of the vehicle page.

= 1.0.2 =
Shows the photos Bilibú is still processing after a sync.

= 1.0.1 =
Sends all the photos of each vehicle even without a gallery field mapped.

= 1.0.0 =
First public version.
